| @@ -6,8 +6,13 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace MainWP\Dashboard; |
| 9 | 9 | |
| 10 | +// Exit if accessed directly. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 10 | 15 | /** |
| 11 | 16 | * Class MainWP_Page |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| @@ -13,1712 +18,1728 @@ | ||
| 13 | 18 | * @package MainWP\Dashboard |
| 14 | 19 | * |
| 15 | 20 | * @uses MainWP_Bulk_Add |
| 16 | 21 | */ |
| 17 | -class MainWP_Page { | |
| 22 | +class MainWP_Page { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 18 | 23 | |
| 19 | - /** | |
| 20 | - * Method get_class_name() | |
| 21 | - * | |
| 22 | - * Get Class Name. | |
| 23 | - * | |
| 24 | - * @return object __CLASS__ | |
| 25 | - */ | |
| 26 | - public static function get_class_name() { | |
| 27 | - return __CLASS__; | |
| 28 | - } | |
| 24 | + /** | |
| 25 | + * Method get_class_name() | |
| 26 | + * | |
| 27 | + * Get Class Name. | |
| 28 | + * | |
| 29 | + * @return object __CLASS__ | |
| 30 | + */ | |
| 31 | + public static function get_class_name() { | |
| 32 | + return __CLASS__; | |
| 33 | + } | |
| 29 | 34 | |
| 30 | - /** | |
| 31 | - * Subpages of Page. | |
| 32 | - * | |
| 33 | - * @var object $subPages | |
| 34 | - */ | |
| 35 | - public static $subPages; | |
| 35 | + /** | |
| 36 | + * Subpages of Page. | |
| 37 | + * | |
| 38 | + * @var object $subPages | |
| 39 | + */ | |
| 40 | + public static $subPages; | |
| 36 | 41 | |
| 37 | - /** | |
| 38 | - * Pages to load. | |
| 39 | - * | |
| 40 | - * @var object $load_page | |
| 41 | - */ | |
| 42 | - public static $load_page; | |
| 42 | + /** | |
| 43 | + * Pages to load. | |
| 44 | + * | |
| 45 | + * @var object $load_page | |
| 46 | + */ | |
| 47 | + public static $load_page; | |
| 43 | 48 | |
| 44 | - /** | |
| 45 | - * Method init() | |
| 46 | - * | |
| 47 | - * Initiate page. | |
| 48 | - * | |
| 49 | - * @return void | |
| 50 | - */ | |
| 51 | - public static function init() { | |
| 52 | - /** | |
| 53 | - * This hook allows you to render the Page page header via the 'mainwp-pageheader-page' action. | |
| 54 | - * | |
| 55 | - * @link http://codex.mainwp.com/#mainwp-pageheader-page | |
| 56 | - * | |
| 57 | - * This hook is normally used in the same context of 'mainwp-getsubpages-page' | |
| 58 | - * @link http://codex.mainwp.com/#mainwp-getsubpages-page | |
| 59 | - * | |
| 60 | - * @see \MainWP_Page::render_header | |
| 61 | - */ | |
| 62 | - add_action( 'mainwp-pageheader-page', array( self::get_class_name(), 'render_header' ) ); // @deprecated Use 'mainwp_pageheader_page' instead. | |
| 63 | - add_action( 'mainwp_pageheader_page', array( self::get_class_name(), 'render_header' ) ); | |
| 49 | + /** | |
| 50 | + * Method init() | |
| 51 | + * | |
| 52 | + * Initiate page. | |
| 53 | + * | |
| 54 | + * @return void | |
| 55 | + */ | |
| 56 | + public static function init() { | |
| 57 | + /** | |
| 58 | + * This hook allows you to render the Page page header via the 'mainwp-pageheader-page' action. | |
| 59 | + * | |
| 60 | + * @link http://codex.mainwp.com/#mainwp-pageheader-page | |
| 61 | + * | |
| 62 | + * This hook is normally used in the same context of 'mainwp-getsubpages-page' | |
| 63 | + * @link http://codex.mainwp.com/#mainwp-getsubpages-page | |
| 64 | + * | |
| 65 | + * @see \MainWP_Page::render_header | |
| 66 | + */ | |
| 67 | + add_action( 'mainwp-pageheader-page', array( static::get_class_name(), 'render_header' ) ); // @deprecated Use 'mainwp_pageheader_page' instead. | |
| 68 | + add_action( 'mainwp_pageheader_page', array( static::get_class_name(), 'render_header' ) ); | |
| 64 | 69 | |
| 65 | - /** | |
| 66 | - * This hook allows you to render the Page page footer via the 'mainwp-pagefooter-page' action. | |
| 67 | - * | |
| 68 | - * @link http://codex.mainwp.com/#mainwp-pagefooter-page | |
| 69 | - * | |
| 70 | - * This hook is normally used in the same context of 'mainwp-getsubpages-page' | |
| 71 | - * @link http://codex.mainwp.com/#mainwp-getsubpages-page | |
| 72 | - * | |
| 73 | - * @see \MainWP_Page::render_footer | |
| 74 | - */ | |
| 75 | - add_action( 'mainwp-pagefooter-page', array( self::get_class_name(), 'render_footer' ) ); | |
| 76 | - add_action( 'mainwp_pagefooter_page', array( self::get_class_name(), 'render_footer' ) ); | |
| 70 | + /** | |
| 71 | + * This hook allows you to render the Page page footer via the 'mainwp-pagefooter-page' action. | |
| 72 | + * | |
| 73 | + * @link http://codex.mainwp.com/#mainwp-pagefooter-page | |
| 74 | + * | |
| 75 | + * This hook is normally used in the same context of 'mainwp-getsubpages-page' | |
| 76 | + * @link http://codex.mainwp.com/#mainwp-getsubpages-page | |
| 77 | + * | |
| 78 | + * @see \MainWP_Page::render_footer | |
| 79 | + */ | |
| 80 | + add_action( 'mainwp-pagefooter-page', array( static::get_class_name(), 'render_footer' ) ); | |
| 81 | + add_action( 'mainwp_pagefooter_page', array( static::get_class_name(), 'render_footer' ) ); | |
| 77 | 82 | |
| 78 | - add_action( 'mainwp_help_sidebar_content', array( self::get_class_name(), 'mainwp_help_content' ) ); // Hook the Help Sidebar content. | |
| 79 | - } | |
| 83 | + add_action( 'mainwp_help_sidebar_content', array( static::get_class_name(), 'mainwp_help_content' ) ); // Hook the Help Sidebar content. | |
| 84 | + } | |
| 80 | 85 | |
| 81 | - /** | |
| 82 | - * Method init_menu() | |
| 83 | - * | |
| 84 | - * Initiate Menu. | |
| 85 | - * | |
| 86 | - * @return void Initiated menus. | |
| 87 | - * | |
| 88 | - * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 89 | - */ | |
| 90 | - public static function init_menu() { | |
| 91 | - $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '<span id="mainwp-Pages">' . esc_html__( 'Pages', 'mainwp' ) . '</span>', 'read', 'PageBulkManage', array( self::get_class_name(), 'render' ) ); | |
| 92 | - add_action( 'load-' . $_page, array( self::get_class_name(), 'on_load_page' ) ); | |
| 93 | - add_filter( 'manage_' . $_page . '_columns', array( self::get_class_name(), 'get_manage_columns' ) ); | |
| 86 | + /** | |
| 87 | + * Method init_menu() | |
| 88 | + * | |
| 89 | + * Initiate Menu. | |
| 90 | + * | |
| 91 | + * @return void Initiated menus. | |
| 92 | + * | |
| 93 | + * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 94 | + */ | |
| 95 | + public static function init_menu() { | |
| 96 | + $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '<span id="mainwp-Pages">' . esc_html__( 'Pages', 'mainwp' ) . '</span>', 'manage_options', 'PageBulkManage', array( static::get_class_name(), 'render' ) ); | |
| 97 | + add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_page' ) ); | |
| 98 | + add_filter( 'manage_' . $_page . '_columns', array( static::get_class_name(), 'get_manage_columns' ) ); | |
| 94 | 99 | |
| 95 | - $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Add New', 'mainwp' ) . '</div>', 'read', 'PageBulkAdd', array( self::get_class_name(), 'render_bulk_add' ) ); | |
| 96 | - add_action( 'load-' . $_page, array( self::get_class_name(), 'on_load_add_edit' ) ); | |
| 100 | + if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PageBulkAdd' ) ) { | |
| 101 | + $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Add New', 'mainwp' ) . '</div>', 'manage_options', 'PageBulkAdd', array( static::get_class_name(), 'render_bulk_add' ) ); | |
| 102 | + add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_add_edit' ) ); | |
| 103 | + } | |
| 97 | 104 | |
| 98 | - $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Edit Page', 'mainwp' ) . '</div>', 'read', 'PageBulkEdit', array( self::get_class_name(), 'render_bulk_edit' ) ); | |
| 99 | - add_action( 'load-' . $_page, array( self::get_class_name(), 'on_load_add_edit' ) ); | |
| 105 | + if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PageBulkEdit' ) ) { | |
| 106 | + $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Pages', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Edit Page', 'mainwp' ) . '</div>', 'manage_options', 'PageBulkEdit', array( static::get_class_name(), 'render_bulk_edit' ) ); | |
| 107 | + add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_add_edit' ) ); | |
| 108 | + } | |
| 100 | 109 | |
| 101 | - add_submenu_page( 'mainwp_tab', esc_html__( 'Posting new bulkpage', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Add New Page', 'mainwp' ) . '</div>', 'read', 'PostingBulkPage', array( self::get_class_name(), 'posting' ) ); // removed from menu afterwards. | |
| 110 | + add_submenu_page( 'mainwp_tab', esc_html__( 'Posting new bulkpage', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Add New Page', 'mainwp' ) . '</div>', 'manage_options', 'PostingBulkPage', array( static::get_class_name(), 'posting' ), ); // removed from menu afterwards. | |
| 102 | 111 | |
| 103 | - /** | |
| 104 | - * Pages Subpages | |
| 105 | - * | |
| 106 | - * Filters subpages for the Pages page. | |
| 107 | - * | |
| 108 | - * @since Unknown | |
| 109 | - */ | |
| 110 | - $sub_pages = array(); | |
| 111 | - $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-page', array( $sub_pages ), '4.0.7.2', 'mainwp_getsubpages_page' ); // @deprecated Use 'mainwp_getsubpages_page' instead. | |
| 112 | - self::$subPages = apply_filters( 'mainwp_getsubpages_page', $sub_pages ); | |
| 112 | + /** | |
| 113 | + * Pages Subpages | |
| 114 | + * | |
| 115 | + * Filters subpages for the Pages page. | |
| 116 | + * | |
| 117 | + * @since Unknown | |
| 118 | + */ | |
| 119 | + $sub_pages = array(); | |
| 120 | + $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. | |
| 121 | + static::$subPages = apply_filters( 'mainwp_getsubpages_page', $sub_pages ); | |
| 113 | 122 | |
| 114 | - if ( isset( self::$subPages ) && is_array( self::$subPages ) ) { | |
| 115 | - foreach ( self::$subPages as $subPage ) { | |
| 116 | - if ( isset( $subPage['no_page'] ) && $subPage['no_page'] ) { | |
| 117 | - continue; | |
| 118 | - } | |
| 119 | - if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { | |
| 120 | - continue; | |
| 121 | - } | |
| 122 | - add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Page' . $subPage['slug'], $subPage['callback'] ); | |
| 123 | - } | |
| 124 | - } | |
| 125 | - self::init_left_menu( self::$subPages ); | |
| 126 | - } | |
| 123 | + if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { | |
| 124 | + foreach ( static::$subPages as $subPage ) { | |
| 125 | + if ( isset( $subPage['no_page'] ) && $subPage['no_page'] ) { | |
| 126 | + continue; | |
| 127 | + } | |
| 128 | + if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { | |
| 129 | + continue; | |
| 130 | + } | |
| 131 | + add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'manage_options', 'Page' . $subPage['slug'], $subPage['callback'] ); | |
| 132 | + } | |
| 133 | + } | |
| 134 | + static::init_left_menu( static::$subPages ); | |
| 135 | + } | |
| 127 | 136 | |
| 128 | - /** | |
| 129 | - * Method on_load_add_edit() | |
| 130 | - * | |
| 131 | - * Add edit on load bulk posts. | |
| 132 | - * | |
| 133 | - * @return void Returns post to edit. | |
| 134 | - * | |
| 135 | - * @uses \MainWP\Dashboard\MainWP_Post::on_load_bulkpost() | |
| 136 | - */ | |
| 137 | - public static function on_load_add_edit() { | |
| 137 | + /** | |
| 138 | + * Method on_load_add_edit() | |
| 139 | + * | |
| 140 | + * Add edit on load bulk posts. | |
| 141 | + * | |
| 142 | + * @return void Returns post to edit. | |
| 143 | + * | |
| 144 | + * @uses \MainWP\Dashboard\MainWP_Post::on_load_bulkpost() | |
| 145 | + */ | |
| 146 | + public static function on_load_add_edit() { | |
| 147 | + if ( isset( $_GET['page'] ) && 'PageBulkAdd' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 138 | 148 | |
| 139 | - global $_mainwp_menu_active_slugs; | |
| 149 | + /** | |
| 150 | + * MainWP default post to edit. | |
| 151 | + * | |
| 152 | + * @global string | |
| 153 | + */ | |
| 154 | + global $_mainwp_default_post_to_edit; | |
| 140 | 155 | |
| 141 | - if ( isset( $_GET['page'] ) && 'PageBulkAdd' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 156 | + $post_type = 'bulkpage'; | |
| 157 | + $_mainwp_default_post_to_edit = get_default_post_to_edit( $post_type, true ); | |
| 158 | + $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; | |
| 159 | + } else { | |
| 160 | + $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 161 | + } | |
| 142 | 162 | |
| 143 | - /** | |
| 144 | - * MainWP default post to edit. | |
| 145 | - * | |
| 146 | - * @global string | |
| 147 | - */ | |
| 148 | - global $_mainwp_default_post_to_edit; | |
| 163 | + if ( ! $post_id ) { | |
| 164 | + wp_die( esc_html__( 'Invalid post.', 'mainwp' ) ); | |
| 165 | + } | |
| 149 | 166 | |
| 150 | - $post_type = 'bulkpage'; | |
| 151 | - $_mainwp_default_post_to_edit = get_default_post_to_edit( $post_type, true ); | |
| 152 | - $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; | |
| 153 | - } else { | |
| 154 | - $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 155 | - $_mainwp_menu_active_slugs['PageBulkEdit'] = 'PageBulkManage'; // to fix hidden second menu level. | |
| 156 | - } | |
| 167 | + MainWP_Post::on_load_bulkpost( $post_id ); | |
| 168 | + } | |
| 157 | 169 | |
| 158 | - if ( ! $post_id ) { | |
| 159 | - wp_die( esc_html__( 'Invalid post.' ) ); | |
| 160 | - } | |
| 170 | + /** | |
| 171 | + * Method init_left_menu() | |
| 172 | + * | |
| 173 | + * Initiate left menu. | |
| 174 | + * | |
| 175 | + * @param array $subPages Left menu sub pages. | |
| 176 | + * | |
| 177 | + * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu() | |
| 178 | + * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu() | |
| 179 | + * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 180 | + */ | |
| 181 | + public static function init_left_menu( $subPages = array() ) { | |
| 182 | + $init_sub_subleftmenu = array( | |
| 183 | + array( | |
| 184 | + 'title' => esc_html__( 'Manage Pages', 'mainwp' ), | |
| 185 | + 'parent_key' => 'Extensions-Mainwp-Content-Operations', | |
| 186 | + 'href' => 'admin.php?page=PageBulkManage', | |
| 187 | + 'slug' => 'PageBulkManage', | |
| 188 | + 'right' => 'manage_pages', | |
| 189 | + 'leftsub_order_level2' => 2, | |
| 190 | + 'active_path' => array( | |
| 191 | + 'PageBulkEdit' => 'PageBulkManage', | |
| 192 | + 'PageBulkAdd' => 'PageBulkManage', | |
| 193 | + ), | |
| 194 | + ), | |
| 195 | + array( | |
| 196 | + 'title' => esc_html__( 'Add New', 'mainwp' ), | |
| 197 | + 'parent_key' => 'Extensions-Mainwp-Content-Operations', | |
| 198 | + 'href' => 'admin.php?page=PageBulkAdd', | |
| 199 | + 'slug' => 'PageBulkAdd', | |
| 200 | + 'right' => 'manage_pages', | |
| 201 | + 'leftsub_order_level2' => 2, | |
| 202 | + ), | |
| 203 | + array( | |
| 204 | + 'title' => esc_html__( 'Edit Page', 'mainwp' ), | |
| 205 | + 'parent_key' => 'Extensions-Mainwp-Content-Operations', | |
| 206 | + 'href' => 'admin.php?page=PageBulkEdit', | |
| 207 | + 'slug' => 'PageBulkEdit', | |
| 208 | + 'right' => 'manage_pages', | |
| 209 | + 'leftsub_order_level2' => 2, | |
| 210 | + ), | |
| 211 | + ); | |
| 212 | + MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'PageBulkManage', 'Page' ); | |
| 161 | 213 | |
| 162 | - MainWP_Post::on_load_bulkpost( $post_id ); | |
| 163 | - } | |
| 214 | + foreach ( $init_sub_subleftmenu as $item ) { | |
| 215 | + if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { | |
| 216 | + continue; | |
| 217 | + } | |
| 218 | + $level = ( 'PageBulkManage' === $item['slug'] ) ? 2 : 3; | |
| 219 | + MainWP_Menu::add_left_menu( $item, $level ); | |
| 220 | + } | |
| 221 | + } | |
| 164 | 222 | |
| 165 | - /** | |
| 166 | - * Method init_subpages_menu() | |
| 167 | - * | |
| 168 | - * Initiate subpages menu. | |
| 169 | - * | |
| 170 | - * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 171 | - */ | |
| 172 | - public static function init_subpages_menu() { | |
| 173 | - ?> | |
| 174 | - <div id="menu-mainwp-Pages" class="mainwp-submenu-wrapper"> | |
| 175 | - <div class="wp-submenu sub-open" style=""> | |
| 176 | - <div class="mainwp_boxout"> | |
| 177 | - <div class="mainwp_boxoutin"></div> | |
| 178 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) { ?> | |
| 179 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkManage' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Manage Pages', 'mainwp' ); ?></a> | |
| 180 | - <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PageBulkAdd' ) ) { ?> | |
| 181 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Add New', 'mainwp' ); ?></a> | |
| 182 | - <?php } ?> | |
| 183 | - <?php } ?> | |
| 184 | - <?php | |
| 185 | - if ( isset( self::$subPages ) && is_array( self::$subPages ) ) { | |
| 186 | - foreach ( self::$subPages as $subPage ) { | |
| 187 | - if ( ! isset( $subPage['menu_hidden'] ) || ( isset( $subPage['menu_hidden'] ) && true !== $subPage['menu_hidden'] ) ) { | |
| 188 | - if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { | |
| 189 | - continue; | |
| 190 | - } | |
| 191 | - ?> | |
| 192 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=Page' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $subPage['title'] ); ?></a> | |
| 193 | - <?php | |
| 194 | - } | |
| 195 | - } | |
| 196 | - } | |
| 197 | - ?> | |
| 198 | - </div> | |
| 199 | - </div> | |
| 200 | - </div> | |
| 201 | - <?php | |
| 202 | - } | |
| 223 | + /** | |
| 224 | + * Method on_load_page() | |
| 225 | + * | |
| 226 | + * On page load. | |
| 227 | + */ | |
| 228 | + public static function on_load_page() { | |
| 229 | + add_action( 'admin_head', array( static::get_class_name(), 'admin_head' ) ); | |
| 230 | + add_filter( 'hidden_columns', array( static::get_class_name(), 'get_hidden_columns' ), 10, 3 ); | |
| 231 | + add_action( 'mainwp_screen_options_modal_bottom', array( static::get_class_name(), 'hook_screen_options_modal_bottom' ), 10, 2 ); | |
| 232 | + } | |
| 203 | 233 | |
| 204 | - /** | |
| 205 | - * Method init_left_menu() | |
| 206 | - * | |
| 207 | - * Initiate left menu. | |
| 208 | - * | |
| 209 | - * @param array $subPages Left menu sub pages. | |
| 210 | - * | |
| 211 | - * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu() | |
| 212 | - * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu() | |
| 213 | - * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 214 | - */ | |
| 215 | - public static function init_left_menu( $subPages = array() ) { | |
| 234 | + /** | |
| 235 | + * Method get_manage_columns() | |
| 236 | + * | |
| 237 | + * Get columns to display. | |
| 238 | + * | |
| 239 | + * @return array $colums Columns to display. | |
| 240 | + * | |
| 241 | + * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 242 | + */ | |
| 243 | + public static function get_manage_columns() { | |
| 244 | + $colums = array( | |
| 245 | + 'title' => 'Title', | |
| 246 | + 'author' => 'Author', | |
| 247 | + 'comments' => 'Comments', | |
| 248 | + 'date' => 'Date', | |
| 249 | + 'status' => 'Status', | |
| 250 | + 'seo-links' => 'Links', | |
| 251 | + 'seo-linked' => 'Linked', | |
| 252 | + 'seo-score' => 'SEO Score', | |
| 253 | + 'seo-readability' => 'Readability score', | |
| 254 | + 'website' => 'Website', | |
| 255 | + ); | |
| 216 | 256 | |
| 217 | - MainWP_Menu::add_left_menu( | |
| 218 | - array( | |
| 219 | - 'title' => esc_html__( 'Pages', 'mainwp' ), | |
| 220 | - 'parent_key' => 'managesites', | |
| 221 | - 'slug' => 'PageBulkManage', | |
| 222 | - 'href' => 'admin.php?page=PageBulkManage', | |
| 223 | - 'icon' => '<i class="file icon"></i>', | |
| 224 | - 'leftsub_order' => 8, | |
| 225 | - ), | |
| 226 | - 1 | |
| 227 | - ); | |
| 228 | - $init_sub_subleftmenu = array( | |
| 229 | - array( | |
| 230 | - 'title' => esc_html__( 'Manage Pages', 'mainwp' ), | |
| 231 | - 'parent_key' => 'PageBulkManage', | |
| 232 | - 'href' => 'admin.php?page=PageBulkManage', | |
| 233 | - 'slug' => 'PageBulkManage', | |
| 234 | - 'right' => 'manage_pages', | |
| 235 | - 'leftsub_order_level2' => 1, | |
| 236 | - ), | |
| 237 | - array( | |
| 238 | - 'title' => esc_html__( 'Add New', 'mainwp' ), | |
| 239 | - 'parent_key' => 'PageBulkManage', | |
| 240 | - 'href' => 'admin.php?page=PageBulkAdd', | |
| 241 | - 'slug' => 'PageBulkAdd', | |
| 242 | - 'right' => 'manage_pages', | |
| 243 | - 'leftsub_order_level2' => 2, | |
| 244 | - ), | |
| 245 | - ); | |
| 246 | - MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'PageBulkManage', 'Page' ); | |
| 257 | + if ( ! MainWP_Utility::enabled_wp_seo() ) { | |
| 258 | + unset( $colums['seo-links'] ); | |
| 259 | + unset( $colums['seo-linked'] ); | |
| 260 | + unset( $colums['seo-score'] ); | |
| 261 | + unset( $colums['seo-readability'] ); | |
| 262 | + } | |
| 263 | + return $colums; | |
| 264 | + } | |
| 247 | 265 | |
| 248 | - foreach ( $init_sub_subleftmenu as $item ) { | |
| 249 | - if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { | |
| 250 | - continue; | |
| 251 | - } | |
| 252 | - MainWP_Menu::add_left_menu( $item, 2 ); | |
| 253 | - } | |
| 254 | - } | |
| 266 | + /** | |
| 267 | + * Method admin_head() | |
| 268 | + * | |
| 269 | + * Add current screen ID to html header. | |
| 270 | + */ | |
| 271 | + public static function admin_head() { | |
| 255 | 272 | |
| 256 | - /** | |
| 257 | - * Method on_load_page() | |
| 258 | - * | |
| 259 | - * On page load. | |
| 260 | - */ | |
| 261 | - public static function on_load_page() { | |
| 262 | - add_action( 'admin_head', array( self::get_class_name(), 'admin_head' ) ); | |
| 263 | - add_filter( 'hidden_columns', array( self::get_class_name(), 'get_hidden_columns' ), 10, 3 ); | |
| 264 | - add_action( 'mainwp_screen_options_modal_bottom', array( self::get_class_name(), 'hook_screen_options_modal_bottom' ), 10, 2 ); | |
| 265 | - } | |
| 273 | + /** | |
| 274 | + * Current screen. | |
| 275 | + * | |
| 276 | + * @global string | |
| 277 | + */ | |
| 278 | + global $current_screen; | |
| 266 | 279 | |
| 267 | - /** | |
| 268 | - * Method get_manage_columns() | |
| 269 | - * | |
| 270 | - * Get columns to display. | |
| 271 | - * | |
| 272 | - * @return array $colums Columns to display. | |
| 273 | - * | |
| 274 | - * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 275 | - */ | |
| 276 | - public static function get_manage_columns() { | |
| 277 | - $colums = array( | |
| 278 | - 'title' => 'Title', | |
| 279 | - 'author' => 'Author', | |
| 280 | - 'comments' => 'Comments', | |
| 281 | - 'date' => 'Date', | |
| 282 | - 'status' => 'Status', | |
| 283 | - 'seo-links' => 'Links', | |
| 284 | - 'seo-linked' => 'Linked', | |
| 285 | - 'seo-score' => 'SEO Score', | |
| 286 | - 'seo-readability' => 'Readability score', | |
| 287 | - 'website' => 'Website', | |
| 288 | - ); | |
| 280 | + ?> | |
| 281 | + <script type="text/javascript"> pagenow = '<?php echo esc_js( strtolower( $current_screen->id ) ); ?>';</script> | |
| 282 | + <?php | |
| 283 | + } | |
| 289 | 284 | |
| 290 | - if ( ! MainWP_Utility::enabled_wp_seo() ) { | |
| 291 | - unset( $colums['seo-links'] ); | |
| 292 | - unset( $colums['seo-linked'] ); | |
| 293 | - unset( $colums['seo-score'] ); | |
| 294 | - unset( $colums['seo-readability'] ); | |
| 295 | - } | |
| 296 | - return $colums; | |
| 297 | - } | |
| 285 | + /** | |
| 286 | + * Method get_hidden_columns() | |
| 287 | + * | |
| 288 | + * Get hidden columns. | |
| 289 | + * | |
| 290 | + * @param mixed $hidden Columns that are hidden. | |
| 291 | + * @param mixed $screen Current page. | |
| 292 | + * | |
| 293 | + * @return string $hidden Hidden columns. | |
| 294 | + */ | |
| 295 | + public static function get_hidden_columns( $hidden, $screen ) { | |
| 296 | + if ( $screen && 'mainwp_page_PageBulkManage' === $screen->id ) { | |
| 297 | + $hidden = get_user_option( 'manage' . strtolower( $screen->id ) . 'columnshidden' ); | |
| 298 | + } | |
| 299 | + if ( ! is_array( $hidden ) ) { | |
| 300 | + $hidden = array(); | |
| 301 | + } | |
| 302 | + return $hidden; | |
| 303 | + } | |
| 298 | 304 | |
| 299 | - /** | |
| 300 | - * Method admin_head() | |
| 301 | - * | |
| 302 | - * Add current screen ID to html header. | |
| 303 | - */ | |
| 304 | - public static function admin_head() { | |
| 305 | + /** | |
| 306 | + * Method hook_screen_options_modal_bottom() | |
| 307 | + * | |
| 308 | + * Render screen options modal bottom. | |
| 309 | + */ | |
| 310 | + public static function hook_screen_options_modal_bottom() { | |
| 311 | + $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 312 | + if ( 'PageBulkManage' === $page ) { | |
| 305 | 313 | |
| 306 | - /** | |
| 307 | - * Current screen. | |
| 308 | - * | |
| 309 | - * @global string | |
| 310 | - */ | |
| 311 | - global $current_screen; | |
| 314 | + $show_columns = get_user_option( 'mainwp_managepages_show_columns' ); | |
| 312 | 315 | |
| 313 | - ?> | |
| 314 | - <script type="text/javascript"> pagenow = '<?php echo esc_js( strtolower( $current_screen->id ) ); ?>';</script> | |
| 315 | - <?php | |
| 316 | - } | |
| 316 | + if ( ! is_array( $show_columns ) ) { | |
| 317 | + $show_columns = array(); | |
| 318 | + } | |
| 317 | 319 | |
| 318 | - /** | |
| 319 | - * Method get_hidden_columns() | |
| 320 | - * | |
| 321 | - * Get hidden columns. | |
| 322 | - * | |
| 323 | - * @param mixed $hidden Columns that are hidden. | |
| 324 | - * @param mixed $screen Current page. | |
| 325 | - * | |
| 326 | - * @return string $hidden Hidden columns. | |
| 327 | - */ | |
| 328 | - public static function get_hidden_columns( $hidden, $screen ) { | |
| 329 | - if ( $screen && 'mainwp_page_PageBulkManage' === $screen->id ) { | |
| 330 | - $hidden = get_user_option( 'manage' . strtolower( $screen->id ) . 'columnshidden' ); | |
| 331 | - } | |
| 332 | - if ( ! is_array( $hidden ) ) { | |
| 333 | - $hidden = array(); | |
| 334 | - } | |
| 335 | - return $hidden; | |
| 336 | - } | |
| 320 | + $cols = static::get_manage_columns(); | |
| 337 | 321 | |
| 338 | - /** | |
| 339 | - * Method hook_screen_options_modal_bottom() | |
| 340 | - * | |
| 341 | - * Render screen options modal bottom. | |
| 342 | - */ | |
| 343 | - public static function hook_screen_options_modal_bottom() { | |
| 344 | - $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 345 | - if ( 'PageBulkManage' === $page ) { | |
| 322 | + MainWP_UI::render_showhide_columns_settings( $cols, $show_columns, 'page' ); | |
| 323 | + } | |
| 324 | + } | |
| 346 | 325 | |
| 347 | - $show_columns = get_user_option( 'mainwp_managepages_show_columns' ); | |
| 326 | + /** | |
| 327 | + * Method render_header() | |
| 328 | + * | |
| 329 | + * Render page header. | |
| 330 | + * | |
| 331 | + * @param string $shownPage Current page. | |
| 332 | + * @param int $post_id Post ID. | |
| 333 | + * | |
| 334 | + * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 335 | + * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() | |
| 336 | + * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation() | |
| 337 | + */ | |
| 338 | + public static function render_header( $shownPage = '', $post_id = null ) { // phpcs:ignore -- NOSONAR - complex. | |
| 348 | 339 | |
| 349 | - if ( ! is_array( $show_columns ) ) { | |
| 350 | - $show_columns = array(); | |
| 351 | - } | |
| 340 | + $params = array( | |
| 341 | + 'title' => esc_html__( 'Pages', 'mainwp' ), | |
| 342 | + ); | |
| 343 | + MainWP_UI::render_top_header( $params ); | |
| 352 | 344 | |
| 353 | - $cols = self::get_manage_columns(); | |
| 345 | + $renderItems = array(); | |
| 354 | 346 | |
| 355 | - MainWP_UI::render_showhide_columns_settings( $cols, $show_columns, 'page' ); | |
| 356 | - } | |
| 357 | - } | |
| 347 | + if ( \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { | |
| 348 | + $renderItems[] = array( | |
| 349 | + 'title' => esc_html__( 'Manage Pages', 'mainwp' ), | |
| 350 | + 'href' => 'admin.php?page=PageBulkManage', | |
| 351 | + 'active' => ( 'BulkManage' === $shownPage ) ? true : false, | |
| 352 | + ); | |
| 353 | + if ( 'BulkEdit' === $shownPage ) { | |
| 354 | + $renderItems[] = array( | |
| 355 | + 'title' => esc_html__( 'Edit Page', 'mainwp' ), | |
| 356 | + 'href' => 'admin.php?page=PageBulkEdit&post_id=' . esc_attr( $post_id ), | |
| 357 | + 'active' => true, | |
| 358 | + ); | |
| 359 | + } | |
| 358 | 360 | |
| 359 | - /** | |
| 360 | - * Method render_header() | |
| 361 | - * | |
| 362 | - * Render page header. | |
| 363 | - * | |
| 364 | - * @param string $shownPage Current page. | |
| 365 | - * @param int $post_id Post ID. | |
| 366 | - * | |
| 367 | - * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 368 | - * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() | |
| 369 | - * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation() | |
| 370 | - */ | |
| 371 | - public static function render_header( $shownPage = '', $post_id = null ) { | |
| 361 | + if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PageBulkAdd' ) ) { | |
| 362 | + $renderItems[] = array( | |
| 363 | + 'title' => esc_html__( 'Add New', 'mainwp' ), | |
| 364 | + 'href' => 'admin.php?page=PageBulkAdd', | |
| 365 | + 'active' => ( 'BulkAdd' === $shownPage ) ? true : false, | |
| 366 | + ); | |
| 367 | + } | |
| 368 | + } | |
| 372 | 369 | |
| 373 | - $params = array( | |
| 374 | - 'title' => esc_html__( 'Pages', 'mainwp' ), | |
| 375 | - ); | |
| 376 | - MainWP_UI::render_top_header( $params ); | |
| 370 | + if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { | |
| 371 | + foreach ( static::$subPages as $subPage ) { | |
| 372 | + if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { | |
| 373 | + continue; | |
| 374 | + } | |
| 377 | 375 | |
| 378 | - $renderItems = array(); | |
| 376 | + if ( isset( $subPage['tab_link_hidden'] ) && true === $subPage['tab_link_hidden'] ) { | |
| 377 | + $tab_link = '#'; | |
| 378 | + } else { | |
| 379 | + $tab_link = 'admin.php?page=Page' . $subPage['slug']; | |
| 380 | + } | |
| 381 | + $item = array(); | |
| 382 | + $item['title'] = $subPage['title']; | |
| 383 | + $item['href'] = $tab_link; | |
| 384 | + $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false; | |
| 385 | + $renderItems[] = $item; | |
| 386 | + } | |
| 387 | + } | |
| 379 | 388 | |
| 380 | - if ( mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) { | |
| 381 | - $renderItems[] = array( | |
| 382 | - 'title' => esc_html__( 'Manage Pages', 'mainwp' ), | |
| 383 | - 'href' => 'admin.php?page=PageBulkManage', | |
| 384 | - 'active' => ( 'BulkManage' === $shownPage ) ? true : false, | |
| 385 | - ); | |
| 386 | - if ( 'BulkEdit' === $shownPage ) { | |
| 387 | - $renderItems[] = array( | |
| 388 | - 'title' => esc_html__( 'Edit Page', 'mainwp' ), | |
| 389 | - 'href' => 'admin.php?page=PageBulkEdit&post_id=' . esc_attr( $post_id ), | |
| 390 | - 'active' => true, | |
| 391 | - ); | |
| 392 | - } | |
| 389 | + MainWP_UI::render_page_navigation( $renderItems, __CLASS__ ); | |
| 390 | + } | |
| 393 | 391 | |
| 394 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PageBulkAdd' ) ) { | |
| 395 | - $renderItems[] = array( | |
| 396 | - 'title' => esc_html__( 'Add New', 'mainwp' ), | |
| 397 | - 'href' => 'admin.php?page=PageBulkAdd', | |
| 398 | - 'active' => ( 'BulkAdd' === $shownPage ) ? true : false, | |
| 399 | - ); | |
| 400 | - } | |
| 401 | - } | |
| 392 | + /** | |
| 393 | + * Method render_footer() | |
| 394 | + * | |
| 395 | + * Render page footer. | |
| 396 | + */ | |
| 397 | + public static function render_footer() { | |
| 398 | + echo '</div>'; | |
| 399 | + } | |
| 402 | 400 | |
| 403 | - if ( isset( self::$subPages ) && is_array( self::$subPages ) ) { | |
| 404 | - foreach ( self::$subPages as $subPage ) { | |
| 405 | - if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) { | |
| 406 | - continue; | |
| 407 | - } | |
| 401 | + /** | |
| 402 | + * Renders Bulk Page Manager. | |
| 403 | + * | |
| 404 | + * @return void | |
| 405 | + * | |
| 406 | + * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() | |
| 407 | + */ | |
| 408 | + public static function render() { | |
| 409 | + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { | |
| 410 | + \mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); | |
| 411 | + return; | |
| 412 | + } | |
| 408 | 413 | |
| 409 | - if ( isset( $subPage['tab_link_hidden'] ) && true === $subPage['tab_link_hidden'] ) { | |
| 410 | - $tab_link = '#'; | |
| 411 | - } else { | |
| 412 | - $tab_link = 'admin.php?page=Page' . $subPage['slug']; | |
| 413 | - } | |
| 414 | - $item = array(); | |
| 415 | - $item['title'] = $subPage['title']; | |
| 416 | - $item['href'] = $tab_link; | |
| 417 | - $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false; | |
| 418 | - $renderItems[] = $item; | |
| 419 | - } | |
| 420 | - } | |
| 414 | + $cachedSearch = MainWP_Cache::get_cached_context( 'Page' ); | |
| 421 | 415 | |
| 422 | - MainWP_UI::render_page_navigation( $renderItems, __CLASS__ ); | |
| 423 | - } | |
| 416 | + $selected_sites = array(); | |
| 417 | + $selected_groups = array(); | |
| 418 | + $selected_clients = array(); | |
| 424 | 419 | |
| 425 | - /** | |
| 426 | - * Method render_footer() | |
| 427 | - * | |
| 428 | - * Render page footer. | |
| 429 | - */ | |
| 430 | - public static function render_footer() { | |
| 431 | - echo '</div>'; | |
| 432 | - } | |
| 420 | + if ( null !== $cachedSearch ) { | |
| 421 | + if ( isset( $cachedSearch['sites'] ) && is_array( $cachedSearch['sites'] ) ) { | |
| 422 | + $selected_sites = $cachedSearch['sites']; | |
| 423 | + } elseif ( isset( $cachedSearch['groups'] ) && is_array( $cachedSearch['groups'] ) ) { | |
| 424 | + $selected_groups = $cachedSearch['groups']; | |
| 425 | + } elseif ( isset( $cachedSearch['clients'] ) && is_array( $cachedSearch['clients'] ) ) { | |
| 426 | + $selected_clients = $cachedSearch['clients']; | |
| 427 | + } | |
| 428 | + } | |
| 433 | 429 | |
| 434 | - /** | |
| 435 | - * Renders Bulk Page Manager. | |
| 436 | - * | |
| 437 | - * @return void | |
| 438 | - * | |
| 439 | - * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() | |
| 440 | - */ | |
| 441 | - public static function render() { | |
| 442 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) { | |
| 443 | - mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); | |
| 444 | - return; | |
| 445 | - } | |
| 430 | + ?> | |
| 431 | + <?php static::render_header( 'BulkManage' ); ?> | |
| 446 | 432 | |
| 447 | - $cachedSearch = MainWP_Cache::get_cached_context( 'Page' ); | |
| 433 | + <div id="mainwp-manage-pages" class="ui alt segment"> | |
| 434 | + <div class="mainwp-main-content"> | |
| 435 | + <div class="mainwp-actions-bar ui mini form"> | |
| 436 | + <div class="ui grid"> | |
| 437 | + <div class="ui two column row"> | |
| 438 | + <div class="column"> | |
| 439 | + <select class="ui dropdown" id="mainwp-bulk-actions"> | |
| 440 | + <option value="none"><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option> | |
| 441 | + <?php do_action( 'mainwp_manage_pages_bulk_action' ); ?> | |
| 442 | + <option value="trash"><?php esc_html_e( 'Move to trash', 'mainwp' ); ?></option> | |
| 443 | + <option value="restore"><?php esc_html_e( 'Restore', 'mainwp' ); ?></option> | |
| 444 | + <option value="delete"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></option> | |
| 445 | + <?php | |
| 446 | + /** | |
| 447 | + * Action: mainwp_pages_bulk_action | |
| 448 | + * | |
| 449 | + * Adds new action to the Bulk Actions menu on Manage Pages. | |
| 450 | + * | |
| 451 | + * Suggested HTML Markup: | |
| 452 | + * <option value="Your custom value">Your custom text</option> | |
| 453 | + * | |
| 454 | + * @since 4.1 | |
| 455 | + */ | |
| 456 | + do_action( 'mainwp_pages_bulk_action' ); | |
| 457 | + ?> | |
| 458 | + </select> | |
| 459 | + <button class="ui mini button" id="mainwp-do-pages-bulk-actions"><?php esc_html_e( 'Apply', 'mainwp' ); ?></button> | |
| 460 | + <?php | |
| 461 | + /** | |
| 462 | + * Action: mainwp_pages_actions_bar_left | |
| 463 | + * | |
| 464 | + * Fires at the left side of the actions bar on the Pages screen, after the Bulk Actions menu. | |
| 465 | + * | |
| 466 | + * @since 4.0 | |
| 467 | + */ | |
| 468 | + do_action( 'mainwp_pages_actions_bar_left' ); | |
| 469 | + ?> | |
| 470 | + </div> | |
| 471 | + <div class="right aligned column"> | |
| 472 | + <?php | |
| 473 | + /** | |
| 474 | + * Action: mainwp_pages_actions_bar_right | |
| 475 | + * | |
| 476 | + * Fires at the right side of the actions bar on the Pages screen. | |
| 477 | + * | |
| 478 | + * @since 4.0 | |
| 479 | + */ | |
| 480 | + do_action( 'mainwp_pages_actions_bar_right' ); | |
| 481 | + ?> | |
| 482 | + <a href="admin.php?page=PageBulkAdd" class="ui mini green button"><?php esc_html_e( 'Create New Page', 'mainwp' ); ?></a> | |
| 483 | + <?php if ( MainWP_Extensions_Handler::is_extension_available( 'boilerplate-extension' ) ) : ?> | |
| 484 | + <a href="admin.php?page=PageBulkAdd&boilerplate=1" class="ui mini green basic button"><?php esc_html_e( 'Create New Boilerplate', 'mainwp' ); ?></a> | |
| 485 | + <?php endif; ?> | |
| 486 | + </div> | |
| 487 | + </div> | |
| 488 | + </div> | |
| 489 | + </div> | |
| 490 | + <div class="ui padded segment" id="mainwp_pages_wrap_table"> | |
| 491 | + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-pages-info-message' ) ) : ?> | |
| 492 | + <div class="ui info message"> | |
| 493 | + <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-pages-info-message"></i> | |
| 494 | + <?php /* translators: 1: opening anchor tag, 2: closing anchor tag */ printf( esc_html__( 'Monitor and manage the lifecycle of content across all connected sites. Perform safe, bulk operations without editing layouts or page design. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/content/manage-pages" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?> | |
| 495 | + </div> | |
| 496 | + <?php endif; ?> | |
| 497 | + <?php static::render_table( true ); ?> | |
| 498 | + </div> | |
| 499 | + </div> | |
| 500 | + <div class="mainwp-side-content mainwp-no-padding"> | |
| 501 | + <?php | |
| 502 | + /** | |
| 503 | + * Action: mainwp_manage_pages_sidebar_top | |
| 504 | + * | |
| 505 | + * Fires at the top of the sidebar on Manage pages. | |
| 506 | + * | |
| 507 | + * @since 4.1 | |
| 508 | + */ | |
| 509 | + do_action( 'mainwp_manage_pages_sidebar_top' ); | |
| 510 | + ?> | |
| 511 | + <div class="mainwp-select-sites ui accordion mainwp-sidebar-accordion"> | |
| 512 | + <?php | |
| 513 | + /** | |
| 514 | + * Action: mainwp_manage_pages_before_select_sites | |
| 515 | + * | |
| 516 | + * Fires before the Select Sites section on Manage pages. | |
| 517 | + * | |
| 518 | + * @since 4.1 | |
| 519 | + */ | |
| 520 | + do_action( 'mainwp_manage_pages_before_select_sites' ); | |
| 521 | + ?> | |
| 522 | + <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Sites', 'mainwp' ); ?></div> | |
| 523 | + <div class="content active"> | |
| 524 | + <?php | |
| 525 | + $sel_params = array( | |
| 526 | + 'selected_sites' => $selected_sites, | |
| 527 | + 'selected_groups' => $selected_groups, | |
| 528 | + 'selected_clients' => $selected_clients, | |
| 529 | + 'class' => 'mainwp_select_sites_box_left', | |
| 530 | + 'show_client' => true, | |
| 531 | + ); | |
| 532 | + MainWP_UI_Select_Sites::select_sites_box( $sel_params ); | |
| 533 | + ?> | |
| 534 | + </div> | |
| 535 | + <?php | |
| 536 | + /** | |
| 537 | + * Action: mainwp_manage_pages_after_select_sites | |
| 538 | + * | |
| 539 | + * Fires after the Select Sites section on Manage pages. | |
| 540 | + * | |
| 541 | + * @since 4.1 | |
| 542 | + */ | |
| 543 | + do_action( 'mainwp_manage_pages_after_select_sites' ); | |
| 544 | + ?> | |
| 545 | + </div> | |
| 546 | + <div class="ui fitted divider"></div> | |
| 547 | + <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion"> | |
| 548 | + <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Status', 'mainwp' ); ?></div> | |
| 549 | + <div class="content active"> | |
| 550 | + <?php | |
| 551 | + /** | |
| 552 | + * Action: mainwp_manage_pages_before_search_options | |
| 553 | + * | |
| 554 | + * Fires before the Search Options on Manage Pages. | |
| 555 | + * | |
| 556 | + * @since 4.1 | |
| 557 | + */ | |
| 558 | + do_action( 'mainwp_manage_pages_before_search_options' ); | |
| 559 | + ?> | |
| 560 | + <div class="ui mini form"> | |
| 561 | + <div class="field"> | |
| 562 | + <select multiple="" class="ui fluid dropdown" id="mainwp_page_search_type"> | |
| 563 | + <option value=""><?php esc_html_e( 'Select status', 'mainwp' ); ?></option> | |
| 564 | + <option value="publish" selected><?php esc_html_e( 'Published', 'mainwp' ); ?></option> | |
| 565 | + <option value="pending"><?php esc_html_e( 'Pending', 'mainwp' ); ?></option> | |
| 566 | + <option value="private"><?php esc_html_e( 'Private', 'mainwp' ); ?></option> | |
| 567 | + <option value="future"><?php esc_html_e( 'Scheduled', 'mainwp' ); ?></option> | |
| 568 | + <option value="draft"><?php esc_html_e( 'Draft', 'mainwp' ); ?></option> | |
| 569 | + <option value="trash"><?php esc_html_e( 'Trash', 'mainwp' ); ?></option> | |
| 570 | + </select> | |
| 571 | + </div> | |
| 572 | + </div> | |
| 573 | + </div> | |
| 574 | + </div> | |
| 575 | + <div class="ui fitted divider"></div> | |
| 576 | + <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion"> | |
| 577 | + <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Search Options', 'mainwp' ); ?></div> | |
| 578 | + <div class="content active"> | |
| 579 | + <?php static::render_search_options(); ?> | |
| 580 | + <?php | |
| 581 | + /** | |
| 582 | + * Action: mainwp_manage_pages_after_search_options | |
| 583 | + * | |
| 584 | + * Fires after the Search Options on Manage Pages. | |
| 585 | + * | |
| 586 | + * @since 4.1 | |
| 587 | + */ | |
| 588 | + do_action( 'mainwp_manage_pages_after_search_options' ); | |
| 589 | + ?> | |
| 590 | + </div> | |
| 591 | + </div> | |
| 592 | + <div class="ui fitted divider"></div> | |
| 593 | + <div class="mainwp-search-submit"> | |
| 594 | + <?php | |
| 595 | + /** | |
| 596 | + * Action: mainwp_manage_pages_before_submit_button | |
| 597 | + * | |
| 598 | + * Fires before the Submit Button on Manage Pages. | |
| 599 | + * | |
| 600 | + * @since 4.1 | |
| 601 | + */ | |
| 602 | + do_action( 'mainwp_manage_pages_before_submit_button' ); | |
| 603 | + $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 604 | + if ( $is_demo ) { | |
| 605 | + MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<input type="button" class="ui green big fluid button disabled" disabled="disabled" value="' . esc_attr__( 'Show Pages', 'mainwp' ) . '"/>' ); | |
| 606 | + } else { | |
| 607 | + ?> | |
| 608 | + <input type="button" name="mainwp_show_pages" id="mainwp_show_pages" class="ui green big fluid button" value="<?php esc_attr_e( 'Show Pages', 'mainwp' ); ?>"/> | |
| 609 | + <?php | |
| 610 | + } | |
| 611 | + /** | |
| 612 | + * Action: mainwp_manage_pages_after_submit_button | |
| 613 | + * | |
| 614 | + * Fires after the Submit Button on Manage Pages. | |
| 615 | + * | |
| 616 | + * @since 4.1 | |
| 617 | + */ | |
| 618 | + do_action( 'mainwp_manage_pages_after_submit_button' ); | |
| 619 | + ?> | |
| 620 | + </div> | |
| 621 | + <?php | |
| 622 | + /** | |
| 623 | + * Action: mainwp_manage_pages_sidebar_bottom | |
| 624 | + * | |
| 625 | + * Fires at the bottom of the sidebar on Manage pages. | |
| 626 | + * | |
| 627 | + * @since 4.1 | |
| 628 | + */ | |
| 629 | + do_action( 'mainwp_manage_pages_sidebar_bottom' ); | |
| 630 | + ?> | |
| 631 | + </div> | |
| 632 | + <div class="ui hidden clearing divider"></div> | |
| 633 | + </div> | |
| 634 | + <?php | |
| 635 | + } | |
| 448 | 636 | |
| 449 | - $selected_sites = array(); | |
| 450 | - $selected_groups = array(); | |
| 451 | - $selected_clients = array(); | |
| 637 | + /** | |
| 638 | + * Method render_search_options() | |
| 639 | + * | |
| 640 | + * Render search options box. | |
| 641 | + * | |
| 642 | + * @return void Output the page search options box | |
| 643 | + * | |
| 644 | + * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() | |
| 645 | + */ | |
| 646 | + public static function render_search_options() { | |
| 647 | + $cachedSearch = MainWP_Cache::get_cached_context( 'Page' ); | |
| 648 | + $statuses = isset( $cachedSearch['status'] ) ? $cachedSearch['status'] : array(); | |
| 649 | + if ( $cachedSearch && isset( $cachedSearch['keyword'] ) ) { | |
| 650 | + $cachedSearch['keyword'] = trim( $cachedSearch['keyword'] ); | |
| 651 | + } | |
| 652 | + ?> | |
| 653 | + <div class="ui mini form"> | |
| 654 | + <div class="two fields"> | |
| 655 | + <div class="field"> | |
| 656 | + <div class="ui input fluid"> | |
| 657 | + <input type="text" placeholder="<?php esc_attr_e( 'Containing keyword', 'mainwp' ); ?>" id="mainwp_page_search_by_keyword" class="text" value="<?php echo ( null !== $cachedSearch ) ? esc_attr( $cachedSearch['keyword'] ) : ''; ?>" /> | |
| 658 | + </div> | |
| 659 | + </div> | |
| 660 | + <div class="field"> | |
| 661 | + <?php | |
| 662 | + $searchon = 'all'; | |
| 663 | + if ( null !== $cachedSearch ) { | |
| 664 | + $searchon = $cachedSearch['search_on']; | |
| 665 | + } | |
| 666 | + ?> | |
| 667 | + <select class="ui dropdown fluid" id="mainwp_page_search_on"> | |
| 668 | + <option value=""><?php esc_html_e( 'Search in...', 'mainwp' ); ?></option> | |
| 669 | + <option value="title" <?php echo 'title' === $searchon ? 'selected' : ''; ?>><?php esc_html_e( 'Title', 'mainwp' ); ?></option> | |
| 670 | + <option value="content" <?php echo 'content' === $searchon ? 'selected' : ''; ?>><?php esc_html_e( 'Body', 'mainwp' ); ?></option> | |
| 671 | + <option value="all" <?php echo 'all' === $searchon ? 'selected' : ''; ?>><?php esc_html_e( 'Title and Body', 'mainwp' ); ?></option> | |
| 672 | + </select> | |
| 673 | + </div> | |
| 674 | + </div> | |
| 675 | + <div class="field"> | |
| 676 | + <label><?php esc_html_e( 'Date range', 'mainwp' ); ?></label> | |
| 677 | + <div class="two fields"> | |
| 678 | + <div class="field"> | |
| 679 | + <div class="ui calendar mainwp_datepicker" > | |
| 680 | + <div class="ui input left icon"> | |
| 681 | + <i class="calendar icon"></i> | |
| 682 | + <input type="text" placeholder="Date" autocomplete="off" id="mainwp_page_search_by_dtsstart" value=" | |
| 683 | + <?php | |
| 684 | + if ( null !== $cachedSearch ) { | |
| 685 | + echo esc_attr( $cachedSearch['dtsstart'] ); | |
| 686 | + } | |
| 687 | + ?> | |
| 688 | + "/> | |
| 689 | + </div> | |
| 690 | + </div> | |
| 691 | + </div> | |
| 692 | + <div class="field"> | |
| 693 | + <div class="ui calendar mainwp_datepicker" > | |
| 694 | + <div class="ui input left icon"> | |
| 695 | + <i class="calendar icon"></i> | |
| 696 | + <input type="text" placeholder="Date" autocomplete="off" id="mainwp_page_search_by_dtsstop" value=" | |
| 697 | + <?php | |
| 698 | + if ( null !== $cachedSearch ) { | |
| 699 | + echo esc_attr( $cachedSearch['dtsstop'] ); | |
| 700 | + } | |
| 701 | + ?> | |
| 702 | + "/> | |
| 703 | + </div> | |
| 704 | + </div> | |
| 705 | + </div> | |
| 706 | + </div> | |
| 707 | + </div> | |
| 708 | + <div class="field"> | |
| 709 | + <label><?php esc_html_e( 'Max pages to return', 'mainwp' ); ?></label> | |
| 710 | + <input type="text" name="mainwp_maximumPages" id="mainwp_maximumPages" value="<?php echo ( false === get_option( 'mainwp_maximumPages' ) ) ? 50 : esc_attr( get_option( 'mainwp_maximumPages' ) ); ?>"/> | |
| 711 | + </div> | |
| 712 | + </div> | |
| 713 | + <?php | |
| 714 | + if ( is_array( $statuses ) && ! empty( $statuses ) ) { | |
| 715 | + $status = ''; | |
| 716 | + foreach ( $statuses as $st ) { | |
| 717 | + $status .= "'" . esc_html( $st ) . "',"; | |
| 718 | + } | |
| 719 | + $status = rtrim( $status, ',' ); | |
| 720 | + ?> | |
| 721 | + <script type="text/javascript"> | |
| 722 | + jQuery( document ).ready( function () { | |
| 723 | + jQuery( '#mainwp_page_search_type' ).dropdown( 'set selected',[<?php echo $status; //phpcs:ignore -- safe output. ?>] ); | |
| 724 | + } ); | |
| 725 | + </script> | |
| 726 | + <?php | |
| 727 | + } | |
| 728 | + } | |
| 452 | 729 | |
| 453 | - if ( null !== $cachedSearch ) { | |
| 454 | - if ( is_array( $cachedSearch['sites'] ) ) { | |
| 455 | - $selected_sites = $cachedSearch['sites']; | |
| 456 | - } elseif ( is_array( $cachedSearch['groups'] ) ) { | |
| 457 | - $selected_groups = $cachedSearch['groups']; | |
| 458 | - } elseif ( is_array( $cachedSearch['clients'] ) ) { | |
| 459 | - $selected_clients = $cachedSearch['clients']; | |
| 460 | - } | |
| 461 | - } | |
| 730 | + /** | |
| 731 | + * Method render_table() | |
| 732 | + * | |
| 733 | + * Render Manage page table. | |
| 734 | + * | |
| 735 | + * @param mixed $cached Cached search body. | |
| 736 | + * @param string $keyword Search keywords. | |
| 737 | + * @param string $dtsstart Date & time of Session start time. | |
| 738 | + * @param string $dtsstop Date & time of Session stop time. | |
| 739 | + * @param string $status Page status. | |
| 740 | + * @param array $params Other params. | |
| 741 | + * | |
| 742 | + * @return void Page table html. | |
| 743 | + * | |
| 744 | + * @uses \MainWP\Dashboard\MainWP_Cache::echo_body() | |
| 745 | + * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 746 | + */ | |
| 747 | + public static function render_table( $cached, $keyword = '', $dtsstart = '', $dtsstop = '', $status = '', $params = array() ) { | |
| 462 | 748 | |
| 463 | - ?> | |
| 464 | - <?php self::render_header( 'BulkManage' ); ?> | |
| 749 | + if ( ! is_array( $params ) ) { | |
| 750 | + $params = array(); | |
| 751 | + } | |
| 465 | 752 | |
| 466 | - <div id="mainwp-manage-pages" class="ui alt segment"> | |
| 467 | - <div class="mainwp-main-content"> | |
| 468 | - <div class="mainwp-actions-bar ui mini form"> | |
| 469 | - <div class="ui grid"> | |
| 470 | - <div class="ui two column row"> | |
| 471 | - <div class="column"> | |
| 472 | - <select class="ui dropdown" id="mainwp-bulk-actions"> | |
| 473 | - <option value="none"><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option> | |
| 474 | - <?php do_action( 'mainwp_manage_pages_bulk_action' ); ?> | |
| 475 | - <option value="trash"><?php esc_html_e( 'Move to trash', 'mainwp' ); ?></option> | |
| 476 | - <option value="restore"><?php esc_html_e( 'Restore', 'mainwp' ); ?></option> | |
| 477 | - <option value="delete"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></option> | |
| 478 | - <?php | |
| 479 | - /** | |
| 480 | - * Action: mainwp_pages_bulk_action | |
| 481 | - * | |
| 482 | - * Adds new action to the Bulk Actions menu on Manage Pages. | |
| 483 | - * | |
| 484 | - * Suggested HTML Markup: | |
| 485 | - * <option value="Your custom value">Your custom text</option> | |
| 486 | - * | |
| 487 | - * @since 4.1 | |
| 488 | - */ | |
| 489 | - do_action( 'mainwp_pages_bulk_action' ); | |
| 490 | - ?> | |
| 491 | - </select> | |
| 492 | - <button class="ui mini button" id="mainwp-do-pages-bulk-actions"><?php esc_html_e( 'Apply', 'mainwp' ); ?></button> | |
| 493 | - <?php | |
| 494 | - /** | |
| 495 | - * Action: mainwp_pages_actions_bar_left | |
| 496 | - * | |
| 497 | - * Fires at the left side of the actions bar on the Pages screen, after the Bulk Actions menu. | |
| 498 | - * | |
| 499 | - * @since 4.0 | |
| 500 | - */ | |
| 501 | - do_action( 'mainwp_pages_actions_bar_left' ); | |
| 502 | - ?> | |
| 503 | - </div> | |
| 504 | - <div class="right aligned column"> | |
| 505 | - <?php | |
| 506 | - /** | |
| 507 | - * Action: mainwp_pages_actions_bar_right | |
| 508 | - * | |
| 509 | - * Fires at the right side of the actions bar on the Pages screen. | |
| 510 | - * | |
| 511 | - * @since 4.0 | |
| 512 | - */ | |
| 513 | - do_action( 'mainwp_pages_actions_bar_right' ); | |
| 514 | - ?> | |
| 515 | - </div> | |
| 516 | - </div> | |
| 517 | - </div> | |
| 518 | - </div> | |
| 519 | - <div class="ui segment" id="mainwp_pages_wrap_table"> | |
| 520 | - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-pages-info-message' ) ) : ?> | |
| 521 | - <div class="ui info message"> | |
| 522 | - <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-pages-info-message"></i> | |
| 523 | - <?php printf( esc_html__( 'Manage existing pages on your child sites. Here you can edit, view and delete pages. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/manage-pages/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?> | |
| 524 | - </div> | |
| 525 | - <?php endif; ?> | |
| 526 | - <?php self::render_table( true ); ?> | |
| 527 | - </div> | |
| 528 | - </div> | |
| 529 | - <div class="mainwp-side-content mainwp-no-padding"> | |
| 530 | - <?php | |
| 531 | - /** | |
| 532 | - * Action: mainwp_manage_pages_sidebar_top | |
| 533 | - * | |
| 534 | - * Fires at the top of the sidebar on Manage pages. | |
| 535 | - * | |
| 536 | - * @since 4.1 | |
| 537 | - */ | |
| 538 | - do_action( 'mainwp_manage_pages_sidebar_top' ); | |
| 539 | - ?> | |
| 540 | - <div class="mainwp-select-sites ui accordion mainwp-sidebar-accordion"> | |
| 541 | - <?php | |
| 542 | - /** | |
| 543 | - * Action: mainwp_manage_pages_before_select_sites | |
| 544 | - * | |
| 545 | - * Fires before the Select Sites section on Manage pages. | |
| 546 | - * | |
| 547 | - * @since 4.1 | |
| 548 | - */ | |
| 549 | - do_action( 'mainwp_manage_pages_before_select_sites' ); | |
| 550 | - ?> | |
| 551 | - <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Sites', 'mainwp' ); ?></div> | |
| 552 | - <div class="content active"> | |
| 553 | - <?php | |
| 554 | - $sel_params = array( | |
| 555 | - 'selected_sites' => $selected_sites, | |
| 556 | - 'selected_groups' => $selected_groups, | |
| 557 | - 'selected_clients' => $selected_clients, | |
| 558 | - 'class' => 'mainwp_select_sites_box_left', | |
| 559 | - 'show_client' => true, | |
| 560 | - ); | |
| 561 | - MainWP_UI_Select_Sites::select_sites_box( $sel_params ); | |
| 562 | - ?> | |
| 563 | - </div> | |
| 564 | - <?php | |
| 565 | - /** | |
| 566 | - * Action: mainwp_manage_pages_after_select_sites | |
| 567 | - * | |
| 568 | - * Fires after the Select Sites section on Manage pages. | |
| 569 | - * | |
| 570 | - * @since 4.1 | |
| 571 | - */ | |
| 572 | - do_action( 'mainwp_manage_pages_after_select_sites' ); | |
| 573 | - ?> | |
| 574 | - </div> | |
| 575 | - <div class="ui fitted divider"></div> | |
| 576 | - <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion"> | |
| 577 | - <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Status', 'mainwp' ); ?></div> | |
| 578 | - <div class="content active"> | |
| 579 | - <?php | |
| 580 | - /** | |
| 581 | - * Action: mainwp_manage_pages_before_search_options | |
| 582 | - * | |
| 583 | - * Fires before the Search Options on Manage Pages. | |
| 584 | - * | |
| 585 | - * @since 4.1 | |
| 586 | - */ | |
| 587 | - do_action( 'mainwp_manage_pages_before_search_options' ); | |
| 588 | - ?> | |
| 589 | - <div class="ui mini form"> | |
| 590 | - <div class="field"> | |
| 591 | - <select multiple="" class="ui fluid dropdown" id="mainwp_page_search_type"> | |
| 592 | - <option value=""><?php esc_html_e( 'Select status', 'mainwp' ); ?></option> | |
| 593 | - <option value="publish" selected><?php esc_html_e( 'Published', 'mainwp' ); ?></option> | |
| 594 | - <option value="pending"><?php esc_html_e( 'Pending', 'mainwp' ); ?></option> | |
| 595 | - <option value="private"><?php esc_html_e( 'Private', 'mainwp' ); ?></option> | |
| 596 | - <option value="future"><?php esc_html_e( 'Scheduled', 'mainwp' ); ?></option> | |
| 597 | - <option value="draft"><?php esc_html_e( 'Draft', 'mainwp' ); ?></option> | |
| 598 | - <option value="trash"><?php esc_html_e( 'Trash', 'mainwp' ); ?></option> | |
| 599 | - </select> | |
| 600 | - </div> | |
| 601 | - </div> | |
| 602 | - </div> | |
| 603 | - </div> | |
| 604 | - <div class="ui fitted divider"></div> | |
| 605 | - <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion"> | |
| 606 | - <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Search Options', 'mainwp' ); ?></div> | |
| 607 | - <div class="content active"> | |
| 608 | - <?php self::render_search_options(); ?> | |
| 609 | - <?php | |
| 610 | - /** | |
| 611 | - * Action: mainwp_manage_pages_after_search_options | |
| 612 | - * | |
| 613 | - * Fires after the Search Options on Manage Pages. | |
| 614 | - * | |
| 615 | - * @since 4.1 | |
| 616 | - */ | |
| 617 | - do_action( 'mainwp_manage_pages_after_search_options' ); | |
| 618 | - ?> | |
| 619 | - </div> | |
| 620 | - </div> | |
| 621 | - <div class="ui fitted divider"></div> | |
| 622 | - <div class="mainwp-search-submit"> | |
| 623 | - <?php | |
| 624 | - /** | |
| 625 | - * Action: mainwp_manage_pages_before_submit_button | |
| 626 | - * | |
| 627 | - * Fires before the Submit Button on Manage Pages. | |
| 628 | - * | |
| 629 | - * @since 4.1 | |
| 630 | - */ | |
| 631 | - do_action( 'mainwp_manage_pages_before_submit_button' ); | |
| 632 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 633 | - if ( $is_demo ) { | |
| 634 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<input type="button" class="ui green big fluid button disabled" disabled="disabled" value="' . esc_attr__( 'Show Pages', 'mainwp' ) . '"/>' ); | |
| 635 | - } else { | |
| 636 | - ?> | |
| 637 | - <input type="button" name="mainwp_show_pages" id="mainwp_show_pages" class="ui green big fluid button" value="<?php esc_attr_e( 'Show Pages', 'mainwp' ); ?>"/> | |
| 638 | - <?php | |
| 639 | - } | |
| 640 | - /** | |
| 641 | - * Action: mainwp_manage_pages_after_submit_button | |
| 642 | - * | |
| 643 | - * Fires after the Submit Button on Manage Pages. | |
| 644 | - * | |
| 645 | - * @since 4.1 | |
| 646 | - */ | |
| 647 | - do_action( 'mainwp_manage_pages_after_submit_button' ); | |
| 648 | - ?> | |
| 649 | - </div> | |
| 650 | - <?php | |
| 651 | - /** | |
| 652 | - * Action: mainwp_manage_pages_sidebar_bottom | |
| 653 | - * | |
| 654 | - * Fires at the bottom of the sidebar on Manage pages. | |
| 655 | - * | |
| 656 | - * @since 4.1 | |
| 657 | - */ | |
| 658 | - do_action( 'mainwp_manage_pages_sidebar_bottom' ); | |
| 659 | - ?> | |
| 660 | - </div> | |
| 661 | - <div class="ui hidden clearing divider"></div> | |
| 662 | - </div> | |
| 663 | - <?php | |
| 664 | - } | |
| 753 | + $groups = isset( $params['groups'] ) ? $params['groups'] : ''; | |
| 754 | + $sites = isset( $params['sites'] ) ? $params['sites'] : ''; | |
| 755 | + $search_on = isset( $params['search_on'] ) ? $params['search_on'] : 'all'; | |
| 756 | + $clients = isset( $params['clients'] ) ? $params['clients'] : ''; | |
| 665 | 757 | |
| 666 | - /** | |
| 667 | - * Method render_search_options() | |
| 668 | - * | |
| 669 | - * Render search options box. | |
| 670 | - * | |
| 671 | - * @return void Output the page search options box | |
| 672 | - * | |
| 673 | - * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() | |
| 674 | - */ | |
| 675 | - public static function render_search_options() { | |
| 676 | - $cachedSearch = MainWP_Cache::get_cached_context( 'Page' ); | |
| 677 | - $statuses = isset( $cachedSearch['status'] ) ? $cachedSearch['status'] : array(); | |
| 678 | - if ( $cachedSearch && isset( $cachedSearch['keyword'] ) ) { | |
| 679 | - $cachedSearch['keyword'] = trim( $cachedSearch['keyword'] ); | |
| 680 | - } | |
| 681 | - ?> | |
| 682 | - <div class="ui mini form"> | |
| 683 | - <div class="field"> | |
| 684 | - <div class="ui input fluid"> | |
| 685 | - <input type="text" placeholder="<?php esc_attr_e( 'Containing keyword', 'mainwp' ); ?>" id="mainwp_page_search_by_keyword" class="text" value="<?php echo ( null !== $cachedSearch ) ? esc_attr( $cachedSearch['keyword'] ) : ''; ?>" /> | |
| 686 | - </div> | |
| 687 | - </div> | |
| 688 | - <div class="field"> | |
| 689 | - <?php | |
| 690 | - $searchon = 'all'; | |
| 691 | - if ( null !== $cachedSearch ) { | |
| 692 | - $searchon = $cachedSearch['search_on']; | |
| 693 | - } | |
| 694 | - ?> | |
| 695 | - <select class="ui dropdown fluid" id="mainwp_page_search_on"> | |
| 696 | - <option value=""><?php esc_html_e( 'Search in...', 'mainwp' ); ?></option> | |
| 697 | - <option value="title" <?php echo 'title' === $searchon ? 'selected' : ''; ?>><?php esc_html_e( 'Title', 'mainwp' ); ?></option> | |
| 698 | - <option value="content" <?php echo 'content' === $searchon ? 'selected' : ''; ?>><?php esc_html_e( 'Body', 'mainwp' ); ?></option> | |
| 699 | - <option value="all" <?php echo 'all' === $searchon ? 'selected' : ''; ?>><?php esc_html_e( 'Title and Body', 'mainwp' ); ?></option> | |
| 700 | - </select> | |
| 701 | - </div> | |
| 702 | - <div class="field"> | |
| 703 | - <label><?php esc_html_e( 'Date range', 'mainwp' ); ?></label> | |
| 704 | - <div class="two fields"> | |
| 705 | - <div class="field"> | |
| 706 | - <div class="ui calendar mainwp_datepicker" > | |
| 707 | - <div class="ui input left icon"> | |
| 708 | - <i class="calendar icon"></i> | |
| 709 | - <input type="text" placeholder="Date" autocomplete="off" id="mainwp_page_search_by_dtsstart" value=" | |
| 710 | - <?php | |
| 711 | - if ( null !== $cachedSearch ) { | |
| 712 | - echo esc_attr( $cachedSearch['dtsstart'] ); | |
| 713 | - } | |
| 714 | - ?> | |
| 715 | - "/> | |
| 716 | - </div> | |
| 717 | - </div> | |
| 718 | - </div> | |
| 719 | - <div class="field"> | |
| 720 | - <div class="ui calendar mainwp_datepicker" > | |
| 721 | - <div class="ui input left icon"> | |
| 722 | - <i class="calendar icon"></i> | |
| 723 | - <input type="text" placeholder="Date" autocomplete="off" id="mainwp_page_search_by_dtsstop" value=" | |
| 724 | - <?php | |
| 725 | - if ( null !== $cachedSearch ) { | |
| 726 | - echo esc_attr( $cachedSearch['dtsstop'] ); | |
| 727 | - } | |
| 728 | - ?> | |
| 729 | - "/> | |
| 730 | - </div> | |
| 731 | - </div> | |
| 732 | - </div> | |
| 733 | - </div> | |
| 734 | - </div> | |
| 735 | - <div class="field"> | |
| 736 | - <label><?php esc_html_e( 'Max pages to return', 'mainwp' ); ?></label> | |
| 737 | - <input type="text" name="mainwp_maximumPages" id="mainwp_maximumPages" value="<?php echo( ( false === get_option( 'mainwp_maximumPages' ) ) ? 50 : esc_attr( get_option( 'mainwp_maximumPages' ) ) ); ?>"/> | |
| 738 | - </div> | |
| 739 | - </div> | |
| 740 | - <?php | |
| 741 | - if ( is_array( $statuses ) && 0 < count( $statuses ) ) { | |
| 742 | - $status = ''; | |
| 743 | - foreach ( $statuses as $st ) { | |
| 744 | - $status .= "'" . esc_html( $st ) . "',"; | |
| 745 | - } | |
| 746 | - $status = rtrim( $status, ',' ); | |
| 747 | - ?> | |
| 748 | - <script type="text/javascript"> | |
| 749 | - jQuery( document ).ready( function () { | |
| 750 | - jQuery( '#mainwp_page_search_type' ).dropdown( 'set selected',[<?php echo $status; //phpcs:ignore -- safe output. ?>] ); | |
| 751 | - } ); | |
| 752 | - </script> | |
| 753 | - <?php | |
| 754 | - } | |
| 755 | - } | |
| 758 | + $has_cached_results = $cached && isset( $_SESSION['MainWPPageSearch'] ) && ! empty( $_SESSION['MainWPPageSearch'] ); | |
| 756 | 759 | |
| 757 | - /** | |
| 758 | - * Method render_table() | |
| 759 | - * | |
| 760 | - * Render Manage page table. | |
| 761 | - * | |
| 762 | - * @param mixed $cached Cached search body. | |
| 763 | - * @param string $keyword Search keywords. | |
| 764 | - * @param string $dtsstart Date & time of Session start time. | |
| 765 | - * @param string $dtsstop Date & time of Session stop time. | |
| 766 | - * @param string $status Page status. | |
| 767 | - * @param string $groups Groups to display. | |
| 768 | - * @param string $sites Site URLS. | |
| 769 | - * @param string $search_on Site on all sites. Default = all. | |
| 770 | - * @param mixed $clients Selected Clients. | |
| 771 | - * | |
| 772 | - * @return void Page table html. | |
| 773 | - * | |
| 774 | - * @uses \MainWP\Dashboard\MainWP_Cache::echo_body() | |
| 775 | - * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 776 | - */ | |
| 777 | - public static function render_table( $cached, $keyword = '', $dtsstart = '', $dtsstop = '', $status = '', $groups = '', $sites = '', $search_on = 'all', $clients = '' ) { | |
| 778 | - ?> | |
| 779 | - <div id="mainwp_pages_error"></div> | |
| 780 | - <div id="mainwp-loading-pages-row" style="display: none;"> | |
| 781 | - <div class="ui active inverted dimmer"> | |
| 782 | - <div class="ui indeterminate large text loader"><?php esc_html_e( 'Loading Pages...', 'mainwp' ); ?></div> | |
| 783 | - </div> | |
| 784 | - </div> | |
| 785 | - <?php | |
| 786 | - /** | |
| 787 | - * Action: mainwp_before_pages_table | |
| 788 | - * | |
| 789 | - * Fires before the Manage Pages table. | |
| 790 | - * | |
| 791 | - * @since 4.1 | |
| 792 | - */ | |
| 793 | - do_action( 'mainwp_before_pages_table' ); | |
| 794 | - ?> | |
| 795 | - <table id="mainwp-pages-table" class="ui unstackable single line table" style="width:100%"> | |
| 796 | - <thead> | |
| 797 | - <tr> | |
| 798 | - <th class="no-sort check-column collapsing"><span class="ui checkbox"><input id="cb-select-all-top" type="checkbox" /></span></th> | |
| 799 | - <?php | |
| 800 | - /** | |
| 801 | - * Action: mainwp_pages_table_header | |
| 802 | - * | |
| 803 | - * Adds new column header to the Manage pages table. | |
| 804 | - * | |
| 805 | - * @since 4.1 | |
| 806 | - */ | |
| 807 | - do_action( 'mainwp_pages_table_header' ); | |
| 808 | - ?> | |
| 809 | - <th id="title"><?php esc_html_e( 'Title', 'mainwp' ); ?></th> | |
| 810 | - <th id="author" class="min-tablet"><?php esc_html_e( 'Author', 'mainwp' ); ?></th> | |
| 811 | - <th id="comments"><i class="comment icon"></i></th> | |
| 812 | - <th id="date" class="min-tablet"><?php esc_html_e( 'Last Modified', 'mainwp' ); ?></th> | |
| 813 | - <th id="status"><?php esc_html_e( 'Status', 'mainwp' ); ?></th> | |
| 814 | - <?php if ( MainWP_Utility::enabled_wp_seo() ) : ?> | |
| 815 | - <th id="seo-links"><span title="<?php echo esc_attr__( 'Number of internal links in this page', 'mainwp' ); ?>"><?php esc_html_e( 'Links', 'mainwp' ); ?></span></th> | |
| 816 | - <th id="seo-linked"><span title="<?php echo esc_attr__( 'Number of internal links linking to this page', 'mainwp' ); ?>"><?php esc_html_e( 'Linked', 'mainwp' ); ?></span></th> | |
| 817 | - <th id="seo-score"><span title="<?php echo esc_attr__( 'SEO score', 'mainwp' ); ?>"><?php esc_html_e( 'SEO score', 'mainwp' ); ?></span></th> | |
| 818 | - <th id="seo-readability"><span title="<?php echo esc_attr__( 'Readability score', 'mainwp' ); ?>"><?php esc_html_e( 'Readability score', 'mainwp' ); ?></span></th> | |
| 819 | - <?php endif; ?> | |
| 820 | - <th id="website" class="min-tablet"><?php esc_html_e( 'Website', 'mainwp' ); ?></th> | |
| 821 | - <th id="pages-actions" class="no-sort min-tablet"></th> | |
| 822 | - </tr> | |
| 823 | - </thead> | |
| 824 | - <tbody id="mainwp-posts-list"> | |
| 825 | - <?php | |
| 826 | - if ( $cached ) { | |
| 827 | - MainWP_Cache::echo_body( 'Page' ); | |
| 828 | - } else { | |
| 829 | - self::render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on, $clients ); | |
| 830 | - } | |
| 831 | - ?> | |
| 832 | - </tbody> | |
| 833 | - </table> | |
| 834 | - <?php | |
| 835 | - /** | |
| 836 | - * Action: mainwp_after_pages_table | |
| 837 | - * | |
| 838 | - * Fires after the Manage Pages table. | |
| 839 | - * | |
| 840 | - * @since 4.1 | |
| 841 | - */ | |
| 842 | - do_action( 'mainwp_after_pages_table' ); | |
| 760 | + ?> | |
| 761 | + <div id="mainwp_pages_error"></div> | |
| 762 | + <div id="mainwp-loading-pages-row" style="display: none;"> | |
| 763 | + <div class="ui active page dimmer"> | |
| 764 | + <div class="ui double text loader"><?php esc_html_e( 'Loading...', 'mainwp' ); ?></div> | |
| 765 | + </div> | |
| 766 | + </div> | |
| 843 | 767 | |
| 844 | - $table_features = array( | |
| 845 | - 'searching' => 'true', | |
| 846 | - 'paging' => 'true', | |
| 847 | - 'info' => 'true', | |
| 848 | - 'stateSave' => 'true', | |
| 849 | - 'scrollX' => 'true', | |
| 850 | - 'colReorder' => '{ fixedColumnsLeft: 1, fixedColumnsRight: 1 }', | |
| 851 | - 'order' => '[]', | |
| 852 | - 'responsive' => 'true', | |
| 853 | - ); | |
| 768 | + <?php | |
| 769 | + /** | |
| 770 | + * Action: mainwp_before_pages_table | |
| 771 | + * | |
| 772 | + * Fires before the Manage Pages table. | |
| 773 | + * | |
| 774 | + * @since 4.1 | |
| 775 | + */ | |
| 776 | + do_action( 'mainwp_before_pages_table' ); | |
| 854 | 777 | |
| 855 | - /** | |
| 856 | - * Filter: mainwp_pages_table_fatures | |
| 857 | - * | |
| 858 | - * Filters the Manage Pages table features. | |
| 859 | - * | |
| 860 | - * @since 4.1 | |
| 861 | - */ | |
| 862 | - $table_features = apply_filters( 'mainwp_pages_table_fatures', $table_features ); | |
| 863 | - ?> | |
| 864 | - <script type="text/javascript"> | |
| 865 | - var responsive = <?php echo esc_html( $table_features['responsive'] ); ?>; | |
| 866 | - if( jQuery( window ).width() > 1140 ) { | |
| 867 | - responsive = false; | |
| 868 | - } | |
| 869 | - jQuery( document ).ready( function () { | |
| 870 | - try { | |
| 871 | - jQuery("#mainwp-pages-table").DataTable().destroy(); // fixed re-initialize datatable issue. | |
| 872 | - $manage_pages_table = jQuery( '#mainwp-pages-table' ).DataTable( { | |
| 873 | - "responsive" : responsive, | |
| 874 | - "searching" : <?php echo esc_html( $table_features['searching'] ); ?>, | |
| 875 | - "colReorder" : <?php echo esc_html( $table_features['colReorder'] ); ?>, | |
| 876 | - "stateSave": <?php echo esc_html( $table_features['stateSave'] ); ?>, | |
| 877 | - "paging": <?php echo esc_html( $table_features['paging'] ); ?>, | |
| 878 | - "info": <?php echo esc_html( $table_features['info'] ); ?>, | |
| 879 | - "order": <?php echo esc_html( $table_features['order'] ); ?>, | |
| 880 | - "scrollX" : <?php echo esc_html( $table_features['scrollX'] ); ?>, | |
| 881 | - "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ], | |
| 882 | - "columnDefs": [ { | |
| 883 | - "targets": 'no-sort', | |
| 884 | - "orderable": false | |
| 885 | - } ], | |
| 886 | - "language" : { "emptyTable": "<?php esc_html_e( 'Use the search options to find the page you want to manage.', 'mainwp' ); ?>" }, | |
| 887 | - "preDrawCallback": function( settings ) { | |
| 888 | - jQuery( '#mainwp_pages_wrap_table table .ui.dropdown' ).dropdown(); | |
| 889 | - jQuery( '#mainwp_pages_wrap_table table .ui.checkbox' ).checkbox(); | |
| 890 | - mainwp_datatable_fix_menu_overflow(); | |
| 891 | - mainwp_table_check_columns_init(); // ajax: to fix checkbox all. | |
| 892 | - } | |
| 893 | - } ); | |
| 894 | - } catch( err ) { | |
| 895 | - // to fix js error. | |
| 896 | - } | |
| 778 | + if ( ! $cached || $has_cached_results ) { | |
| 779 | + ?> | |
| 780 | + <table id="mainwp-pages-table" class="ui unstackable single line table" style="width:100%"> | |
| 781 | + <thead> | |
| 782 | + <tr> | |
| 783 | + <th class="no-sort check-column collapsing"><span class="ui checkbox"><input id="cb-select-all-top" type="checkbox" /></span></th> | |
| 784 | + <?php | |
| 785 | + /** | |
| 786 | + * Action: mainwp_pages_table_header | |
| 787 | + * | |
| 788 | + * Adds new column header to the Manage pages table. | |
| 789 | + * | |
| 790 | + * @since 4.1 | |
| 791 | + */ | |
| 792 | + do_action( 'mainwp_pages_table_header' ); | |
| 793 | + ?> | |
| 794 | + <th id="title"><?php esc_html_e( 'Title', 'mainwp' ); ?></th> | |
| 795 | + <th id="author" class="min-tablet"><?php esc_html_e( 'Author', 'mainwp' ); ?></th> | |
| 796 | + <th id="comments"><i class="comment icon"></i></th> | |
| 797 | + <th id="date" class="min-tablet"><?php esc_html_e( 'Last Modified', 'mainwp' ); ?></th> | |
| 798 | + <th id="status"><?php esc_html_e( 'Status', 'mainwp' ); ?></th> | |
| 799 | + <?php if ( MainWP_Utility::enabled_wp_seo() ) : ?> | |
| 800 | + <th id="seo-links"><span title="<?php echo esc_attr__( 'Number of internal links in this page', 'mainwp' ); ?>"><?php esc_html_e( 'Links', 'mainwp' ); ?></span></th> | |
| 801 | + <th id="seo-linked"><span title="<?php echo esc_attr__( 'Number of internal links linking to this page', 'mainwp' ); ?>"><?php esc_html_e( 'Linked', 'mainwp' ); ?></span></th> | |
| 802 | + <th id="seo-score"><span title="<?php echo esc_attr__( 'SEO score', 'mainwp' ); ?>"><?php esc_html_e( 'SEO score', 'mainwp' ); ?></span></th> | |
| 803 | + <th id="seo-readability"><span title="<?php echo esc_attr__( 'Readability score', 'mainwp' ); ?>"><?php esc_html_e( 'Readability score', 'mainwp' ); ?></span></th> | |
| 804 | + <?php endif; ?> | |
| 805 | + <th id="website" class="min-tablet"><?php esc_html_e( 'Website', 'mainwp' ); ?></th> | |
| 806 | + <th id="pages-actions" class="no-sort min-tablet"></th> | |
| 807 | + </tr> | |
| 808 | + </thead> | |
| 809 | + <tbody id="mainwp-posts-list"> | |
| 810 | + <?php | |
| 811 | + if ( $cached ) { | |
| 812 | + MainWP_Cache::echo_body( 'Page' ); | |
| 813 | + } else { | |
| 814 | + static::render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on, $clients ); | |
| 815 | + } | |
| 816 | + ?> | |
| 817 | + </tbody> | |
| 818 | + </table> | |
| 819 | + <?php | |
| 820 | + } else { | |
| 821 | + MainWP_UI::render_empty_page_placeholder( | |
| 822 | + esc_html__( 'Find Pages', 'mainwp' ), | |
| 823 | + esc_html__( 'Select the Child Sites you want, choose any filters, then click Show Pages.', 'mainwp' ), | |
| 824 | + '<em data-emoji=":page_facing_up:" class="big"></em>' | |
| 825 | + ); | |
| 826 | + } | |
| 827 | + /** | |
| 828 | + * Action: mainwp_after_pages_table | |
| 829 | + * | |
| 830 | + * Fires after the Manage Pages table. | |
| 831 | + * | |
| 832 | + * @since 4.1 | |
| 833 | + */ | |
| 834 | + do_action( 'mainwp_after_pages_table' ); | |
| 897 | 835 | |
| 898 | - _init_manage_sites_screen = function() { | |
| 899 | - jQuery( '#mainwp-overview-screen-options-modal input[type=checkbox][id^="mainwp_show_column_"]' ).each( function() { | |
| 900 | - var col_id = jQuery( this ).attr( 'id' ); | |
| 901 | - col_id = col_id.replace( "mainwp_show_column_", "" ); | |
| 902 | - try { | |
| 903 | - $manage_pages_table.column( '#' + col_id ).visible( jQuery(this).is( ':checked' ) ); | |
| 904 | - } catch(err) { | |
| 905 | - // to fix js error. | |
| 906 | - } | |
| 907 | - } ); | |
| 908 | - }; | |
| 909 | - _init_manage_sites_screen(); | |
| 910 | - } ); | |
| 911 | - </script> | |
| 912 | - <?php | |
| 913 | - } | |
| 836 | + $table_features = array( | |
| 837 | + 'searching' => 'true', | |
| 838 | + 'paging' => 'true', | |
| 839 | + 'info' => 'true', | |
| 840 | + 'stateSave' => 'true', | |
| 841 | + 'scrollX' => 'true', | |
| 842 | + 'colReorder' => '{columns:":not(.check-column):not(:last-child)"}', | |
| 843 | + 'order' => '[]', | |
| 844 | + 'responsive' => 'true', | |
| 845 | + ); | |
| 914 | 846 | |
| 915 | - /** | |
| 916 | - * Method render_table_body() | |
| 917 | - * | |
| 918 | - * Render table body. | |
| 919 | - * | |
| 920 | - * @param mixed $keyword Search keywords. | |
| 921 | - * @param mixed $dtsstart Date & time of Session start. | |
| 922 | - * @param mixed $dtsstop Date & time of Session stop. | |
| 923 | - * @param mixed $status Page statuses. | |
| 924 | - * @param mixed $groups Groups to display. | |
| 925 | - * @param mixed $sites Site URLS. | |
| 926 | - * @param string $search_on Site on all sites. Default = all. | |
| 927 | - * @param mixed $clients Selected Clients. | |
| 928 | - * | |
| 929 | - * @return void Output table body. | |
| 930 | - * | |
| 931 | - * @uses \MainWP\Dashboard\MainWP_Cache::init_cache() | |
| 932 | - * @uses \MainWP\Dashboard\MainWP_Cache::add_context() | |
| 933 | - * @uses \MainWP\Dashboard\MainWP_Cache::add_body() | |
| 934 | - * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 935 | - * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 936 | - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_by_group_id() | |
| 937 | - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 938 | - * @uses \MainWP\Dashboard\MainWP_DB::free_result() | |
| 939 | - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 940 | - * @uses \MainWP\Dashboard\MainWP_Utility::map_site() | |
| 941 | - * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 942 | - */ | |
| 943 | - public static function render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on = 'all', $clients = '' ) { // phpcs:ignore -- complex function. | |
| 847 | + /** | |
| 848 | + * Filter: mainwp_pages_table_fatures | |
| 849 | + * | |
| 850 | + * Filters the Manage Pages table features. | |
| 851 | + * | |
| 852 | + * @since 4.1 | |
| 853 | + */ | |
| 854 | + $table_features = apply_filters( 'mainwp_pages_table_fatures', $table_features ); | |
| 855 | + ?> | |
| 856 | + <script type="text/javascript"> | |
| 857 | + jQuery( document ).ready( function () { | |
| 858 | + let responsive = <?php echo esc_html( $table_features['responsive'] ); // to fix. ?>; | |
| 859 | + if( jQuery( window ).width() > 1140 ) { | |
| 860 | + responsive = false; | |
| 861 | + } | |
| 862 | + try { | |
| 863 | + jQuery("#mainwp-pages-table").DataTable().destroy(); // fixed re-initialize datatable issue. | |
| 864 | + $manage_pages_table = jQuery( '#mainwp-pages-table' ).DataTable( { | |
| 865 | + "responsive" : responsive, | |
| 866 | + "searching" : <?php echo esc_html( $table_features['searching'] ); ?>, | |
| 867 | + "colReorder" : <?php echo $table_features['colReorder']; // phpcs:ignore -- specical chars. ?>, | |
| 868 | + "stateSave": <?php echo esc_html( $table_features['stateSave'] ); ?>, | |
| 869 | + "paging": <?php echo esc_html( $table_features['paging'] ); ?>, | |
| 870 | + "info": <?php echo esc_html( $table_features['info'] ); ?>, | |
| 871 | + "order": <?php echo esc_html( $table_features['order'] ); ?>, | |
| 872 | + "scrollX" : <?php echo esc_html( $table_features['scrollX'] ); ?>, | |
| 873 | + "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ], | |
| 874 | + "columnDefs": [ { | |
| 875 | + "targets": 'no-sort', | |
| 876 | + "orderable": false | |
| 877 | + } ], | |
| 878 | + "language" : { "emptyTable": "<?php esc_html_e( 'No pages found matching your search criteria.', 'mainwp' ); ?>" }, | |
| 879 | + "drawCallback": function( settings ) { | |
| 880 | + setTimeout(() => { // to fix. | |
| 881 | + jQuery( '#mainwp-pages-table .ui.dropdown' ).dropdown(); | |
| 882 | + jQuery( '#mainwp-pages-table .ui.checkbox' ).checkbox(); | |
| 883 | + mainwp_datatable_fix_menu_overflow('#mainwp-pages-table'); | |
| 884 | + mainwp_table_check_columns_init(); // ajax: to fix checkbox all. | |
| 885 | + }, 1000); | |
| 886 | + }, | |
| 887 | + select: { | |
| 888 | + items: 'row', | |
| 889 | + style: 'multi+shift', | |
| 890 | + selector: 'tr>td:not(.not-selectable)' | |
| 891 | + } | |
| 892 | + } ).on('select', function (e, dt, type, indexes) { | |
| 893 | + if( 'row' == type ){ | |
| 894 | + dt.rows(indexes) | |
| 895 | + .nodes() | |
| 896 | + .to$().find('td.check-column .ui.checkbox' ).checkbox('set checked'); | |
| 897 | + } | |
| 898 | + }).on('deselect', function (e, dt, type, indexes) { | |
| 899 | + if( 'row' == type ){ | |
| 900 | + dt.rows(indexes) | |
| 901 | + .nodes() | |
| 902 | + .to$().find('td.check-column .ui.checkbox' ).checkbox('set unchecked'); | |
| 903 | + } | |
| 904 | + }).on( 'columns-reordered', function () { | |
| 905 | + setTimeout(() => { // to fix. | |
| 906 | + jQuery( '#mainwp-pages-table .ui.dropdown' ).dropdown(); | |
| 907 | + jQuery( '#mainwp-pages-table .ui.checkbox' ).checkbox(); | |
| 908 | + mainwp_datatable_fix_menu_overflow('#mainwp-pages-table'); | |
| 909 | + mainwp_table_check_columns_init(); // ajax: to fix checkbox all. | |
| 910 | + }, 1000); | |
| 911 | + }); | |
| 912 | + } catch( err ) { | |
| 913 | + // to fix js error. | |
| 914 | + } | |
| 944 | 915 | |
| 945 | - MainWP_Cache::init_cache( 'Page' ); | |
| 916 | + _init_manage_sites_screen = function() { | |
| 917 | + jQuery( '#mainwp-overview-screen-options-modal input[type=checkbox][id^="mainwp_show_column_"]' ).each( function() { | |
| 918 | + let col_id = jQuery( this ).attr( 'id' ); | |
| 919 | + col_id = col_id.replace( "mainwp_show_column_", "" ); | |
| 920 | + try { | |
| 921 | + $manage_pages_table.column( '#' + col_id ).visible( jQuery(this).is( ':checked' ) ); | |
| 922 | + } catch(err) { | |
| 923 | + // to fix js error. | |
| 924 | + } | |
| 925 | + } ); | |
| 926 | + }; | |
| 927 | + _init_manage_sites_screen(); | |
| 928 | + } ); | |
| 929 | + </script> | |
| 930 | + <?php | |
| 931 | + } | |
| 946 | 932 | |
| 947 | - $data_fields = MainWP_System_Utility::get_default_map_site_fields(); | |
| 933 | + /** | |
| 934 | + * Method render_table_body() | |
| 935 | + * | |
| 936 | + * Render table body. | |
| 937 | + * | |
| 938 | + * @param mixed $keyword Search keywords. | |
| 939 | + * @param mixed $dtsstart Date & time of Session start. | |
| 940 | + * @param mixed $dtsstop Date & time of Session stop. | |
| 941 | + * @param mixed $status Page statuses. | |
| 942 | + * @param mixed $groups Groups to display. | |
| 943 | + * @param mixed $sites Site URLS. | |
| 944 | + * @param string $search_on Site on all sites. Default = all. | |
| 945 | + * @param mixed $clients Selected Clients. | |
| 946 | + * | |
| 947 | + * @return void Output table body. | |
| 948 | + * | |
| 949 | + * @uses \MainWP\Dashboard\MainWP_Cache::init_cache() | |
| 950 | + * @uses \MainWP\Dashboard\MainWP_Cache::add_context() | |
| 951 | + * @uses \MainWP\Dashboard\MainWP_Cache::add_body() | |
| 952 | + * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 953 | + * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 954 | + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_by_group_id() | |
| 955 | + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 956 | + * @uses \MainWP\Dashboard\MainWP_DB::free_result() | |
| 957 | + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 958 | + * @uses \MainWP\Dashboard\MainWP_Utility::map_site() | |
| 959 | + * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 960 | + */ | |
| 961 | + public static function render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on = 'all', $clients = '' ) { // phpcs:ignore -- NOSONAR - complex function. | |
| 948 | 962 | |
| 949 | - $dbwebsites = array(); | |
| 950 | - if ( ! empty( $sites ) ) { | |
| 951 | - foreach ( $sites as $k => $v ) { | |
| 952 | - if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 953 | - $website = MainWP_DB::instance()->get_website_by_id( $v ); | |
| 954 | - if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 955 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 956 | - } | |
| 957 | - } | |
| 958 | - } | |
| 959 | - } | |
| 960 | - if ( ! empty( $groups ) ) { | |
| 961 | - foreach ( $groups as $k => $v ) { | |
| 962 | - if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 963 | - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) ); | |
| 964 | - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 965 | - if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 966 | - continue; | |
| 967 | - } | |
| 968 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 969 | - } | |
| 970 | - MainWP_DB::free_result( $websites ); | |
| 971 | - } | |
| 972 | - } | |
| 973 | - } | |
| 963 | + MainWP_Cache::init_cache( 'Page' ); | |
| 974 | 964 | |
| 975 | - if ( '' !== $clients && is_array( $clients ) ) { | |
| 976 | - $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( | |
| 977 | - $clients, | |
| 978 | - array( | |
| 979 | - 'select_data' => $data_fields, | |
| 980 | - ) | |
| 981 | - ); | |
| 965 | + $data_fields = MainWP_System_Utility::get_default_map_site_fields(); | |
| 982 | 966 | |
| 983 | - foreach ( $websites as $website ) { | |
| 984 | - if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 985 | - continue; | |
| 986 | - } | |
| 987 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( | |
| 988 | - $website, | |
| 989 | - $data_fields | |
| 990 | - ); | |
| 991 | - } | |
| 992 | - } | |
| 967 | + $dbwebsites = array(); | |
| 968 | + if ( ! empty( $sites ) ) { | |
| 969 | + foreach ( $sites as $v ) { | |
| 970 | + if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 971 | + $website = MainWP_DB::instance()->get_website_by_id( $v ); | |
| 972 | + if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 973 | + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 974 | + } | |
| 975 | + } | |
| 976 | + } | |
| 977 | + } | |
| 978 | + if ( ! empty( $groups ) ) { | |
| 979 | + foreach ( $groups as $v ) { | |
| 980 | + if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 981 | + $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) ); | |
| 982 | + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 983 | + if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 984 | + continue; | |
| 985 | + } | |
| 986 | + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 987 | + } | |
| 988 | + MainWP_DB::free_result( $websites ); | |
| 989 | + } | |
| 990 | + } | |
| 991 | + } | |
| 993 | 992 | |
| 994 | - $output = new \stdClass(); | |
| 995 | - $output->errors = array(); | |
| 996 | - $output->pages = 0; | |
| 993 | + if ( '' !== $clients && is_array( $clients ) ) { | |
| 994 | + $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( | |
| 995 | + $clients, | |
| 996 | + array( | |
| 997 | + 'select_data' => $data_fields, | |
| 998 | + ) | |
| 999 | + ); | |
| 997 | 1000 | |
| 998 | - if ( 0 < count( $dbwebsites ) ) { | |
| 999 | - $post_data = array( | |
| 1000 | - 'keyword' => $keyword, | |
| 1001 | - 'dtsstart' => $dtsstart, | |
| 1002 | - 'dtsstop' => $dtsstop, | |
| 1003 | - 'status' => $status, | |
| 1004 | - 'maxRecords' => ( ( false === get_option( 'mainwp_maximumPages' ) ) ? 50 : get_option( 'mainwp_maximumPages' ) ), | |
| 1005 | - 'search_on' => $search_on, | |
| 1006 | - ); | |
| 1001 | + foreach ( $websites as $website ) { | |
| 1002 | + if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1003 | + continue; | |
| 1004 | + } | |
| 1005 | + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( | |
| 1006 | + $website, | |
| 1007 | + $data_fields | |
| 1008 | + ); | |
| 1009 | + } | |
| 1010 | + } | |
| 1007 | 1011 | |
| 1008 | - if ( MainWP_Utility::enabled_wp_seo() ) { | |
| 1009 | - $post_data['WPSEOEnabled'] = 1; | |
| 1010 | - } | |
| 1012 | + $output = new \stdClass(); | |
| 1013 | + $output->errors = array(); | |
| 1014 | + $output->pages = 0; | |
| 1011 | 1015 | |
| 1012 | - /** | |
| 1013 | - * Get all pages data | |
| 1014 | - * | |
| 1015 | - * Set search parameters for the fetch process. | |
| 1016 | - * | |
| 1017 | - * @since 3.4 | |
| 1018 | - */ | |
| 1019 | - $post_data = apply_filters( 'mainwp_get_all_pages_data', $post_data ); | |
| 1020 | - MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_pages', $post_data, array( self::get_class_name(), 'pages_search_handler' ), $output ); | |
| 1021 | - } | |
| 1016 | + if ( ! empty( $dbwebsites ) ) { | |
| 1017 | + $post_data = array( | |
| 1018 | + 'keyword' => $keyword, | |
| 1019 | + 'dtsstart' => $dtsstart, | |
| 1020 | + 'dtsstop' => $dtsstop, | |
| 1021 | + 'status' => $status, | |
| 1022 | + 'maxRecords' => ( ( false === get_option( 'mainwp_maximumPages' ) ) ? 50 : get_option( 'mainwp_maximumPages' ) ), | |
| 1023 | + 'search_on' => $search_on, | |
| 1024 | + ); | |
| 1022 | 1025 | |
| 1023 | - MainWP_Cache::add_context( | |
| 1024 | - 'Page', | |
| 1025 | - array( | |
| 1026 | - 'count' => $output->pages, | |
| 1027 | - 'keyword' => $keyword, | |
| 1028 | - 'dtsstart' => $dtsstart, | |
| 1029 | - 'dtsstop' => $dtsstop, | |
| 1030 | - 'status' => $status, | |
| 1031 | - 'sites' => ( ! empty( $sites ) ) ? $sites : '', | |
| 1032 | - 'groups' => ( ! empty( $groups ) ) ? $groups : '', | |
| 1033 | - 'search_on' => $search_on, | |
| 1034 | - ) | |
| 1035 | - ); | |
| 1026 | + if ( MainWP_Utility::enabled_wp_seo() ) { | |
| 1027 | + $post_data['WPSEOEnabled'] = 1; | |
| 1028 | + } | |
| 1036 | 1029 | |
| 1037 | - if ( empty( $output->pages ) ) { | |
| 1038 | - MainWP_Cache::add_body( 'Page', '' ); | |
| 1039 | - return; | |
| 1040 | - } | |
| 1041 | - } | |
| 1030 | + /** | |
| 1031 | + * Get all pages data | |
| 1032 | + * | |
| 1033 | + * Set search parameters for the fetch process. | |
| 1034 | + * | |
| 1035 | + * @since 3.4 | |
| 1036 | + */ | |
| 1037 | + $post_data = apply_filters( 'mainwp_get_all_pages_data', $post_data ); | |
| 1038 | + MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_pages', $post_data, array( static::get_class_name(), 'pages_search_handler' ), $output ); | |
| 1039 | + } | |
| 1042 | 1040 | |
| 1043 | - /** | |
| 1044 | - * Method get_status() | |
| 1045 | - * | |
| 1046 | - * Get page status. If the page status is | |
| 1047 | - * 'publish' change it to 'Published'. | |
| 1048 | - * | |
| 1049 | - * @param mixed $status Page Status. | |
| 1050 | - * | |
| 1051 | - * @return string Page status. | |
| 1052 | - */ | |
| 1053 | - private static function get_status( $status ) { | |
| 1054 | - if ( 'publish' === $status ) { | |
| 1055 | - return 'Published'; | |
| 1056 | - } | |
| 1057 | - return esc_html( ucfirst( $status ) ); | |
| 1058 | - } | |
| 1041 | + MainWP_Cache::add_context( | |
| 1042 | + 'Page', | |
| 1043 | + array( | |
| 1044 | + 'count' => $output->pages, | |
| 1045 | + 'keyword' => $keyword, | |
| 1046 | + 'dtsstart' => $dtsstart, | |
| 1047 | + 'dtsstop' => $dtsstop, | |
| 1048 | + 'status' => $status, | |
| 1049 | + 'sites' => ( ! empty( $sites ) ) ? $sites : '', | |
| 1050 | + 'groups' => ( ! empty( $groups ) ) ? $groups : '', | |
| 1051 | + 'search_on' => $search_on, | |
| 1052 | + ) | |
| 1053 | + ); | |
| 1059 | 1054 | |
| 1055 | + if ( empty( $output->pages ) ) { | |
| 1056 | + MainWP_Cache::add_body( 'Page', '' ); | |
| 1057 | + } | |
| 1058 | + } | |
| 1060 | 1059 | |
| 1061 | - /** | |
| 1062 | - * Method pages_search_handler() | |
| 1063 | - * | |
| 1064 | - * Pages Search handler. | |
| 1065 | - * | |
| 1066 | - * @param mixed $data Search data. | |
| 1067 | - * @param mixed $website Child Site ID to search on. | |
| 1068 | - * @param mixed $output Search output. | |
| 1069 | - * | |
| 1070 | - * @return void Search box html. | |
| 1071 | - * | |
| 1072 | - * @uses \MainWP\Dashboard\MainWP_Cache::add_body() | |
| 1073 | - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 1074 | - * @uses \MainWP\Dashboard\MainWP_Exception | |
| 1075 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response() | |
| 1076 | - * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 1077 | - * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 1078 | - * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 1079 | - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() | |
| 1080 | - */ | |
| 1081 | - public static function pages_search_handler( $data, $website, &$output ) { // phpcs:ignore -- complex function. | |
| 1082 | - if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) { | |
| 1083 | - return; | |
| 1084 | - } | |
| 1085 | - if ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) { | |
| 1086 | - $result = $results[1]; | |
| 1087 | - $pages = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1060 | + /** | |
| 1061 | + * Method get_status() | |
| 1062 | + * | |
| 1063 | + * Get page status. If the page status is | |
| 1064 | + * 'publish' change it to 'Published'. | |
| 1065 | + * | |
| 1066 | + * @param mixed $status Page Status. | |
| 1067 | + * | |
| 1068 | + * @return string Page status. | |
| 1069 | + */ | |
| 1070 | + private static function get_status( $status ) { | |
| 1071 | + if ( 'publish' === $status ) { | |
| 1072 | + return 'Published'; | |
| 1073 | + } | |
| 1074 | + return esc_html( ucfirst( $status ) ); | |
| 1075 | + } | |
| 1088 | 1076 | |
| 1089 | - if ( is_array( $pages ) && isset( $pages['error'] ) ) { | |
| 1090 | - $output->errors[ $website->id ] = esc_html( $pages['error'] ); | |
| 1091 | - return; | |
| 1092 | - } | |
| 1093 | 1077 | |
| 1094 | - unset( $results ); | |
| 1095 | - foreach ( $pages as $page ) { | |
| 1096 | - $raw_dts = ''; | |
| 1097 | - if ( isset( $page['dts'] ) ) { | |
| 1098 | - $raw_dts = $page['dts']; | |
| 1099 | - if ( ! stristr( $page['dts'], '-' ) ) { | |
| 1100 | - $page['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $page['dts'] ) ); | |
| 1101 | - } | |
| 1102 | - } | |
| 1078 | + /** | |
| 1079 | + * Method pages_search_handler() | |
| 1080 | + * | |
| 1081 | + * Pages Search handler. | |
| 1082 | + * | |
| 1083 | + * @param mixed $data Search data. | |
| 1084 | + * @param mixed $website Child Site ID to search on. | |
| 1085 | + * @param mixed $output Search output. | |
| 1086 | + * | |
| 1087 | + * @return void Search box html. | |
| 1088 | + * | |
| 1089 | + * @uses \MainWP\Dashboard\MainWP_Cache::add_body() | |
| 1090 | + * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 1091 | + * @uses \MainWP\Dashboard\MainWP_Exception | |
| 1092 | + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response() | |
| 1093 | + * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() | |
| 1094 | + * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() | |
| 1095 | + * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() | |
| 1096 | + * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() | |
| 1097 | + */ | |
| 1098 | + public static function pages_search_handler( $data, $website, &$output ) { // phpcs:ignore -- NOSONAR - complex function. | |
| 1099 | + if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) { | |
| 1100 | + return; | |
| 1101 | + } | |
| 1102 | + if ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) { | |
| 1103 | + $result = $results[1]; | |
| 1104 | + $pages = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1103 | 1105 | |
| 1104 | - if ( ! isset( $page['title'] ) || ( '' === $page['title'] ) ) { | |
| 1105 | - $page['title'] = '(No Title)'; | |
| 1106 | - } | |
| 1107 | - ob_start(); | |
| 1108 | - ?> | |
| 1109 | - <tr> | |
| 1110 | - <td class="check-column"><span class="ui checkbox"><input type="checkbox" name="page[]" value="1"></span></td> | |
| 1111 | - <?php | |
| 1112 | - /** | |
| 1113 | - * Action: mainwp_pages_table_column | |
| 1114 | - * | |
| 1115 | - * Adds a new column item in the Manage pages table. | |
| 1116 | - * | |
| 1117 | - * @param array $page Array containing the page data. | |
| 1118 | - * @param array $website Object containing the website data. | |
| 1119 | - * | |
| 1120 | - * @since 4.1 | |
| 1121 | - */ | |
| 1122 | - do_action( 'mainwp_pages_table_column', $page, $website ); | |
| 1123 | - ?> | |
| 1124 | - <td class="page-title column-title"> | |
| 1125 | - <strong> | |
| 1126 | - <abbr title="<?php echo esc_html( $page['title'] ); ?>"> | |
| 1127 | - <?php if ( 'trash' !== $page['status'] ) { ?> | |
| 1128 | - <a class="row-title" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $website->id ); ?>&location=<?php echo esc_attr( base64_encode( 'post.php?post=' . $page['id'] . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" target="_blank" title="Edit '<?php echo esc_html( $page['title'] ); ?>'?"><?php echo esc_html( $page['title'] ); ?></a> | |
| 1129 | - <?php } else { ?> | |
| 1130 | - <?php echo esc_html( $page['title'] ); ?> | |
| 1131 | - <?php } ?> | |
| 1132 | - </abbr> | |
| 1133 | - </strong> | |
| 1106 | + if ( is_array( $pages ) && isset( $pages['error'] ) ) { | |
| 1107 | + $output->errors[ $website->id ] = esc_html( $pages['error'] ); | |
| 1108 | + return; | |
| 1109 | + } | |
| 1134 | 1110 | |
| 1135 | - </td> | |
| 1136 | - <td class="author column-author"> | |
| 1137 | - <?php echo esc_html( $page['author'] ); ?> | |
| 1138 | - </td> | |
| 1139 | - <td class="comments"> | |
| 1140 | - <div class="page-com-count-wrapper"> | |
| 1141 | - <a href="#" title="0 pending" class="post-com-count"> | |
| 1142 | - <span class="comment-count"><abbr title="<?php echo esc_attr( $page['comment_count'] ); ?>"><?php echo esc_html( $page['comment_count'] ); ?></abbr></span> | |
| 1143 | - </a> | |
| 1144 | - </div> | |
| 1145 | - </td> | |
| 1146 | - <td class="date" data-order="<?php echo esc_attr( $raw_dts ); ?>"> | |
| 1147 | - <abbr raw_value="<?php echo esc_attr( $raw_dts ); ?>" title="<?php echo esc_attr( $page['dts'] ); ?>"><?php echo esc_html( $page['dts'] ); ?></abbr> | |
| 1148 | - </td> | |
| 1149 | - <td class="status column-status <?php echo 'trash' === $page['status'] ? 'post-trash' : ''; ?>"><?php echo esc_html( self::get_status( $page['status'] ) ); ?> | |
| 1150 | - </td> | |
| 1151 | - <?php | |
| 1152 | - if ( MainWP_Utility::enabled_wp_seo() ) { | |
| 1153 | - $count_seo_links = null; | |
| 1154 | - $count_seo_linked = null; | |
| 1155 | - $seo_score = ''; | |
| 1156 | - $readability_score = ''; | |
| 1157 | - if ( isset( $page['seo_data'] ) ) { | |
| 1158 | - $seo_data = $page['seo_data']; | |
| 1159 | - $count_seo_links = esc_html( $seo_data['count_seo_links'] ); | |
| 1160 | - $count_seo_linked = esc_html( $seo_data['count_seo_linked'] ); | |
| 1161 | - $seo_score = MainWP_Utility::esc_content( $seo_data['seo_score'], 'mixed' ); | |
| 1162 | - $readability_score = MainWP_Utility::esc_content( $seo_data['readability_score'], 'mixed' ); | |
| 1163 | - } | |
| 1164 | - ?> | |
| 1165 | - <td class="column-seo-links"><abbr raw_value="<?php echo null !== $count_seo_links ? $count_seo_links : -1; ?>" title=""><?php echo null !== $count_seo_links ? $count_seo_links : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1166 | - <td class="column-seo-linked"><abbr raw_value="<?php echo null !== $count_seo_linked ? $count_seo_linked : -1; ?>" title=""><?php echo null !== $count_seo_linked ? $count_seo_linked : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1167 | - <td class="column-seo-score"><abbr raw_value="<?php echo $seo_score ? 1 : 0; ?>" title=""><?php echo $seo_score; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1168 | - <td class="column-seo-readability"><abbr raw_value="<?php echo $readability_score ? 1 : 0; ?>" title=""><?php echo $readability_score; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1169 | - <?php | |
| 1170 | - } | |
| 1171 | - ?> | |
| 1172 | - <td class="website"> | |
| 1173 | - <a href="<?php echo esc_html( $website->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( $website->url ); ?></a> | |
| 1174 | - </td> | |
| 1175 | - <td class="right aligned"> | |
| 1176 | - <input class="pageId" type="hidden" name="id" value="<?php echo intval( $page['id'] ); ?>"/> | |
| 1177 | - <input class="allowedBulkActions" type="hidden" name="allowedBulkActions" value="|get_edit|trash|delete|<?php echo ( 'trash' === $page['status'] ) ? 'restore|' : ''; ?><?php echo ( 'future' === $page['status'] || 'draft' === $page['status'] ) ? 'publish|' : ''; ?>" /> | |
| 1178 | - <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 1111 | + unset( $results ); | |
| 1112 | + foreach ( $pages as $page ) { | |
| 1113 | + $raw_dts = ''; | |
| 1114 | + $copy_permalink = MainWP_Post::get_copyable_permalink( $page, $website ); | |
| 1115 | + if ( isset( $page['dts'] ) ) { | |
| 1116 | + $raw_dts = $page['dts']; | |
| 1117 | + if ( ! stristr( $page['dts'], '-' ) ) { | |
| 1118 | + $page['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $page['dts'] ) ); | |
| 1119 | + } | |
| 1120 | + } | |
| 1179 | 1121 | |
| 1180 | - <div class="ui left pointing dropdown icon mini basic green button" style="z-index: 999"> | |
| 1181 | - <a href="javascript:void(0)"><i class="ellipsis horizontal icon"></i></a> | |
| 1182 | - <div class="menu"> | |
| 1183 | - <?php if ( 'future' === $page['status'] || 'draft' === $page['status'] ) : ?> | |
| 1184 | - <a class="item page_submitpublish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 1185 | - <?php endif; ?> | |
| 1186 | - <?php if ( 'trash' !== $page['status'] ) : ?> | |
| 1187 | - <a class="item page_getedit" href="#"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 1188 | - <?php do_action( 'mainwp_manage_pages_action_item', $page ); ?> | |
| 1189 | - <a class="item page_submitdelete" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 1190 | - <?php endif; ?> | |
| 1191 | - <?php if ( 'publish' === $page['status'] ) { ?> | |
| 1192 | - <a class="item" href="<?php echo esc_html( $website->url ) . ( '/' !== substr( $website->url, -1 ) ? '/' : '' ) . '?p=' . intval( $page['id'] ); ?>" target="_blank"><?php esc_html_e( 'View', 'mainwp' ); ?></a> | |
| 1193 | - <?php } ?> | |
| 1194 | - <?php if ( 'trash' === $page['status'] ) { ?> | |
| 1195 | - <a class="item page_submitrestore" href="#"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a> | |
| 1196 | - <a class="item page_submitdelete_perm" href="#"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a> | |
| 1197 | - <?php } ?> | |
| 1198 | - <a class="item" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . intval( $website->id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="bottom right" data-inverted="" class="open_newwindow_wpadmin ui green basic icon button" target="_blank"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a> | |
| 1199 | - <?php | |
| 1200 | - /** | |
| 1201 | - * Action: mainwp_pages_table_action | |
| 1202 | - * | |
| 1203 | - * Adds a new item in the Actions menu in Manage Pages table. | |
| 1204 | - * | |
| 1205 | - * Suggested HTML markup: | |
| 1206 | - * <a class="item" href="Your custom URL">Your custom label</a> | |
| 1207 | - * | |
| 1208 | - * @param array $post Array containing the page data. | |
| 1209 | - * @param array $website Object containing the website data. | |
| 1210 | - * | |
| 1211 | - * @since 4.1 | |
| 1212 | - */ | |
| 1213 | - do_action( 'mainwp_pages_table_action', $page, $website ); | |
| 1214 | - ?> | |
| 1215 | - </div> | |
| 1216 | - </div> | |
| 1217 | - </td> | |
| 1218 | - </tr> | |
| 1219 | - <?php | |
| 1220 | - $newOutput = ob_get_clean(); | |
| 1221 | - echo $newOutput; // phpcs:ignore WordPress.Security.EscapeOutput | |
| 1222 | - MainWP_Cache::add_body( 'Page', $newOutput ); | |
| 1223 | - ++$output->pages; | |
| 1224 | - } | |
| 1225 | - unset( $pages ); | |
| 1226 | - } else { | |
| 1227 | - $output->errors[ $website->id ] = MainWP_Error_Helper::get_error_message( new MainWP_Exception( 'NOMAINWP', $website->url ) ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 1228 | - } | |
| 1229 | - } | |
| 1122 | + if ( ! isset( $page['title'] ) || ( '' === $page['title'] ) ) { | |
| 1123 | + $page['title'] = '(No Title)'; | |
| 1124 | + } | |
| 1125 | + ob_start(); | |
| 1126 | + ?> | |
| 1127 | + <tr> | |
| 1128 | + <td class="check-column"><span class="ui checkbox"><input type="checkbox" name="page[]" value="1"></span></td> | |
| 1129 | + <?php | |
| 1130 | + /** | |
| 1131 | + * Action: mainwp_pages_table_column | |
| 1132 | + * | |
| 1133 | + * Adds a new column item in the Manage pages table. | |
| 1134 | + * | |
| 1135 | + * @param array $page Array containing the page data. | |
| 1136 | + * @param array $website Object containing the website data. | |
| 1137 | + * | |
| 1138 | + * @since 4.1 | |
| 1139 | + */ | |
| 1140 | + do_action( 'mainwp_pages_table_column', $page, $website ); | |
| 1141 | + ?> | |
| 1142 | + <td class="page-title column-title not-selectable"> | |
| 1143 | + <strong> | |
| 1144 | + <abbr title="<?php echo esc_html( $page['title'] ); ?>"> | |
| 1145 | + <?php if ( 'trash' !== $page['status'] ) { ?> | |
| 1146 | + <a class="row-title" href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); //phpcs:ignore -- ok. ?>&location=<?php echo esc_attr( base64_encode( 'post.php?post=' . $page['id'] . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" target="_blank" title="Edit '<?php echo esc_html( $page['title'] ); ?>'?"><?php echo esc_html( $page['title'] ); ?></a> | |
| 1147 | + <?php } else { ?> | |
| 1148 | + <?php echo esc_html( $page['title'] ); ?> | |
| 1149 | + <?php } ?> | |
| 1150 | + </abbr> | |
| 1151 | + </strong> | |
| 1230 | 1152 | |
| 1231 | - /** | |
| 1232 | - * Method publish() | |
| 1233 | - * | |
| 1234 | - * Publish page. | |
| 1235 | - * | |
| 1236 | - * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1237 | - */ | |
| 1238 | - public static function publish() { | |
| 1239 | - MainWP_Recent_Posts::action( 'publish', 'page' ); | |
| 1240 | - die( wp_json_encode( array( 'result' => 'Page has been published!' ) ) ); | |
| 1241 | - } | |
| 1153 | + </td> | |
| 1154 | + <td class="author column-author not-selectable"> | |
| 1155 | + <?php echo esc_html( $page['author'] ); ?> | |
| 1156 | + </td> | |
| 1157 | + <td class="comments not-selectable"> | |
| 1158 | + <div class="page-com-count-wrapper"> | |
| 1159 | + <a href="#" title="0 pending" class="post-com-count"> | |
| 1160 | + <span class="comment-count"><abbr title="<?php echo esc_attr( $page['comment_count'] ); ?>"><?php echo esc_html( $page['comment_count'] ); ?></abbr></span> | |
| 1161 | + </a> | |
| 1162 | + </div> | |
| 1163 | + </td> | |
| 1164 | + <td class="date not-selectable" data-order="<?php echo esc_attr( $raw_dts ); ?>"> | |
| 1165 | + <abbr raw_value="<?php echo esc_attr( $raw_dts ); ?>" title="<?php echo esc_attr( $page['dts'] ); ?>"><?php echo esc_html( $page['dts'] ); ?></abbr> | |
| 1166 | + </td> | |
| 1167 | + <td class="status column-status not-selectable <?php echo 'trash' === $page['status'] ? 'post-trash' : ''; ?>"><?php echo esc_html( static::get_status( $page['status'] ) ); ?> | |
| 1168 | + </td> | |
| 1169 | + <?php | |
| 1170 | + if ( MainWP_Utility::enabled_wp_seo() ) { | |
| 1171 | + $count_seo_links = null; | |
| 1172 | + $count_seo_linked = null; | |
| 1173 | + $seo_score = ''; | |
| 1174 | + $readability_score = ''; | |
| 1175 | + if ( isset( $page['seo_data'] ) ) { | |
| 1176 | + $seo_data = $page['seo_data']; | |
| 1177 | + $count_seo_links = esc_html( $seo_data['count_seo_links'] ); | |
| 1178 | + $count_seo_linked = esc_html( $seo_data['count_seo_linked'] ); | |
| 1179 | + $seo_score = MainWP_Utility::esc_content( $seo_data['seo_score'], 'mixed' ); | |
| 1180 | + $readability_score = MainWP_Utility::esc_content( $seo_data['readability_score'], 'mixed' ); | |
| 1181 | + } | |
| 1182 | + ?> | |
| 1183 | + <td class="column-seo-links not-selectable"><abbr raw_value="<?php echo null !== $count_seo_links ? $count_seo_links : -1; ?>" title=""><?php echo null !== $count_seo_links ? $count_seo_links : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1184 | + <td class="column-seo-linked not-selectable"><abbr raw_value="<?php echo null !== $count_seo_linked ? $count_seo_linked : -1; ?>" title=""><?php echo null !== $count_seo_linked ? $count_seo_linked : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1185 | + <td class="column-seo-score not-selectable"><abbr raw_value="<?php echo $seo_score ? 1 : 0; ?>" title=""><?php echo $seo_score; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1186 | + <td class="column-seo-readability not-selectable"><abbr raw_value="<?php echo $readability_score ? 1 : 0; ?>" title=""><?php echo $readability_score; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td> | |
| 1187 | + <?php | |
| 1188 | + } | |
| 1189 | + ?> | |
| 1190 | + <td class="website not-selectable"> | |
| 1191 | + <a href="<?php echo esc_html( $website->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( $website->url ); ?></a> | |
| 1192 | + </td> | |
| 1193 | + <td class="right aligned not-selectable"> | |
| 1194 | + <input class="pageId" type="hidden" name="id" value="<?php echo intval( $page['id'] ); ?>"/> | |
| 1195 | + <input class="copyPermalinkValue" type="hidden" value="<?php echo esc_url( $copy_permalink ); ?>"/> | |
| 1196 | + <input class="allowedBulkActions" type="hidden" name="allowedBulkActions" value="|get_edit|trash|delete|<?php echo 'trash' === $page['status'] ? 'restore|' : ''; ?><?php echo 'future' === $page['status'] || 'draft' === $page['status'] ? 'publish|' : ''; ?>" /> | |
| 1197 | + <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/> | |
| 1198 | + <div class="ui right pointing dropdown" style="z-index: 999"> | |
| 1199 | + <a href="javascript:void(0)"><i class="ellipsis vertical icon"></i></a> | |
| 1200 | + <div class="menu"> | |
| 1201 | + <?php if ( 'future' === $page['status'] || 'draft' === $page['status'] ) : ?> | |
| 1202 | + <a class="item page_submitpublish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a> | |
| 1203 | + <?php endif; ?> | |
| 1204 | + <?php if ( 'trash' !== $page['status'] ) : ?> | |
| 1205 | + <a class="item page_getedit" href="#"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> | |
| 1206 | + <?php do_action( 'mainwp_manage_pages_action_item', $page ); ?> | |
| 1207 | + <a class="item page_submitdelete" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a> | |
| 1208 | + <?php endif; ?> | |
| 1209 | + <?php if ( 'publish' === $page['status'] ) { ?> | |
| 1210 | + <a class="item" href="<?php echo esc_html( $website->url ) . ( '/' !== substr( $website->url, -1 ) ? '/' : '' ) . '?p=' . intval( $page['id'] ); ?>" target="_blank"><?php esc_html_e( 'View', 'mainwp' ); ?></a> | |
| 1211 | + <?php } ?> | |
| 1212 | + <?php if ( 'trash' === $page['status'] ) { ?> | |
| 1213 | + <a class="item page_submitrestore" href="#"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a> | |
| 1214 | + <a class="item page_submitdelete_perm" href="#"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a> | |
| 1215 | + <?php } ?> | |
| 1216 | + <a class="item mainwp-copy-row-value" href="#" data-copy-target=".copyPermalinkValue" data-copy-success="<?php echo esc_attr__( 'Copied permalink to clipboard.', 'mainwp' ); ?>"><?php esc_html_e( 'Copy Permalink', 'mainwp' ); ?></a> | |
| 1217 | + <a class="item mainwp-copy-row-value" href="#" data-copy-target=".pageId" data-copy-success="<?php echo esc_attr__( 'Copied ID to clipboard.', 'mainwp' ); ?>"><?php esc_html_e( 'Copy ID', 'mainwp' ); ?></a> | |
| 1218 | + <a class="item" href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); //phpcs:ignore -- ok. ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="bottom right" data-inverted="" class="open_newwindow_wpadmin ui green basic icon button" target="_blank"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a> | |
| 1219 | + <?php | |
| 1220 | + /** | |
| 1221 | + * Action: mainwp_pages_table_action | |
| 1222 | + * | |
| 1223 | + * Adds a new item in the Actions menu in Manage Pages table. | |
| 1224 | + * | |
| 1225 | + * Suggested HTML markup: | |
| 1226 | + * <a class="item" href="Your custom URL">Your custom label</a> | |
| 1227 | + * | |
| 1228 | + * @param array $post Array containing the page data. | |
| 1229 | + * @param array $website Object containing the website data. | |
| 1230 | + * | |
| 1231 | + * @since 4.1 | |
| 1232 | + */ | |
| 1233 | + do_action( 'mainwp_pages_table_action', $page, $website ); | |
| 1234 | + ?> | |
| 1235 | + </div> | |
| 1236 | + </div> | |
| 1237 | + </td> | |
| 1238 | + </tr> | |
| 1239 | + <?php | |
| 1240 | + $newOutput = ob_get_clean(); | |
| 1241 | + echo $newOutput; // phpcs:ignore WordPress.Security.EscapeOutput | |
| 1242 | + MainWP_Cache::add_body( 'Page', $newOutput ); | |
| 1243 | + ++$output->pages; | |
| 1244 | + } | |
| 1245 | + unset( $pages ); | |
| 1246 | + } else { | |
| 1247 | + $output->errors[ $website->id ] = MainWP_Error_Helper::get_error_message( new MainWP_Exception( 'NOMAINWP', $website->url ) ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 1248 | + } | |
| 1249 | + } | |
| 1242 | 1250 | |
| 1243 | - /** | |
| 1244 | - * Method unpublish() | |
| 1245 | - * | |
| 1246 | - * Unpublish page. | |
| 1247 | - * | |
| 1248 | - * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1249 | - */ | |
| 1250 | - public static function unpublish() { | |
| 1251 | - MainWP_Recent_Posts::action( 'unpublish', 'page' ); | |
| 1252 | - die( wp_json_encode( array( 'result' => 'Page has been unpublished!' ) ) ); | |
| 1253 | - } | |
| 1251 | + /** | |
| 1252 | + * Method publish() | |
| 1253 | + * | |
| 1254 | + * Publish page. | |
| 1255 | + * | |
| 1256 | + * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1257 | + */ | |
| 1258 | + public static function publish() { | |
| 1259 | + MainWP_Recent_Posts::action( 'publish', 'page' ); | |
| 1260 | + die( wp_json_encode( array( 'result' => 'Page has been published!' ) ) ); | |
| 1261 | + } | |
| 1254 | 1262 | |
| 1255 | - /** | |
| 1256 | - * Method trash() | |
| 1257 | - * | |
| 1258 | - * Trash page. | |
| 1259 | - * | |
| 1260 | - * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1261 | - */ | |
| 1262 | - public static function trash() { | |
| 1263 | - MainWP_Recent_Posts::action( 'trash', 'page' ); | |
| 1264 | - die( wp_json_encode( array( 'result' => 'Page has been moved to trash!' ) ) ); | |
| 1265 | - } | |
| 1263 | + /** | |
| 1264 | + * Method unpublish() | |
| 1265 | + * | |
| 1266 | + * Unpublish page. | |
| 1267 | + * | |
| 1268 | + * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1269 | + */ | |
| 1270 | + public static function unpublish() { | |
| 1271 | + MainWP_Recent_Posts::action( 'unpublish', 'page' ); | |
| 1272 | + die( wp_json_encode( array( 'result' => 'Page has been unpublished!' ) ) ); | |
| 1273 | + } | |
| 1266 | 1274 | |
| 1267 | - /** | |
| 1268 | - * Method delete() | |
| 1269 | - * | |
| 1270 | - * Delete page. | |
| 1271 | - * | |
| 1272 | - * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1273 | - */ | |
| 1274 | - public static function delete() { | |
| 1275 | - MainWP_Recent_Posts::action( 'delete', 'page' ); | |
| 1276 | - die( wp_json_encode( array( 'result' => 'Page has been permanently deleted!' ) ) ); | |
| 1277 | - } | |
| 1275 | + /** | |
| 1276 | + * Method trash() | |
| 1277 | + * | |
| 1278 | + * Trash page. | |
| 1279 | + * | |
| 1280 | + * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1281 | + */ | |
| 1282 | + public static function trash() { | |
| 1283 | + MainWP_Recent_Posts::action( 'trash', 'page' ); | |
| 1284 | + die( wp_json_encode( array( 'result' => 'Page has been moved to trash!' ) ) ); | |
| 1285 | + } | |
| 1278 | 1286 | |
| 1279 | - /** | |
| 1280 | - * Method restore() | |
| 1281 | - * | |
| 1282 | - * Restore page. | |
| 1283 | - * | |
| 1284 | - * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1285 | - */ | |
| 1286 | - public static function restore() { | |
| 1287 | - MainWP_Recent_Posts::action( 'restore', 'page' ); | |
| 1288 | - die( wp_json_encode( array( 'result' => 'Page has been restored!' ) ) ); | |
| 1289 | - } | |
| 1287 | + /** | |
| 1288 | + * Method delete() | |
| 1289 | + * | |
| 1290 | + * Delete page. | |
| 1291 | + * | |
| 1292 | + * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1293 | + */ | |
| 1294 | + public static function delete() { | |
| 1295 | + MainWP_Recent_Posts::action( 'delete', 'page' ); | |
| 1296 | + die( wp_json_encode( array( 'result' => 'Page has been permanently deleted!' ) ) ); | |
| 1297 | + } | |
| 1290 | 1298 | |
| 1291 | - /** | |
| 1292 | - * Method render_bulk_add() | |
| 1293 | - * | |
| 1294 | - * Check if user has the rights to manage pages, | |
| 1295 | - * grab the post id and pass onto render_addedit() method. | |
| 1296 | - * | |
| 1297 | - * @return void | |
| 1298 | - */ | |
| 1299 | - public static function render_bulk_add() { | |
| 1300 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) { | |
| 1301 | - mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); | |
| 1302 | - return; | |
| 1303 | - } | |
| 1299 | + /** | |
| 1300 | + * Method restore() | |
| 1301 | + * | |
| 1302 | + * Restore page. | |
| 1303 | + * | |
| 1304 | + * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action() | |
| 1305 | + */ | |
| 1306 | + public static function restore() { | |
| 1307 | + MainWP_Recent_Posts::action( 'restore', 'page' ); | |
| 1308 | + die( wp_json_encode( array( 'result' => 'Page has been restored!' ) ) ); | |
| 1309 | + } | |
| 1304 | 1310 | |
| 1305 | - /** | |
| 1306 | - * MainWP default post to edit. | |
| 1307 | - * | |
| 1308 | - * @global string | |
| 1309 | - */ | |
| 1310 | - global $_mainwp_default_post_to_edit; | |
| 1311 | + /** | |
| 1312 | + * Method render_bulk_add() | |
| 1313 | + * | |
| 1314 | + * Check if user has the rights to manage pages, | |
| 1315 | + * grab the post id and pass onto render_addedit() method. | |
| 1316 | + * | |
| 1317 | + * @return void | |
| 1318 | + */ | |
| 1319 | + public static function render_bulk_add() { | |
| 1320 | + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { | |
| 1321 | + \mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); | |
| 1322 | + return; | |
| 1323 | + } | |
| 1311 | 1324 | |
| 1312 | - $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; | |
| 1313 | - self::render_addedit( $post_id, 'BulkAdd' ); | |
| 1314 | - } | |
| 1325 | + /** | |
| 1326 | + * MainWP default post to edit. | |
| 1327 | + * | |
| 1328 | + * @global string | |
| 1329 | + */ | |
| 1330 | + global $_mainwp_default_post_to_edit; | |
| 1315 | 1331 | |
| 1316 | - /** | |
| 1317 | - * Method render_bulk_edit() | |
| 1318 | - * | |
| 1319 | - * Check if user has the rights to manage pages, | |
| 1320 | - * grab the post id and pass onto render_addedit() method. | |
| 1321 | - * | |
| 1322 | - * @return void | |
| 1323 | - */ | |
| 1324 | - public static function render_bulk_edit() { | |
| 1325 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) { | |
| 1326 | - mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); | |
| 1327 | - return; | |
| 1328 | - } | |
| 1332 | + $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; | |
| 1333 | + static::render_addedit( $post_id, 'BulkAdd' ); | |
| 1334 | + } | |
| 1329 | 1335 | |
| 1330 | - $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1331 | - self::render_addedit( $post_id, 'BulkEdit' ); | |
| 1332 | - } | |
| 1336 | + /** | |
| 1337 | + * Method render_bulk_edit() | |
| 1338 | + * | |
| 1339 | + * Check if user has the rights to manage pages, | |
| 1340 | + * grab the post id and pass onto render_addedit() method. | |
| 1341 | + * | |
| 1342 | + * @return void | |
| 1343 | + */ | |
| 1344 | + public static function render_bulk_edit() { | |
| 1345 | + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_pages' ) ) { | |
| 1346 | + \mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) ); | |
| 1347 | + return; | |
| 1348 | + } | |
| 1333 | 1349 | |
| 1334 | - /** | |
| 1335 | - * Method render_addedit() | |
| 1336 | - * | |
| 1337 | - * Render bulk posts page. | |
| 1338 | - * | |
| 1339 | - * @param mixed $post_id Post ID. | |
| 1340 | - * @param mixed $what Current page. | |
| 1341 | - * | |
| 1342 | - * @return void Display page header, bulkpost body & footer. | |
| 1343 | - * | |
| 1344 | - * @uses \MainWP\Dashboard\MainWP_Post::render_bulkpost() | |
| 1345 | - */ | |
| 1346 | - public static function render_addedit( $post_id, $what ) { | |
| 1347 | - self::render_header( $what, $post_id ); | |
| 1348 | - MainWP_Post::render_bulkpost( $post_id, 'bulkpage' ); | |
| 1349 | - self::render_footer( $what ); | |
| 1350 | - } | |
| 1350 | + $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1351 | + static::render_addedit( $post_id, 'BulkEdit' ); | |
| 1352 | + } | |
| 1351 | 1353 | |
| 1352 | - /** | |
| 1353 | - * Method posting() | |
| 1354 | - * | |
| 1355 | - * Render Posting page modal window. | |
| 1356 | - * | |
| 1357 | - * @return void Posting page modal window html. | |
| 1358 | - * | |
| 1359 | - * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 1360 | - * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 1361 | - * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() | |
| 1362 | - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 1363 | - * @uses \MainWP\Dashboard\MainWP_DB::free_result() | |
| 1364 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze() | |
| 1365 | - * @uses \MainWP\Dashboard\MainWP_Bulk_Add::get_class_name() | |
| 1366 | - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 1367 | - * @uses \MainWP\Dashboard\MainWP_Utility::map_site() | |
| 1368 | - */ | |
| 1369 | - public static function posting() { // phpcs:ignore -- current complexity required to achieve desired results. Pull request solutions appreciated. | |
| 1370 | - $succes_message = ''; | |
| 1371 | - $post_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1354 | + /** | |
| 1355 | + * Method render_addedit() | |
| 1356 | + * | |
| 1357 | + * Render bulk posts page. | |
| 1358 | + * | |
| 1359 | + * @param mixed $post_id Post ID. | |
| 1360 | + * @param mixed $what Current page. | |
| 1361 | + * | |
| 1362 | + * @return void Display page header, bulkpost body & footer. | |
| 1363 | + * | |
| 1364 | + * @uses \MainWP\Dashboard\MainWP_Post::render_bulkpost() | |
| 1365 | + */ | |
| 1366 | + public static function render_addedit( $post_id, $what ) { | |
| 1367 | + static::render_header( $what, $post_id ); | |
| 1368 | + MainWP_Post::render_bulkpost( $post_id, 'bulkpage' ); | |
| 1369 | + static::render_footer( $what ); | |
| 1370 | + } | |
| 1372 | 1371 | |
| 1373 | - if ( ! isset( $_GET['posting_nonce'] ) || ( isset( $_GET['posting_nonce'] ) && ! wp_verify_nonce( sanitize_key( $_POST['posting_nonce'] ), 'posting_nonce_' . $post_id ) ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 1374 | - wp_die( 'Invalid request!' ); | |
| 1375 | - } | |
| 1372 | + /** | |
| 1373 | + * Method posting() | |
| 1374 | + * | |
| 1375 | + * Render Posting page modal window. | |
| 1376 | + * | |
| 1377 | + * @return void Posting page modal window html. | |
| 1378 | + * | |
| 1379 | + * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed() | |
| 1380 | + * @uses \MainWP\Dashboard\MainWP_DB::query() | |
| 1381 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() | |
| 1382 | + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 1383 | + * @uses \MainWP\Dashboard\MainWP_DB::free_result() | |
| 1384 | + * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze() | |
| 1385 | + * @uses \MainWP\Dashboard\MainWP_Bulk_Add::get_class_name() | |
| 1386 | + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 1387 | + * @uses \MainWP\Dashboard\MainWP_Utility::map_site() | |
| 1388 | + */ | |
| 1389 | + public static function posting() { // phpcs:ignore -- NOSONAR - current complexity required to achieve desired results. Pull request solutions appreciated. | |
| 1390 | + $succes_message = ''; | |
| 1391 | + $post_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1376 | 1392 | |
| 1377 | - $edit_id = 0; | |
| 1378 | - if ( $post_id ) { | |
| 1379 | - $edit_id = get_post_meta( $post_id, '_mainwp_edit_post_id', true ); | |
| 1380 | - $edit_id = intval( $edit_id ); | |
| 1381 | - if ( $edit_id ) { | |
| 1382 | - $succes_message = esc_html__( 'Page has been updated successfully', 'mainwp' ); | |
| 1383 | - } else { | |
| 1384 | - $succes_message = esc_html__( 'New page created', 'mainwp' ); | |
| 1385 | - } | |
| 1386 | - } | |
| 1387 | - $data_fields = MainWP_System_Utility::get_default_map_site_fields(); | |
| 1388 | - ?> | |
| 1389 | - <div class="ui modal" id="mainwp-posting-page-modal"> | |
| 1390 | - <i class="close icon"></i> | |
| 1391 | - <div class="header"><?php $edit_id ? esc_html_e( 'Edit Page', 'mainwp' ) : esc_html_e( 'New Page', 'mainwp' ); ?></div> | |
| 1392 | - <div class="scrolling content"> | |
| 1393 | - <?php | |
| 1394 | - /** | |
| 1395 | - * Before Page post action | |
| 1396 | - * | |
| 1397 | - * Fires right before posting the 'bulkpage' to child sites. | |
| 1398 | - * | |
| 1399 | - * @param int $_GET['id'] Page ID. | |
| 1400 | - * | |
| 1401 | - * @since Unknown | |
| 1402 | - */ | |
| 1403 | - do_action( 'mainwp_bulkpage_before_post', $post_id ); | |
| 1393 | + 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 | |
| 1394 | + wp_die( 'Invalid request!' ); | |
| 1395 | + } | |
| 1404 | 1396 | |
| 1405 | - $skip_post = false; | |
| 1406 | - if ( $post_id ) { | |
| 1407 | - if ( 'yes' === get_post_meta( $post_id, '_mainwp_skip_posting', true ) ) { | |
| 1408 | - $skip_post = true; | |
| 1409 | - wp_delete_post( $post_id, true ); | |
| 1410 | - } | |
| 1411 | - } | |
| 1397 | + $edit_id = 0; | |
| 1398 | + if ( $post_id ) { | |
| 1399 | + $edit_id = get_post_meta( $post_id, '_mainwp_edit_post_id', true ); | |
| 1400 | + $edit_id = intval( $edit_id ); | |
| 1401 | + if ( $edit_id ) { | |
| 1402 | + $succes_message = esc_html__( 'Page has been updated successfully', 'mainwp' ); | |
| 1403 | + } else { | |
| 1404 | + $succes_message = esc_html__( 'New page created', 'mainwp' ); | |
| 1405 | + } | |
| 1406 | + } | |
| 1407 | + $data_fields = MainWP_System_Utility::get_default_map_site_fields(); | |
| 1408 | + ?> | |
| 1409 | + <div class="ui modal" id="mainwp-posting-page-modal"> | |
| 1410 | + <i class="close icon"></i> | |
| 1411 | + <div class="header"><?php $edit_id ? esc_html_e( 'Edit Page', 'mainwp' ) : esc_html_e( 'New Page', 'mainwp' ); ?></div> | |
| 1412 | + <div class="scrolling content"> | |
| 1413 | + <?php | |
| 1414 | + /** | |
| 1415 | + * Before Page post action | |
| 1416 | + * | |
| 1417 | + * Fires right before posting the 'bulkpage' to child sites. | |
| 1418 | + * | |
| 1419 | + * @param int $_GET['id'] Page ID. | |
| 1420 | + * | |
| 1421 | + * @since Unknown | |
| 1422 | + */ | |
| 1423 | + do_action( 'mainwp_bulkpage_before_post', $post_id ); | |
| 1412 | 1424 | |
| 1413 | - if ( ! $skip_post ) { | |
| 1414 | - if ( $post_id ) { | |
| 1415 | - $id = $post_id; | |
| 1416 | - $_post = get_post( $id ); | |
| 1417 | - if ( $_post ) { | |
| 1418 | - $selected_by = get_post_meta( $id, '_selected_by', true ); | |
| 1419 | - $val = get_post_meta( $id, '_selected_sites', true ); | |
| 1420 | - $selected_sites = MainWP_System_Utility::maybe_unserialyze( $val ); | |
| 1421 | - $val = get_post_meta( $id, '_selected_groups', true ); | |
| 1422 | - $selected_groups = MainWP_System_Utility::maybe_unserialyze( $val ); | |
| 1423 | - $selected_clients = get_post_meta( $id, '_selected_clients', true ); | |
| 1424 | - $post_slug = base64_decode( get_post_meta( $id, '_slug', true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1425 | - $post_custom = get_post_custom( $id ); | |
| 1426 | - include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; | |
| 1427 | - $featured_image_id = get_post_thumbnail_id( $id ); | |
| 1428 | - $post_featured_image = null; | |
| 1429 | - $featured_image_data = null; | |
| 1430 | - $mainwp_upload_dir = wp_upload_dir(); | |
| 1425 | + $skip_post = false; | |
| 1426 | + if ( $post_id && 'yes' === get_post_meta( $post_id, '_mainwp_skip_posting', true ) ) { | |
| 1427 | + $skip_post = true; | |
| 1428 | + wp_delete_post( $post_id, true ); | |
| 1429 | + } | |
| 1431 | 1430 | |
| 1432 | - // to fix. | |
| 1433 | - $post_status = $_post->post_status; | |
| 1434 | - if ( 'publish' === $post_status ) { | |
| 1435 | - $post_status = get_post_meta( $id, '_edit_post_status', true ); | |
| 1436 | - } | |
| 1431 | + if ( ! $skip_post ) { | |
| 1432 | + if ( $post_id ) { | |
| 1433 | + $id = $post_id; | |
| 1434 | + $_post = get_post( $id ); | |
| 1435 | + if ( $_post ) { | |
| 1436 | + $selected_by = get_post_meta( $id, '_selected_by', true ); | |
| 1437 | + $val = get_post_meta( $id, '_selected_sites', true ); | |
| 1438 | + $selected_sites = MainWP_System_Utility::maybe_unserialyze( $val ); | |
| 1439 | + $val = get_post_meta( $id, '_selected_groups', true ); | |
| 1440 | + $selected_groups = MainWP_System_Utility::maybe_unserialyze( $val ); | |
| 1441 | + $selected_clients = get_post_meta( $id, '_selected_clients', true ); | |
| 1442 | + $post_slug = base64_decode( get_post_meta( $id, '_slug', true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1443 | + $post_custom = get_post_custom( $id ); | |
| 1444 | + include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; // NOSONAR - WP compatible. | |
| 1445 | + $featured_image_id = get_post_thumbnail_id( $id ); | |
| 1446 | + $post_featured_image = null; | |
| 1447 | + $featured_image_data = null; | |
| 1448 | + $mainwp_upload_dir = wp_upload_dir(); | |
| 1437 | 1449 | |
| 1438 | - /** | |
| 1439 | - * Page status | |
| 1440 | - * | |
| 1441 | - * Sets page status when posting 'bulkpage' to child sites. | |
| 1442 | - * | |
| 1443 | - * @param int $id Page ID. | |
| 1444 | - * | |
| 1445 | - * @since Unknown | |
| 1446 | - */ | |
| 1447 | - $post_status = apply_filters( 'mainwp_posting_bulkpost_post_status', $post_status, $id ); | |
| 1450 | + // to fix. | |
| 1451 | + $post_status = $_post->post_status; | |
| 1452 | + if ( 'publish' === $post_status ) { | |
| 1453 | + $post_status = get_post_meta( $id, '_edit_post_status', true ); | |
| 1454 | + } | |
| 1448 | 1455 | |
| 1449 | - $new_post = array( | |
| 1450 | - 'post_title' => $_post->post_title, | |
| 1451 | - 'post_content' => $_post->post_content, | |
| 1452 | - 'post_status' => $post_status, | |
| 1453 | - 'post_date' => $_post->post_date, | |
| 1454 | - 'post_date_gmt' => $_post->post_date_gmt, | |
| 1455 | - 'post_type' => 'page', | |
| 1456 | - 'post_name' => $post_slug, | |
| 1457 | - 'post_excerpt' => MainWP_Utility::esc_content( $_post->post_excerpt, 'mixed' ), | |
| 1458 | - 'post_password' => $_post->post_password, | |
| 1459 | - 'comment_status' => $_post->comment_status, | |
| 1460 | - 'ping_status' => $_post->ping_status, | |
| 1461 | - 'mainwp_post_id' => $_post->ID, | |
| 1462 | - ); | |
| 1456 | + /** | |
| 1457 | + * Page status | |
| 1458 | + * | |
| 1459 | + * Sets page status when posting 'bulkpage' to child sites. | |
| 1460 | + * | |
| 1461 | + * @param int $id Page ID. | |
| 1462 | + * | |
| 1463 | + * @since Unknown | |
| 1464 | + */ | |
| 1465 | + $post_status = apply_filters( 'mainwp_posting_bulkpost_post_status', $post_status, $id ); | |
| 1463 | 1466 | |
| 1464 | - if ( ! empty( $featured_image_id ) ) { | |
| 1465 | - $img = wp_get_attachment_image_src( $featured_image_id, 'full' ); | |
| 1466 | - $post_featured_image = $img[0]; | |
| 1467 | - $attachment = get_post( $featured_image_id ); | |
| 1468 | - $featured_image_data = array( | |
| 1469 | - 'alt' => get_post_meta( $featured_image_id, '_wp_attachment_image_alt', true ), | |
| 1470 | - 'caption' => MainWP_Utility::esc_content( $attachment->post_excerpt, 'mixed' ), | |
| 1471 | - 'description' => $attachment->post_content, | |
| 1472 | - 'title' => htmlspecialchars( $attachment->post_title ), | |
| 1473 | - ); | |
| 1474 | - } | |
| 1467 | + $new_post = array( | |
| 1468 | + 'post_title' => $_post->post_title, | |
| 1469 | + 'post_content' => $_post->post_content, | |
| 1470 | + 'post_status' => $post_status, | |
| 1471 | + 'post_date' => $_post->post_date, | |
| 1472 | + 'post_date_gmt' => $_post->post_date_gmt, | |
| 1473 | + 'post_type' => 'page', | |
| 1474 | + 'post_name' => $post_slug, | |
| 1475 | + 'post_excerpt' => MainWP_Utility::esc_content( $_post->post_excerpt, 'mixed' ), | |
| 1476 | + 'post_password' => $_post->post_password, | |
| 1477 | + 'comment_status' => $_post->comment_status, | |
| 1478 | + 'ping_status' => $_post->ping_status, | |
| 1479 | + 'mainwp_post_id' => $_post->ID, | |
| 1480 | + ); | |
| 1475 | 1481 | |
| 1476 | - $galleries = get_post_gallery( $id, false ); | |
| 1477 | - $post_gallery_images = array(); | |
| 1482 | + if ( ! empty( $featured_image_id ) ) { | |
| 1483 | + $img = wp_get_attachment_image_src( $featured_image_id, 'full' ); | |
| 1484 | + $post_featured_image = $img[0]; | |
| 1485 | + $attachment = get_post( $featured_image_id ); | |
| 1486 | + $featured_image_data = array( | |
| 1487 | + 'alt' => get_post_meta( $featured_image_id, '_wp_attachment_image_alt', true ), | |
| 1488 | + 'caption' => MainWP_Utility::esc_content( $attachment->post_excerpt, 'mixed' ), | |
| 1489 | + 'description' => $attachment->post_content, | |
| 1490 | + 'title' => htmlspecialchars( $attachment->post_title ), | |
| 1491 | + ); | |
| 1492 | + } | |
| 1478 | 1493 | |
| 1479 | - if ( is_array( $galleries ) && isset( $galleries['ids'] ) ) { | |
| 1480 | - $attached_images = explode( ',', $galleries['ids'] ); | |
| 1481 | - foreach ( $attached_images as $attachment_id ) { | |
| 1482 | - $attachment = get_post( $attachment_id ); | |
| 1483 | - if ( $attachment ) { | |
| 1484 | - $post_gallery_images[] = array( | |
| 1485 | - 'id' => $attachment_id, | |
| 1486 | - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), | |
| 1487 | - 'caption' => MainWP_Utility::esc_content( $attachment->post_excerpt, 'mixed' ), | |
| 1488 | - 'description' => $attachment->post_content, | |
| 1489 | - 'src' => $attachment->guid, | |
| 1490 | - 'title' => htmlspecialchars( $attachment->post_title ), | |
| 1491 | - ); | |
| 1492 | - } | |
| 1493 | - } | |
| 1494 | - } | |
| 1494 | + $galleries = get_post_galleries( $id, false ); | |
| 1495 | + $post_gallery_images = array(); | |
| 1495 | 1496 | |
| 1496 | - $dbwebsites = array(); | |
| 1497 | - if ( 'site' === $selected_by ) { | |
| 1498 | - foreach ( $selected_sites as $k ) { | |
| 1499 | - if ( MainWP_Utility::ctype_digit( $k ) ) { | |
| 1500 | - $website = MainWP_DB::instance()->get_website_by_id( $k ); | |
| 1501 | - if ( '' === $website->sync_errors && ! MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1502 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 1503 | - } | |
| 1504 | - } | |
| 1505 | - } | |
| 1506 | - } elseif ( 'client' === $selected_by ) { | |
| 1507 | - if ( is_array( $selected_clients ) ) { | |
| 1508 | - $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( | |
| 1509 | - $selected_clients, | |
| 1510 | - array( | |
| 1511 | - 'select_data' => $data_fields, | |
| 1512 | - ) | |
| 1513 | - ); | |
| 1514 | - if ( $websites ) { | |
| 1515 | - foreach ( $websites as $website ) { | |
| 1516 | - if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1517 | - continue; | |
| 1518 | - } | |
| 1519 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 1520 | - } | |
| 1521 | - } | |
| 1522 | - } | |
| 1523 | - } elseif ( 'group' === $selected_by ) { | |
| 1524 | - foreach ( $selected_groups as $k ) { | |
| 1525 | - if ( MainWP_Utility::ctype_digit( $k ) ) { | |
| 1526 | - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $k ) ); | |
| 1527 | - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 1528 | - if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1529 | - continue; | |
| 1530 | - } | |
| 1531 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 1532 | - } | |
| 1533 | - MainWP_DB::free_result( $websites ); | |
| 1534 | - } | |
| 1535 | - } | |
| 1536 | - } | |
| 1497 | + if ( is_array( $galleries ) ) { | |
| 1498 | + foreach ( $galleries as $gallery ) { | |
| 1499 | + if ( isset( $gallery['ids'] ) ) { | |
| 1500 | + $attached_images = explode( ',', $gallery['ids'] ); | |
| 1501 | + foreach ( $attached_images as $attachment_id ) { | |
| 1502 | + $attachment = get_post( $attachment_id ); | |
| 1503 | + if ( $attachment ) { | |
| 1504 | + $post_gallery_images[] = array( | |
| 1505 | + 'id' => $attachment_id, | |
| 1506 | + 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), | |
| 1507 | + 'caption' => MainWP_Utility::esc_content( $attachment->post_excerpt, 'mixed' ), | |
| 1508 | + 'description' => $attachment->post_content, | |
| 1509 | + 'src' => $attachment->guid, | |
| 1510 | + 'image_url' => wp_get_attachment_image_url( $attachment_id ), // to fix src/guid missing the file name. | |
| 1511 | + 'title' => htmlspecialchars( $attachment->post_title ), | |
| 1512 | + ); | |
| 1513 | + } | |
| 1514 | + } | |
| 1515 | + } | |
| 1516 | + } | |
| 1517 | + } | |
| 1537 | 1518 | |
| 1538 | - $output = new \stdClass(); | |
| 1539 | - $output->ok = array(); | |
| 1540 | - $output->errors = array(); | |
| 1541 | - $startTime = time(); | |
| 1519 | + $dbwebsites = array(); | |
| 1520 | + if ( 'site' === $selected_by ) { | |
| 1521 | + foreach ( $selected_sites as $k ) { | |
| 1522 | + if ( MainWP_Utility::ctype_digit( $k ) ) { | |
| 1523 | + $website = MainWP_DB::instance()->get_website_by_id( $k ); | |
| 1524 | + if ( '' === $website->sync_errors && ! MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1525 | + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 1526 | + } | |
| 1527 | + } | |
| 1528 | + } | |
| 1529 | + } elseif ( 'client' === $selected_by ) { | |
| 1530 | + if ( is_array( $selected_clients ) ) { | |
| 1531 | + $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( | |
| 1532 | + $selected_clients, | |
| 1533 | + array( | |
| 1534 | + 'select_data' => $data_fields, | |
| 1535 | + ) | |
| 1536 | + ); | |
| 1537 | + if ( $websites ) { | |
| 1538 | + foreach ( $websites as $website ) { | |
| 1539 | + if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1540 | + continue; | |
| 1541 | + } | |
| 1542 | + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 1543 | + } | |
| 1544 | + } | |
| 1545 | + } | |
| 1546 | + } elseif ( 'group' === $selected_by ) { | |
| 1547 | + foreach ( $selected_groups as $k ) { | |
| 1548 | + if ( MainWP_Utility::ctype_digit( $k ) ) { | |
| 1549 | + $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $k ) ); | |
| 1550 | + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 1551 | + if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1552 | + continue; | |
| 1553 | + } | |
| 1554 | + $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); | |
| 1555 | + } | |
| 1556 | + MainWP_DB::free_result( $websites ); | |
| 1557 | + } | |
| 1558 | + } | |
| 1559 | + } | |
| 1542 | 1560 | |
| 1543 | - if ( 0 < count( $dbwebsites ) ) { | |
| 1561 | + $output = new \stdClass(); | |
| 1562 | + $output->ok = array(); | |
| 1563 | + $output->errors = array(); | |
| 1544 | 1564 | |
| 1545 | - // prepare $post_custom values. | |
| 1546 | - $new_post_custom = array(); | |
| 1547 | - foreach ( $post_custom as $meta_key => $meta_values ) { | |
| 1548 | - $new_meta_values = array(); | |
| 1549 | - foreach ( $meta_values as $key_value => $meta_value ) { | |
| 1550 | - if ( is_serialized( $meta_value ) ) { | |
| 1551 | - $meta_value = unserialize( $meta_value ); // phpcs:ignore -- internal value safe. | |
| 1552 | - } | |
| 1553 | - $new_meta_values[ $key_value ] = $meta_value; | |
| 1554 | - } | |
| 1555 | - $new_post_custom[ $meta_key ] = $new_meta_values; | |
| 1556 | - } | |
| 1565 | + if ( ! empty( $dbwebsites ) ) { | |
| 1557 | 1566 | |
| 1558 | - $post_data = array( | |
| 1559 | - 'new_post' => base64_encode( wp_json_encode( $new_post ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1560 | - 'post_custom' => base64_encode( wp_json_encode( $new_post_custom ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1561 | - 'post_featured_image' => ( null !== $post_featured_image ) ? base64_encode( $post_featured_image ) : null, // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1562 | - 'post_gallery_images' => base64_encode( wp_json_encode( $post_gallery_images ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1563 | - 'mainwp_upload_dir' => base64_encode( wp_json_encode( $mainwp_upload_dir ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1564 | - 'featured_image_data' => ( null !== $featured_image_data ) ? base64_encode( wp_json_encode( $featured_image_data ) ) : null, // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1565 | - ); | |
| 1567 | + // prepare $post_custom values. | |
| 1568 | + $new_post_custom = array(); | |
| 1569 | + foreach ( $post_custom as $meta_key => $meta_values ) { | |
| 1570 | + $new_meta_values = array(); | |
| 1571 | + foreach ( $meta_values as $key_value => $meta_value ) { | |
| 1572 | + if ( is_serialized( $meta_value ) ) { | |
| 1573 | + $meta_value = unserialize( $meta_value ); // phpcs:ignore -- internal value safe. | |
| 1574 | + } | |
| 1575 | + $new_meta_values[ $key_value ] = $meta_value; | |
| 1576 | + } | |
| 1577 | + $new_post_custom[ $meta_key ] = $new_meta_values; | |
| 1578 | + } | |
| 1566 | 1579 | |
| 1567 | - /** | |
| 1568 | - * Posting new page | |
| 1569 | - * | |
| 1570 | - * Sets Page data to post to child sites. | |
| 1571 | - * | |
| 1572 | - * @param int $id Page ID. | |
| 1573 | - * | |
| 1574 | - * @since Unknown | |
| 1575 | - */ | |
| 1576 | - $post_data = apply_filters( 'mainwp_bulkpage_posting', $post_data, $id ); | |
| 1577 | - MainWP_Connect::fetch_urls_authed( $dbwebsites, 'newpost', $post_data, array( MainWP_Bulk_Add::get_class_name(), 'posting_bulk_handler' ), $output ); | |
| 1578 | - } | |
| 1580 | + $post_data = array( | |
| 1581 | + 'new_post' => base64_encode( wp_json_encode( $new_post ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1582 | + 'post_custom' => base64_encode( wp_json_encode( $new_post_custom ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1583 | + 'post_featured_image' => ( null !== $post_featured_image ) ? base64_encode( $post_featured_image ) : null, // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1584 | + 'post_gallery_images' => base64_encode( wp_json_encode( $post_gallery_images ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1585 | + 'mainwp_upload_dir' => base64_encode( wp_json_encode( $mainwp_upload_dir ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1586 | + 'featured_image_data' => ( null !== $featured_image_data ) ? base64_encode( wp_json_encode( $featured_image_data ) ) : null, // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. | |
| 1587 | + ); | |
| 1579 | 1588 | |
| 1580 | - foreach ( $dbwebsites as $website ) { | |
| 1581 | - if ( isset( $output->ok[ $website->id ] ) && ( 1 === (int) $output->ok[ $website->id ] ) && ( isset( $output->added_id[ $website->id ] ) ) ) { | |
| 1582 | - $links = isset( $output->link[ $website->id ] ) ? $output->link[ $website->id ] : null; | |
| 1589 | + /** | |
| 1590 | + * Posting new page | |
| 1591 | + * | |
| 1592 | + * Sets Page data to post to child sites. | |
| 1593 | + * | |
| 1594 | + * @param int $id Page ID. | |
| 1595 | + * | |
| 1596 | + * @since Unknown | |
| 1597 | + */ | |
| 1598 | + $post_data = apply_filters( 'mainwp_bulkpage_posting', $post_data, $id ); | |
| 1599 | + MainWP_Connect::fetch_urls_authed( $dbwebsites, 'newpost', $post_data, array( MainWP_Bulk_Add::get_class_name(), 'posting_bulk_handler' ), $output ); | |
| 1600 | + } | |
| 1583 | 1601 | |
| 1584 | - do_action_deprecated( 'mainwp-post-posting-page', array( $website, $output->added_id[ $website->id ], $links ), '4.0.7.2', 'mainwp_post_posting_page' ); // @deprecated Use 'mainwp_post_posting_page' instead. | |
| 1585 | - do_action_deprecated( 'mainwp-bulkposting-done', array( $_post, $website, $output ), '4.0.7.2', 'mainwp_bulkposting_done' ); // @deprecated Use 'mainwp_bulkposting_done' instead. | |
| 1602 | + foreach ( $dbwebsites as $website ) { | |
| 1603 | + if ( isset( $output->ok[ $website->id ] ) && ( 1 === (int) $output->ok[ $website->id ] ) && ( isset( $output->added_id[ $website->id ] ) ) ) { | |
| 1604 | + $links = isset( $output->link[ $website->id ] ) ? $output->link[ $website->id ] : null; | |
| 1586 | 1605 | |
| 1587 | - /** | |
| 1588 | - * Posting page | |
| 1589 | - * | |
| 1590 | - * Fires while posting page. | |
| 1591 | - * | |
| 1592 | - * @param object $website Object containing child site data. | |
| 1593 | - * @param int $output->added_id[ $website->id ] Child site ID. | |
| 1594 | - * @param array $links Links. | |
| 1595 | - * | |
| 1596 | - * @since Unknown | |
| 1597 | - */ | |
| 1598 | - do_action( 'mainwp_post_posting_page', $website, $output->added_id[ $website->id ], $links ); | |
| 1606 | + do_action_deprecated( 'mainwp-post-posting-page', array( $website, $output->added_id[ $website->id ], $links ), '4.0.7.2', 'mainwp_post_posting_page' ); // @deprecated Use 'mainwp_post_posting_page' instead. NOSONAR - not IP. | |
| 1607 | + do_action_deprecated( 'mainwp-bulkposting-done', array( $_post, $website, $output ), '4.0.7.2', 'mainwp_bulkposting_done' ); // @deprecated Use 'mainwp_bulkposting_done' instead. NOSONAR - not IP. | |
| 1599 | 1608 | |
| 1600 | - /** | |
| 1601 | - * Posting page completed | |
| 1602 | - * | |
| 1603 | - * Fires after the page posting process is completed. | |
| 1604 | - * | |
| 1605 | - * @param array $_post Array containing the post data. | |
| 1606 | - * @param object $website Object containing child site data. | |
| 1607 | - * @param array $output Output data. | |
| 1608 | - * | |
| 1609 | - * @since Unknown | |
| 1610 | - */ | |
| 1611 | - do_action( 'mainwp_bulkposting_done', $_post, $website, $output ); | |
| 1612 | - } | |
| 1613 | - } | |
| 1609 | + /** | |
| 1610 | + * Posting page | |
| 1611 | + * | |
| 1612 | + * Fires while posting page. | |
| 1613 | + * | |
| 1614 | + * @param object $website Object containing child site data. | |
| 1615 | + * @param int $output->added_id[ $website->id ] Child site ID. | |
| 1616 | + * @param array $links Links. | |
| 1617 | + * | |
| 1618 | + * @since Unknown | |
| 1619 | + */ | |
| 1620 | + do_action( 'mainwp_post_posting_page', $website, $output->added_id[ $website->id ], $links ); | |
| 1614 | 1621 | |
| 1615 | - /** | |
| 1616 | - * After posting a new page | |
| 1617 | - * | |
| 1618 | - * Sets data after the posting process to show the process feedback. | |
| 1619 | - * | |
| 1620 | - * @param array $_post Array containing the post data. | |
| 1621 | - * @param array $dbwebsites Array containing processed sites. | |
| 1622 | - * @param array $output Output data. | |
| 1623 | - * | |
| 1624 | - * @since Unknown | |
| 1625 | - */ | |
| 1626 | - $after_posting = apply_filters_deprecated( 'mainwp-after-posting-bulkpage-result', array( false, $_post, $dbwebsites, $output ), '4.0.7.2', 'mainwp_after_posting_bulkpage_result' ); // @deprecated Use 'mainwp_after_posting_bulkpage_result' instead. | |
| 1627 | - $after_posting = apply_filters( 'mainwp_after_posting_bulkpage_result', $after_posting, $_post, $dbwebsites, $output ); | |
| 1622 | + /** | |
| 1623 | + * Posting page completed | |
| 1624 | + * | |
| 1625 | + * Fires after the page posting process is completed. | |
| 1626 | + * | |
| 1627 | + * @param array $_post Array containing the post data. | |
| 1628 | + * @param object $website Object containing child site data. | |
| 1629 | + * @param array $output Output data. | |
| 1630 | + * | |
| 1631 | + * @since Unknown | |
| 1632 | + */ | |
| 1633 | + do_action( 'mainwp_bulkposting_done', $_post, $website, $output ); | |
| 1634 | + } | |
| 1635 | + } | |
| 1628 | 1636 | |
| 1629 | - if ( false === $after_posting ) { | |
| 1630 | - ?> | |
| 1631 | - <div class="ui relaxed list"> | |
| 1632 | - <?php foreach ( $dbwebsites as $website ) { ?> | |
| 1633 | - <div class="item"><a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a> | |
| 1634 | - : <?php echo ( isset( $output->ok[ $website->id ] ) && 1 === (int) $output->ok[ $website->id ] ? esc_html( $succes_message ) . ' <a href="' . esc_html( $output->link[ $website->id ] ) . '" class="mainwp-may-hide-referrer" target="_blank">View Page</a>' : 'ERROR: ' . $output->errors[ $website->id ] ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 1635 | - </div> | |
| 1636 | - <?php } ?> | |
| 1637 | - </div> | |
| 1637 | + /** | |
| 1638 | + * After posting a new page | |
| 1639 | + * | |
| 1640 | + * Sets data after the posting process to show the process feedback. | |
| 1641 | + * | |
| 1642 | + * @param array $_post Array containing the post data. | |
| 1643 | + * @param array $dbwebsites Array containing processed sites. | |
| 1644 | + * @param array $output Output data. | |
| 1645 | + * | |
| 1646 | + * @since Unknown | |
| 1647 | + */ | |
| 1648 | + $after_posting = apply_filters_deprecated( 'mainwp-after-posting-bulkpage-result', array( false, $_post, $dbwebsites, $output ), '4.0.7.2', 'mainwp_after_posting_bulkpage_result' ); // @deprecated Use 'mainwp_after_posting_bulkpage_result' instead. NOSONAR - not IP. | |
| 1649 | + $after_posting = apply_filters( 'mainwp_after_posting_bulkpage_result', $after_posting, $_post, $dbwebsites, $output ); | |
| 1638 | 1650 | |
| 1639 | - <?php | |
| 1640 | - } | |
| 1651 | + if ( false === $after_posting ) { | |
| 1652 | + ?> | |
| 1653 | + <div class="ui relaxed list"> | |
| 1654 | + <?php foreach ( $dbwebsites as $website ) { ?> | |
| 1655 | + <div class="item"><a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a> | |
| 1656 | + : <?php echo isset( $output->ok[ $website->id ] ) && 1 === (int) $output->ok[ $website->id ] ? esc_html( $succes_message ) . ' <a href="' . esc_html( $output->link[ $website->id ] ) . '" class="mainwp-may-hide-referrer" target="_blank">View Page</a>' : 'ERROR: ' . $output->errors[ $website->id ]; // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 1657 | + </div> | |
| 1658 | + <?php } ?> | |
| 1659 | + </div> | |
| 1641 | 1660 | |
| 1642 | - $do_not_del = get_post_meta( $id, '_bulkpost_do_not_del', true ); | |
| 1661 | + <?php | |
| 1662 | + } | |
| 1643 | 1663 | |
| 1644 | - if ( 'yes' !== $do_not_del ) { | |
| 1645 | - wp_delete_post( $id, true ); | |
| 1646 | - } | |
| 1664 | + $do_not_del = get_post_meta( $id, '_bulkpost_do_not_del', true ); | |
| 1647 | 1665 | |
| 1648 | - $countSites = 0; | |
| 1649 | - $countRealItems = 0; | |
| 1650 | - foreach ( $dbwebsites as $website ) { | |
| 1651 | - if ( isset( $output->ok[ $website->id ] ) && 1 === (int) $output->ok[ $website->id ] ) { | |
| 1652 | - ++$countSites; | |
| 1653 | - ++$countRealItems; | |
| 1654 | - } | |
| 1655 | - } | |
| 1656 | - } | |
| 1657 | - } else { | |
| 1658 | - ?> | |
| 1659 | - <div class="error"> | |
| 1660 | - <p><strong>ERROR</strong>: <?php esc_html_e( 'An undefined error occured.', 'mainwp' ); ?></p> | |
| 1661 | - </div> | |
| 1662 | - <?php | |
| 1663 | - } | |
| 1664 | - } | |
| 1665 | - ?> | |
| 1666 | - </div> | |
| 1667 | - <div class="actions"> | |
| 1668 | - <a href="admin.php?page=PageBulkAdd" class="ui green button"><?php esc_html_e( 'New Page', 'mainwp' ); ?></a> | |
| 1669 | - </div> | |
| 1670 | - </div> | |
| 1671 | - <div class="ui active inverted dimmer" id="mainwp-posting-running"> | |
| 1672 | - <div class="ui indeterminate large text loader"><?php esc_html_e( 'Running ...', 'mainwp' ); ?></div> | |
| 1673 | - </div> | |
| 1674 | - <script type="text/javascript"> | |
| 1675 | - jQuery( document ).ready( function () { | |
| 1676 | - jQuery( "#mainwp-posting-running" ).hide(); | |
| 1677 | - jQuery( "#mainwp-posting-page-modal" ).modal( { | |
| 1678 | - closable: true, | |
| 1679 | - onHide: function() { | |
| 1680 | - location.href = 'admin.php?page=PageBulkManage'; | |
| 1681 | - } | |
| 1682 | - } ).modal( 'show' ); | |
| 1683 | - } ); | |
| 1684 | - </script> | |
| 1685 | - <?php | |
| 1686 | - } | |
| 1666 | + if ( 'yes' !== $do_not_del ) { | |
| 1667 | + wp_delete_post( $id, true ); | |
| 1668 | + } | |
| 1687 | 1669 | |
| 1688 | - /** | |
| 1689 | - * Method mainwp_help_content() | |
| 1690 | - * | |
| 1691 | - * Hook the section help content to the Help Sidebar element | |
| 1692 | - * | |
| 1693 | - * @return void Help section html. | |
| 1694 | - */ | |
| 1695 | - public static function mainwp_help_content() { | |
| 1696 | - if ( isset( $_GET['page'] ) && ( 'PageBulkManage' === $_GET['page'] || 'PageBulkAdd' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1697 | - ?> | |
| 1698 | - <p><?php esc_html_e( 'If you need help with managing pages, please review following help documents', 'mainwp' ); ?></p> | |
| 1699 | - <div class="ui relaxed bulleted list"> | |
| 1700 | - <div class="item"><a href="https://kb.mainwp.com/docs/manage-pages/" target="_blank">Manage Pages</a> <i class="external alternate icon"></i></div> | |
| 1701 | - <div class="item"><a href="https://kb.mainwp.com/docs/create-a-new-page/" target="_blank">Create a New Page</a> <i class="external alternate icon"></i></div> | |
| 1702 | - <div class="item"><a href="https://kb.mainwp.com/docs/edit-an-existing-page/" target="_blank">Edit an Existing Page</a> <i class="external alternate icon"></i></div> | |
| 1703 | - <div class="item"><a href="https://kb.mainwp.com/docs/change-status-of-an-existing-page/" target="_blank">Change Status of an Existing Page</a> <i class="external alternate icon"></i></div> | |
| 1704 | - <div class="item"><a href="https://kb.mainwp.com/docs/view-an-existing-page/" target="_blank">View an Existing Page</a> <i class="external alternate icon"></i></div> | |
| 1705 | - <div class="item"><a href="https://kb.mainwp.com/docs/delete-pages/" target="_blank">Delete Page(s)</a> <i class="external alternate icon"></i></div> | |
| 1706 | - <?php | |
| 1707 | - /** | |
| 1708 | - * Action: mainwp_pages_help_item | |
| 1709 | - * | |
| 1710 | - * Fires at the bottom of the help articles list in the Help sidebar on the Pages page. | |
| 1711 | - * | |
| 1712 | - * Suggested HTML markup: | |
| 1713 | - * | |
| 1714 | - * <div class="item"><a href="Your custom URL">Your custom text</a></div> | |
| 1715 | - * | |
| 1716 | - * @since 4.1 | |
| 1717 | - */ | |
| 1718 | - do_action( 'mainwp_pages_help_item' ); | |
| 1719 | - ?> | |
| 1720 | - </div> | |
| 1721 | - <?php | |
| 1722 | - } | |
| 1723 | - } | |
| 1670 | + $countSites = 0; | |
| 1671 | + $countRealItems = 0; | |
| 1672 | + foreach ( $dbwebsites as $website ) { | |
| 1673 | + if ( isset( $output->ok[ $website->id ] ) && 1 === (int) $output->ok[ $website->id ] ) { | |
| 1674 | + ++$countSites; | |
| 1675 | + ++$countRealItems; | |
| 1676 | + } | |
| 1677 | + } | |
| 1678 | + } | |
| 1679 | + } else { | |
| 1680 | + ?> | |
| 1681 | + <div class="error"> | |
| 1682 | + <p><strong>ERROR</strong>: <?php esc_html_e( 'An undefined error occurred.', 'mainwp' ); ?></p> | |
| 1683 | + </div> | |
| 1684 | + <?php | |
| 1685 | + } | |
| 1686 | + } | |
| 1687 | + ?> | |
| 1688 | + </div> | |
| 1689 | + <div class="actions"> | |
| 1690 | + <?php do_action( 'mainwp_pages_posting_popup_actions', $id ); ?> | |
| 1691 | + <a href="admin.php?page=PageBulkAdd" class="ui green button new-bulk-page"><?php esc_html_e( 'New Page', 'mainwp' ); ?></a> | |
| 1692 | + </div> | |
| 1693 | + </div> | |
| 1694 | + <div class="ui active dimmer" id="mainwp-posting-running"> | |
| 1695 | + <div class="ui double text loader"><?php esc_html_e( 'Running ...', 'mainwp' ); ?></div> | |
| 1696 | + </div> | |
| 1697 | + <script type="text/javascript"> | |
| 1698 | + jQuery( document ).ready( function () { | |
| 1699 | + jQuery( "#mainwp-posting-running" ).hide(); | |
| 1700 | + jQuery( "#mainwp-posting-page-modal" ).modal( { | |
| 1701 | + closable: true, | |
| 1702 | + onHide: function() { | |
| 1703 | + mainwp_forceReload('admin.php?page=PageBulkManage'); | |
| 1704 | + } | |
| 1705 | + } ).modal( 'show' ); | |
| 1706 | + } ); | |
| 1707 | + </script> | |
| 1708 | + <?php | |
| 1709 | + } | |
| 1710 | + | |
| 1711 | + /** | |
| 1712 | + * Method mainwp_help_content() | |
| 1713 | + * | |
| 1714 | + * Creates the MainWP Help Documentation List for the help component in the sidebar. | |
| 1715 | + */ | |
| 1716 | + public static function mainwp_help_content() { | |
| 1717 | + if ( isset( $_GET['page'] ) && ( 'PageBulkManage' === $_GET['page'] || 'PageBulkAdd' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1718 | + ?> | |
| 1719 | + <p><?php esc_html_e( 'If you need help with managing pages, please review following help documents', 'mainwp' ); ?></p> | |
| 1720 | + <div class="ui list"> | |
| 1721 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/content/manage-pages" target="_blank">Manage Pages</a></div> | |
| 1722 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/content/manage-pages#create-a-new-page" target="_blank">Create a New Page</a></div> | |
| 1723 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/content/manage-pages#edit-an-existing-page" target="_blank">Edit an Existing Page</a></div> | |
| 1724 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/content/manage-pages#view-a-page-on-its-site" target="_blank">View an Existing Page</a></div> | |
| 1725 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/content/manage-pages#delete-pages" target="_blank">Delete Page(s)</a></div> | |
| 1726 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/content/manage-pages#restore-a-page" target="_blank">Restore Page(s)</a></div> | |
| 1727 | + <?php | |
| 1728 | + /** | |
| 1729 | + * Action: mainwp_pages_help_item | |
| 1730 | + * | |
| 1731 | + * Fires at the bottom of the help articles list in the Help sidebar on the Pages page. | |
| 1732 | + * | |
| 1733 | + * Suggested HTML markup: | |
| 1734 | + * | |
| 1735 | + * <div class="item"><a href="Your custom URL">Your custom text</a></div> | |
| 1736 | + * | |
| 1737 | + * @since 4.1 | |
| 1738 | + */ | |
| 1739 | + do_action( 'mainwp_pages_help_item' ); | |
| 1740 | + ?> | |
| 1741 | + </div> | |
| 1742 | + <?php | |
| 1743 | + } | |
| 1744 | + } | |
| 1724 | 1745 | } |