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