validate(); $config_validator->save(); } $query = array( 'post' => $clicktotalk_form ? $clicktotalk_form->id() : 0, 'active-tab' => isset( $_POST['active-tab'] ) ? (int) $_POST['active-tab'] : 0, ); if ( ! $clicktotalk_form ) { $query['message'] = 'failed'; } elseif ( -1 == $id ) { $query['message'] = 'created'; } else { $query['message'] = 'saved'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxc2c', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'copy' == $action ) { $id = empty( $_POST['post_ID'] ) ? absint( $_REQUEST['post'] ) : absint( $_POST['post_ID'] ); check_admin_referer( 'wp3cxc2c-copy-clicktotalk-form_' . $id ); if ( ! current_user_can( 'wp3cxc2c_edit_clicktotalk_form', $id ) ) { wp_die( __( 'You are not allowed to edit this item.', '3cx-clicktotalk' ) ); } $query = array(); if ( $clicktotalk_form = wp3cxc2c_clicktotalk_form( $id ) ) { $new_clicktotalk_form = $clicktotalk_form->copy(); $new_clicktotalk_form->save(); $query['post'] = $new_clicktotalk_form->id(); $query['message'] = 'created'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxc2c', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'delete' == $action ) { if ( ! empty( $_POST['post_ID'] ) ) { check_admin_referer( 'wp3cxc2c-delete-clicktotalk-form_' . $_POST['post_ID'] ); } elseif ( ! is_array( $_REQUEST['post'] ) ) { check_admin_referer( 'wp3cxc2c-delete-clicktotalk-form_' . $_REQUEST['post'] ); } else { check_admin_referer( 'bulk-posts' ); } $posts = empty( $_POST['post_ID'] ) ? (array) $_REQUEST['post'] : (array) $_POST['post_ID']; $deleted = 0; foreach ( $posts as $post ) { $post = WP3CXC2C_ClickToTalkForm::get_instance( $post ); if ( empty( $post ) ) { continue; } if ( ! current_user_can( 'wp3cxc2c_delete_clicktotalk_form', $post->id() ) ) { wp_die( __( 'You are not allowed to delete this item.', '3cx-clicktotalk' ) ); } if ( ! $post->delete() ) { wp_die( __( 'Error in deleting.', '3cx-clicktotalk' ) ); } $deleted += 1; } $query = array(); if ( ! empty( $deleted ) ) { $query['message'] = 'deleted'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxc2c', false ) ); wp_safe_redirect( $redirect_to ); exit(); } $_GET['post'] = isset( $_GET['post'] ) ? $_GET['post'] : ''; $post = null; if ( 'wp3cxc2c-new' == $plugin_page ) { $post = WP3CXC2C_ClickToTalkForm::get_template( array( 'locale' => isset( $_GET['locale'] ) ? $_GET['locale'] : null, ) ); } elseif ( ! empty( $_GET['post'] ) ) { $post = WP3CXC2C_ClickToTalkForm::get_instance( $_GET['post'] ); } $current_screen = get_current_screen(); $help_tabs = new WP3CXC2C_Help_Tabs( $current_screen ); if ( $post && current_user_can( 'wp3cxc2c_edit_clicktotalk_form', $post->id() ) ) { $help_tabs->set_help_tabs( 'edit' ); } else { $help_tabs->set_help_tabs( 'list' ); if ( ! class_exists( 'WP3CXC2C_ClickToTalk_Form_List_Table' ) ) { require_once WP3CXC2C_PLUGIN_DIR . '/admin/includes/class-clicktotalk-forms-list-table.php'; } add_filter( 'manage_' . $current_screen->id . '_columns', array( 'WP3CXC2C_ClickToTalk_Form_List_Table', 'define_columns' ) ); add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'wp3cxc2c_clicktotalk_forms_per_page', ) ); } } add_action( 'admin_enqueue_scripts', 'wp3cxc2c_admin_enqueue_scripts' ); function wp3cxc2c_admin_enqueue_scripts( $hook_suffix ) { if ( false === strpos( $hook_suffix, 'wp3cxc2c' ) ) { return; } wp_enqueue_style( '3cx-clicktotalk-admin', wp3cxc2c_plugin_url( 'admin/css/styles.css' ), array(), WP3CXC2C_VERSION, 'all' ); if ( wp3cxc2c_is_rtl() ) { wp_enqueue_style( '3cx-clicktotalk-admin-rtl', wp3cxc2c_plugin_url( 'admin/css/styles-rtl.css' ), array(), WP3CXC2C_VERSION, 'all' ); } wp_enqueue_script( 'wp3cxc2c-admin', wp3cxc2c_plugin_url( 'admin/js/scripts.js' ), array( 'jquery', 'jquery-ui-tabs' ), WP3CXC2C_VERSION, true ); $args = array( 'apiSettings' => array( 'root' => esc_url_raw( rest_url( '3cx-clicktotalk/v1' ) ), 'namespace' => '3cx-clicktotalk/v1', 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), ), 'pluginUrl' => wp3cxc2c_plugin_url(), 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", '3cx-clicktotalk' ), 'activeTab' => isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : 0, 'configValidator' => array( 'errors' => array(), 'howToCorrect' => __( "How to resolve?", '3cx-clicktotalk' ), 'oneError' => __( '1 configuration error detected', '3cx-clicktotalk' ), 'manyErrors' => __( '%d configuration errors detected', '3cx-clicktotalk' ), 'oneErrorInTab' => __( '1 configuration error detected in this tab panel', '3cx-clicktotalk' ), 'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', '3cx-clicktotalk' ), 'docUrl' => '', /* translators: screen reader text */ 'iconAlt' => __( '(configuration error)', '3cx-clicktotalk' ), ), ); if ( ( $post = wp3cxc2c_get_current_clicktotalk_form() ) && current_user_can( 'wp3cxc2c_edit_clicktotalk_form', $post->id() ) && wp3cxc2c_validate_configuration() ) { $config_validator = new WP3CXC2C_ConfigValidator( $post ); $config_validator->restore(); $args['configValidator']['errors'] = $config_validator->collect_error_messages(); } wp_localize_script( 'wp3cxc2c-admin', 'wp3cxc2c', $args ); } function wp3cxc2c_admin_management_page() { if ( $post = wp3cxc2c_get_current_clicktotalk_form() ) { $post_id = $post->initial() ? -1 : $post->id(); require_once WP3CXC2C_PLUGIN_DIR . '/admin/includes/editor.php'; require_once WP3CXC2C_PLUGIN_DIR . '/admin/edit-clicktotalk-form.php'; return; } $list_table = new WP3CXC2C_ClickToTalk_Form_List_Table(); $list_table->prepare_items(); ?>

%2$s', esc_url( menu_page_url( 'wp3cxc2c-new', false ) ), esc_html( __( 'Add New', '3cx-clicktotalk' ) ) ); } if ( ! empty( $_REQUEST['s'] ) ) { echo sprintf( '' /* translators: %s: search keywords */ . __( 'Search results for “%s”', '3cx-clicktotalk' ) . '', esc_html( $_REQUEST['s'] ) ); } ?>
search_box( __( 'Search Click To Talk item', '3cx-clicktotalk' ), 'wp3cxc2c-clicktotalk' ); ?> display(); ?>

%s

', esc_html( $updated_message ) ); return; } if ( 'failed' == $_REQUEST['message'] ) { $updated_message = __( "There was an error saving the Click To Talk item.", '3cx-clicktotalk' ); echo sprintf( '

%s

', esc_html( $updated_message ) ); return; } } add_action( 'wp3cxc2c_admin_warnings', 'wp3cxc2c_old_wp_version_error' ); function wp3cxc2c_old_wp_version_error() { $wp_version = get_bloginfo( 'version' ); if ( ! version_compare( $wp_version, WP3CXC2C_REQUIRED_WP_VERSION, '<' ) ) { return; } ?>

3CX Click To Talk %1$s requires WordPress %2$s or higher. Please update WordPress first.', '3cx-clicktotalk' ), WP3CXC2C_VERSION, WP3CXC2C_REQUIRED_WP_VERSION, admin_url( 'update-core.php' ) ); ?>

id(); if ( current_user_can( 'wp3cxc2c_edit_clicktotalk_form', $post_id ) ) { return; } $message = __( "You are not allowed to edit this Click To Talk item.", '3cx-clicktotalk' ); echo sprintf( '

%s

', esc_html( $message ) ); }