PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.3
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 5.2.2 5.3 All 153 releases
mainwp / pages / page-mainwp-page.php

page-mainwp-page.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.3, at pages/page-mainwp-page.php

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