validate(); $config_validator->save(); } $query = array( 'post' => $webinar_form ? $webinar_form->id() : 0, 'active-tab' => isset( $_POST['active-tab'] ) ? intval($_POST['active-tab']) : 0 ); if ( ! $webinar_form ) { $query['message'] = 'failed'; } elseif ( -1 == $id ) { $query['message'] = 'created'; } else { $query['message'] = 'saved'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'copy' == $action ) { $id = empty( $_POST['post_ID'] ) ? intval( $_REQUEST['post'] ) : intval( $_POST['post_ID'] ); check_admin_referer( 'wp3cxw-copy-webinar-form_' . $id ); if ( ! current_user_can( 'wp3cxw_edit_webinar_form', $id ) ) { wp_die( __( 'You are not allowed to edit this item.', '3cx-webinar' ) ); } $query = array(); if ( $webinar_form = wp3cxw_webinar_form( $id ) ) { $new_webinar_form = $webinar_form->copy(); $new_webinar_form->save(); $query['post'] = $new_webinar_form->id(); $query['message'] = 'created'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'delete' == $action ) { $rawposts = (array) $_REQUEST['post']; $posts = array(); foreach($rawposts as $v){ $v=intval($v); if (!empty($v)) { $posts[]=$v; } } $id = empty( $_POST['post_ID'] ) ? intval( $_REQUEST['post'] ) : intval( $_POST['post_ID'] ); check_admin_referer( 'wp3cxw-delete-webinar-form_' . $id ); $deleted = 0; foreach ( $posts as $id ) { $post = WP3CXW_WebinarForm::get_instance( $id ); if ( empty( $post ) ) { continue; } if ( ! current_user_can( 'wp3cxw_delete_webinar_form', $post->id() ) ) { wp_die( __( 'You are not allowed to delete this item.', '3cx-webinar' ) ); } if ( ! $post->delete() ) { wp_die( __( 'Error in deleting.', '3cx-webinar' ) ); } $deleted += 1; } $query = array(); if ( ! empty( $deleted ) ) { $query['message'] = 'deleted'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } $_GET['post'] = isset( $_GET['post'] ) ? intval($_GET['post']) : ''; $post = null; if ( 'wp3cxw-new' == $plugin_page ) { // TODO: add support for multilanguage $post = WP3CXW_WebinarForm::get_template( array( 'locale' => null ) ); } elseif ( ! empty( $_GET['post'] ) ) { $post = WP3CXW_WebinarForm::get_instance( intval($_GET['post'])) ; } $current_screen = get_current_screen(); $help_tabs = new WP3CXW_Help_Tabs( $current_screen ); if ( $post && current_user_can( 'wp3cxw_edit_webinar_form', $post->id() ) ) { $help_tabs->set_help_tabs( 'edit' ); } else { $help_tabs->set_help_tabs( 'list' ); if ( ! class_exists( 'WP3CXW_Webinar_Form_List_Table' ) ) { require_once WP3CXW_PLUGIN_DIR . '/admin/includes/class-webinar-forms-list-table.php'; } add_filter( 'manage_' . $current_screen->id . '_columns', array( 'WP3CXW_Webinar_Form_List_Table', 'define_columns' ) ); add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'wp3cxw_webinar_forms_per_page', ) ); } } add_action( 'admin_enqueue_scripts', 'wp3cxw_admin_enqueue_scripts' ); function wp3cxw_admin_enqueue_scripts( $hook_suffix ) { if ( false === strpos( $hook_suffix, 'wp3cxw' ) ) { return; } wp_enqueue_style( '3cx-webinar-admin', wp3cxw_plugin_url( 'admin/css/styles.css' ), array(), WP3CXW_VERSION, 'all' ); wp_enqueue_style( '3cx-webinar-dd', wp3cxw_plugin_url( 'includes/css/dd.css' ), array(), WP3CXW_VERSION, 'all' ); wp_enqueue_style( '3cx-webinar-flags', wp3cxw_plugin_url( 'includes/css/flags.css' ), array(), WP3CXW_VERSION, 'all' ); if ( wp3cxw_is_rtl() ) { wp_enqueue_style( '3cx-webinar-admin-rtl', wp3cxw_plugin_url( 'admin/css/styles-rtl.css' ), array(), WP3CXW_VERSION, 'all' ); } wp_enqueue_script( 'wp3cxw-admin', wp3cxw_plugin_url( 'admin/js/scripts.js' ), array( 'jquery', 'jquery-ui-tabs' ), WP3CXW_VERSION, true ); wp_enqueue_script( 'wp3cxw-admin-dd', wp3cxw_plugin_url( 'includes/js/jquery.dd.js' ), array( 'jquery' ), WP3CXW_VERSION, false ); $args = array( 'apiSettings' => array( 'root' => esc_url_raw( rest_url( '3cx-webinar/v1' ) ), 'namespace' => '3cx-webinar/v1', 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), ), 'pluginUrl' => wp3cxw_plugin_url(), 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", '3cx-webinar' ), 'activeTab' => isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : 0, 'configValidator' => array( 'errors' => array(), 'howToCorrect' => __( "How to resolve?", '3cx-webinar' ), 'oneError' => __( '1 configuration error detected', '3cx-webinar' ), 'manyErrors' => __( '%d configuration errors detected', '3cx-webinar' ), 'oneErrorInTab' => __( '1 configuration error detected in this tab panel', '3cx-webinar' ), 'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', '3cx-webinar' ), 'docUrl' => '', /* translators: screen reader text */ 'iconAlt' => __( '(configuration error)', '3cx-webinar' ), ), ); if ( ( $post = wp3cxw_get_current_webinar_form() ) && current_user_can( 'wp3cxw_edit_webinar_form', $post->id() ) && wp3cxw_validate_configuration() ) { $config_validator = new WP3CXW_ConfigValidator( $post ); $config_validator->restore(); $args['configValidator']['errors'] = $config_validator->collect_error_messages(); } wp_localize_script( 'wp3cxw-admin', 'wp3cxw', $args ); } function wp3cxw_admin_management_page() { if ( $post = wp3cxw_get_current_webinar_form() ) { $post_id = $post->initial() ? -1 : $post->id(); require_once WP3CXW_PLUGIN_DIR . '/admin/includes/editor.php'; require_once WP3CXW_PLUGIN_DIR . '/admin/edit-webinar-form.php'; return; } $list_table = new WP3CXW_Webinar_Form_List_Table(); $list_table->prepare_items(); ?>

%2$s', esc_url( menu_page_url( 'wp3cxw-new', false ) ), esc_html( __( 'Add New', '3cx-webinar' ) ) ); } ?>
display(); ?>

%s

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

%s

', esc_html( $updated_message ) ); return; } } add_action( 'wp3cxw_admin_warnings', 'wp3cxw_old_wp_version_error' ); function wp3cxw_old_wp_version_error() { $wp_version = get_bloginfo( 'version' ); if ( ! version_compare( $wp_version, WP3CXW_REQUIRED_WP_VERSION, '<' ) ) { return; } ?>

3CX Webinar %1$s requires WordPress %2$s or higher. Please update WordPress first.', '3cx-webinar' ), WP3CXW_VERSION, WP3CXW_REQUIRED_WP_VERSION, admin_url( 'update-core.php' ) ); ?>

id(); if ( current_user_can( 'wp3cxw_edit_webinar_form', $post_id ) ) { return; } $message = __( "You are not allowed to edit this Webinar form.", '3cx-webinar' ); echo sprintf( '

%s

', esc_html( $message ) ); }