' . esc_html__( 'Pages', 'mainwp' ) . '', 'read', 'PageBulkManage', array( static::get_class_name(), 'render' ) ); add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_page' ) ); add_filter( 'manage_' . $_page . '_columns', array( static::get_class_name(), 'get_manage_columns' ) ); $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '
' . esc_html__( 'Add New', 'mainwp' ) . '
', 'read', 'PageBulkAdd', array( static::get_class_name(), 'render_bulk_add' ) ); add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_add_edit' ) ); $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '
' . esc_html__( 'Edit Page', 'mainwp' ) . '
', 'read', 'PageBulkEdit', array( static::get_class_name(), 'render_bulk_edit' ) ); add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_add_edit' ) ); add_submenu_page( 'mainwp_tab', esc_html__( 'Posting new bulkpage', 'mainwp' ), '
' . esc_html__( 'Add New Page', 'mainwp' ) . '
', 'read', 'PostingBulkPage', array( static::get_class_name(), 'posting' ) ); // removed from menu afterwards. /** * Pages Subpages * * Filters subpages for the Pages page. * * @since Unknown */ $sub_pages = array(); $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-page', array( $sub_pages ), '4.0.7.2', 'mainwp_getsubpages_page' ); // @deprecated Use 'mainwp_getsubpages_page' instead. NOSONAR - not IP. static::$subPages = apply_filters( 'mainwp_getsubpages_page', $sub_pages ); if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { foreach ( static::$subPages as $subPage ) { if ( isset( $subPage['no_page'] ) && $subPage['no_page'] ) { continue; } if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { continue; } add_submenu_page( 'mainwp_tab', $subPage['title'], '
' . $subPage['title'] . '
', 'read', 'Page' . $subPage['slug'], $subPage['callback'] ); } } static::init_left_menu( static::$subPages ); } /** * Method on_load_add_edit() * * Add edit on load bulk posts. * * @return void Returns post to edit. * * @uses \MainWP\Dashboard\MainWP_Post::on_load_bulkpost() */ public static function on_load_add_edit() { global $_mainwp_menu_active_slugs; if ( isset( $_GET['page'] ) && 'PageBulkAdd' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized /** * MainWP default post to edit. * * @global string */ global $_mainwp_default_post_to_edit; $post_type = 'bulkpage'; $_mainwp_default_post_to_edit = get_default_post_to_edit( $post_type, true ); $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; } else { $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $_mainwp_menu_active_slugs['PageBulkEdit'] = 'PageBulkManage'; // to fix hidden second menu level. } if ( ! $post_id ) { wp_die( esc_html__( 'Invalid post.' ) ); } MainWP_Post::on_load_bulkpost( $post_id ); } /** * Method init_subpages_menu() * * Initiate subpages menu. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() */ public static function init_subpages_menu() { // phpcs:ignore -- NOSONAR - complex. ?> esc_html__( 'Pages', 'mainwp' ), 'parent_key' => 'managesites', 'slug' => 'PageBulkManage', 'href' => 'admin.php?page=PageBulkManage', 'icon' => '', 'leftsub_order' => 8, ), 1 ); $init_sub_subleftmenu = array( array( 'title' => esc_html__( 'Manage Pages', 'mainwp' ), 'parent_key' => 'PageBulkManage', 'href' => 'admin.php?page=PageBulkManage', 'slug' => 'PageBulkManage', 'right' => 'manage_pages', 'leftsub_order_level2' => 1, ), array( 'title' => esc_html__( 'Add New', 'mainwp' ), 'parent_key' => 'PageBulkManage', 'href' => 'admin.php?page=PageBulkAdd', 'slug' => 'PageBulkAdd', 'right' => 'manage_pages', 'leftsub_order_level2' => 2, ), ); MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'PageBulkManage', 'Page' ); foreach ( $init_sub_subleftmenu as $item ) { if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { continue; } MainWP_Menu::add_left_menu( $item, 2 ); } } /** * Method on_load_page() * * On page load. */ public static function on_load_page() { add_action( 'admin_head', array( static::get_class_name(), 'admin_head' ) ); add_filter( 'hidden_columns', array( static::get_class_name(), 'get_hidden_columns' ), 10, 3 ); add_action( 'mainwp_screen_options_modal_bottom', array( static::get_class_name(), 'hook_screen_options_modal_bottom' ), 10, 2 ); } /** * Method get_manage_columns() * * Get columns to display. * * @return array $colums Columns to display. * * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() */ public static function get_manage_columns() { $colums = array( 'title' => 'Title', 'author' => 'Author', 'comments' => 'Comments', 'date' => 'Date', 'status' => 'Status', 'seo-links' => 'Links', 'seo-linked' => 'Linked', 'seo-score' => 'SEO Score', 'seo-readability' => 'Readability score', 'website' => 'Website', ); if ( ! MainWP_Utility::enabled_wp_seo() ) { unset( $colums['seo-links'] ); unset( $colums['seo-linked'] ); unset( $colums['seo-score'] ); unset( $colums['seo-readability'] ); } return $colums; } /** * Method admin_head() * * Add current screen ID to html header. */ public static function admin_head() { /** * Current screen. * * @global string */ global $current_screen; ?> id ) { $hidden = get_user_option( 'manage' . strtolower( $screen->id ) . 'columnshidden' ); } if ( ! is_array( $hidden ) ) { $hidden = array(); } return $hidden; } /** * Method hook_screen_options_modal_bottom() * * Render screen options modal bottom. */ public static function hook_screen_options_modal_bottom() { $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( 'PageBulkManage' === $page ) { $show_columns = get_user_option( 'mainwp_managepages_show_columns' ); if ( ! is_array( $show_columns ) ) { $show_columns = array(); } $cols = static::get_manage_columns(); MainWP_UI::render_showhide_columns_settings( $cols, $show_columns, 'page' ); } } /** * Method render_header() * * Render page header. * * @param string $shownPage Current page. * @param int $post_id Post ID. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation() */ public static function render_header( $shownPage = '', $post_id = null ) { // phpcs:ignore -- NOSONAR - complex. $params = array( 'title' => esc_html__( 'Pages', 'mainwp' ), ); MainWP_UI::render_top_header( $params ); $renderItems = array(); if ( \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Manage Pages', 'mainwp' ), 'href' => 'admin.php?page=PageBulkManage', 'active' => ( 'BulkManage' === $shownPage ) ? true : false, ); if ( 'BulkEdit' === $shownPage ) { $renderItems[] = array( 'title' => esc_html__( 'Edit Page', 'mainwp' ), 'href' => 'admin.php?page=PageBulkEdit&post_id=' . esc_attr( $post_id ), 'active' => true, ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PageBulkAdd' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Add New', 'mainwp' ), 'href' => 'admin.php?page=PageBulkAdd', 'active' => ( 'BulkAdd' === $shownPage ) ? true : false, ); } } if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { foreach ( static::$subPages as $subPage ) { if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { continue; } if ( isset( $subPage['tab_link_hidden'] ) && true === $subPage['tab_link_hidden'] ) { $tab_link = '#'; } else { $tab_link = 'admin.php?page=Page' . $subPage['slug']; } $item = array(); $item['title'] = $subPage['title']; $item['href'] = $tab_link; $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false; $renderItems[] = $item; } } MainWP_UI::render_page_navigation( $renderItems, __CLASS__ ); } /** * Method render_footer() * * Render page footer. */ public static function render_footer() { echo ''; } /** * Renders Bulk Page Manager. * * @return void * * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() */ public static function render() { if ( ! \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); return; } $cachedSearch = MainWP_Cache::get_cached_context( 'Page' ); $selected_sites = array(); $selected_groups = array(); $selected_clients = array(); if ( null !== $cachedSearch ) { if ( isset( $cachedSearch['sites'] ) && is_array( $cachedSearch['sites'] ) ) { $selected_sites = $cachedSearch['sites']; } elseif ( isset( $cachedSearch['groups'] ) && is_array( $cachedSearch['groups'] ) ) { $selected_groups = $cachedSearch['groups']; } elseif ( isset( $cachedSearch['clients'] ) && is_array( $cachedSearch['clients'] ) ) { $selected_clients = $cachedSearch['clients']; } } ?>
', ' ' ); ?>
$selected_sites, 'selected_groups' => $selected_groups, 'selected_clients' => $selected_clients, 'class' => 'mainwp_select_sites_box_left', 'show_client' => true, ); MainWP_UI_Select_Sites::select_sites_box( $sel_params ); ?>
render_demo_disable_button( '' ); } else { ?>
'true', 'paging' => 'true', 'info' => 'true', 'stateSave' => 'true', 'scrollX' => 'true', 'colReorder' => '{columns:":not(.check-column):not(:last-child)"}', 'order' => '[]', 'responsive' => 'true', ); /** * Filter: mainwp_pages_table_fatures * * Filters the Manage Pages table features. * * @since 4.1 */ $table_features = apply_filters( 'mainwp_pages_table_fatures', $table_features ); ?> get_website_by_id( $v ); if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) { $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } } } } if ( ! empty( $groups ) ) { foreach ( $groups as $v ) { if ( MainWP_Utility::ctype_digit( $v ) ) { $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } MainWP_DB::free_result( $websites ); } } } if ( '' !== $clients && is_array( $clients ) ) { $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( $clients, array( 'select_data' => $data_fields, ) ); foreach ( $websites as $website ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } } $output = new \stdClass(); $output->errors = array(); $output->pages = 0; if ( ! empty( $dbwebsites ) ) { $post_data = array( 'keyword' => $keyword, 'dtsstart' => $dtsstart, 'dtsstop' => $dtsstop, 'status' => $status, 'maxRecords' => ( ( false === get_option( 'mainwp_maximumPages' ) ) ? 50 : get_option( 'mainwp_maximumPages' ) ), 'search_on' => $search_on, ); if ( MainWP_Utility::enabled_wp_seo() ) { $post_data['WPSEOEnabled'] = 1; } /** * Get all pages data * * Set search parameters for the fetch process. * * @since 3.4 */ $post_data = apply_filters( 'mainwp_get_all_pages_data', $post_data ); MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_pages', $post_data, array( static::get_class_name(), 'pages_search_handler' ), $output ); } MainWP_Cache::add_context( 'Page', array( 'count' => $output->pages, 'keyword' => $keyword, 'dtsstart' => $dtsstart, 'dtsstop' => $dtsstop, 'status' => $status, 'sites' => ( ! empty( $sites ) ) ? $sites : '', 'groups' => ( ! empty( $groups ) ) ? $groups : '', 'search_on' => $search_on, ) ); if ( empty( $output->pages ) ) { MainWP_Cache::add_body( 'Page', '' ); } } /** * Method get_status() * * Get page status. If the page status is * 'publish' change it to 'Published'. * * @param mixed $status Page Status. * * @return string Page status. */ private static function get_status( $status ) { if ( 'publish' === $status ) { return 'Published'; } return esc_html( ucfirst( $status ) ); } /** * Method pages_search_handler() * * Pages Search handler. * * @param mixed $data Search data. * @param mixed $website Child Site ID to search on. * @param mixed $output Search output. * * @return void Search box html. * * @uses \MainWP\Dashboard\MainWP_Cache::add_body() * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() * @uses \MainWP\Dashboard\MainWP_Exception * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response() * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() */ public static function pages_search_handler( $data, $website, &$output ) { // phpcs:ignore -- NOSONAR - complex function. if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) { return; } if ( preg_match( '/(.*)<\/mainwp>/', $data, $results ) > 0 ) { $result = $results[1]; $pages = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. if ( is_array( $pages ) && isset( $pages['error'] ) ) { $output->errors[ $website->id ] = esc_html( $pages['error'] ); return; } unset( $results ); foreach ( $pages as $page ) { $raw_dts = ''; if ( isset( $page['dts'] ) ) { $raw_dts = $page['dts']; if ( ! stristr( $page['dts'], '-' ) ) { $page['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $page['dts'] ) ); } } if ( ! isset( $page['title'] ) || ( '' === $page['title'] ) ) { $page['title'] = '(No Title)'; } ob_start(); ?>
url ); ?> pages; } unset( $pages ); } else { $output->errors[ $website->id ] = MainWP_Error_Helper::get_error_message( new MainWP_Exception( 'NOMAINWP', $website->url ) ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } } /** * Method publish() * * Publish page. * * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() */ public static function publish() { MainWP_Recent_Posts::action( 'publish', 'page' ); die( wp_json_encode( array( 'result' => 'Page has been published!' ) ) ); } /** * Method unpublish() * * Unpublish page. * * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() */ public static function unpublish() { MainWP_Recent_Posts::action( 'unpublish', 'page' ); die( wp_json_encode( array( 'result' => 'Page has been unpublished!' ) ) ); } /** * Method trash() * * Trash page. * * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() */ public static function trash() { MainWP_Recent_Posts::action( 'trash', 'page' ); die( wp_json_encode( array( 'result' => 'Page has been moved to trash!' ) ) ); } /** * Method delete() * * Delete page. * * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() */ public static function delete() { MainWP_Recent_Posts::action( 'delete', 'page' ); die( wp_json_encode( array( 'result' => 'Page has been permanently deleted!' ) ) ); } /** * Method restore() * * Restore page. * * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() */ public static function restore() { MainWP_Recent_Posts::action( 'restore', 'page' ); die( wp_json_encode( array( 'result' => 'Page has been restored!' ) ) ); } /** * Method render_bulk_add() * * Check if user has the rights to manage pages, * grab the post id and pass onto render_addedit() method. * * @return void */ public static function render_bulk_add() { if ( ! \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); return; } /** * MainWP default post to edit. * * @global string */ global $_mainwp_default_post_to_edit; $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; static::render_addedit( $post_id, 'BulkAdd' ); } /** * Method render_bulk_edit() * * Check if user has the rights to manage pages, * grab the post id and pass onto render_addedit() method. * * @return void */ public static function render_bulk_edit() { if ( ! \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); return; } $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized static::render_addedit( $post_id, 'BulkEdit' ); } /** * Method render_addedit() * * Render bulk posts page. * * @param mixed $post_id Post ID. * @param mixed $what Current page. * * @return void Display page header, bulkpost body & footer. * * @uses \MainWP\Dashboard\MainWP_Post::render_bulkpost() */ public static function render_addedit( $post_id, $what ) { static::render_header( $what, $post_id ); MainWP_Post::render_bulkpost( $post_id, 'bulkpage' ); static::render_footer( $what ); } /** * Method posting() * * Render Posting page modal window. * * @return void Posting page modal window html. * * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() * @uses \MainWP\Dashboard\MainWP_DB::query() * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() * @uses \MainWP\Dashboard\MainWP_DB::free_result() * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze() * @uses \MainWP\Dashboard\MainWP_Bulk_Add::get_class_name() * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() * @uses \MainWP\Dashboard\MainWP_Utility::map_site() */ public static function posting() { // phpcs:ignore -- NOSONAR - current complexity required to achieve desired results. Pull request solutions appreciated. $succes_message = ''; $post_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( ! isset( $_GET['posting_nonce'] ) || ( isset( $_GET['posting_nonce'] ) && ! wp_verify_nonce( sanitize_key( $_GET['posting_nonce'] ), 'posting_nonce_' . $post_id ) ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated wp_die( 'Invalid request!' ); } $edit_id = 0; if ( $post_id ) { $edit_id = get_post_meta( $post_id, '_mainwp_edit_post_id', true ); $edit_id = intval( $edit_id ); if ( $edit_id ) { $succes_message = esc_html__( 'Page has been updated successfully', 'mainwp' ); } else { $succes_message = esc_html__( 'New page created', 'mainwp' ); } } $data_fields = MainWP_System_Utility::get_default_map_site_fields(); ?>

Your custom text
* * @since 4.1 */ do_action( 'mainwp_pages_help_item' ); ?>