PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.3.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.3.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
mainwp / pages / page-mainwp-page.php

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

1,726 lines 63.4 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 {
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( 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' ) );
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( self::get_class_name(), 'render_footer' ) );
76 add_action( 'mainwp_pagefooter_page', array( self::get_class_name(), 'render_footer' ) );
77
78 add_action( 'mainwp_help_sidebar_content', array( self::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( 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' ) );
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( self::get_class_name(), 'render_bulk_add' ) );
96 add_action( 'load-' . $_page, array( self::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( self::get_class_name(), 'render_bulk_edit' ) );
99 add_action( 'load-' . $_page, array( self::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( self::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.
112 self::$subPages = apply_filters( 'mainwp_getsubpages_page', $sub_pages );
113
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 }
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() {
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 }
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( self::get_class_name(), 'admin_head' ) );
263 add_filter( 'hidden_columns', array( self::get_class_name(), 'get_hidden_columns' ), 10, 3 );
264 add_action( 'mainwp_screen_options_modal_bottom', array( self::get_class_name(), 'hook_screen_options_modal_bottom' ), 10, 2 );
265 }
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 = self::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 ) {
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_have_right( 'dashboard', 'manage_pages' ) ) {
381 $renderItems[] = array(
382 'title' => esc_html__( 'Manage Pages', 'mainwp' ),
383 'href' => 'admin.php?page=PageBulkManage',
384 'active' => ( 'BulkManage' === $shownPage ) ? true : false,
385 );
386 if ( 'BulkEdit' === $shownPage ) {
387 $renderItems[] = array(
388 'title' => esc_html__( 'Edit Page', 'mainwp' ),
389 'href' => 'admin.php?page=PageBulkEdit&post_id=' . esc_attr( $post_id ),
390 'active' => true,
391 );
392 }
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( self::$subPages ) && is_array( self::$subPages ) ) {
404 foreach ( self::$subPages as $subPage ) {
405 if ( MainWP_Menu::is_disable_menu_item( 3, 'Page' . $subPage['slug'] ) ) {
406 continue;
407 }
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_have_right( '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 ( is_array( $cachedSearch['sites'] ) ) {
455 $selected_sites = $cachedSearch['sites'];
456 } elseif ( is_array( $cachedSearch['groups'] ) ) {
457 $selected_groups = $cachedSearch['groups'];
458 } elseif ( is_array( $cachedSearch['clients'] ) ) {
459 $selected_clients = $cachedSearch['clients'];
460 }
461 }
462
463 ?>
464 <?php self::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 self::render_table( true ); ?>
527 </div>
528 </div>
529 <div class="mainwp-side-content mainwp-no-padding">
530 <?php
531 /**
532 * Action: mainwp_manage_pages_sidebar_top
533 *
534 * Fires at the top of the sidebar on Manage pages.
535 *
536 * @since 4.1
537 */
538 do_action( 'mainwp_manage_pages_sidebar_top' );
539 ?>
540 <div class="mainwp-select-sites ui accordion mainwp-sidebar-accordion">
541 <?php
542 /**
543 * Action: mainwp_manage_pages_before_select_sites
544 *
545 * Fires before the Select Sites section on Manage pages.
546 *
547 * @since 4.1
548 */
549 do_action( 'mainwp_manage_pages_before_select_sites' );
550 ?>
551 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Sites', 'mainwp' ); ?></div>
552 <div class="content active">
553 <?php
554 $sel_params = array(
555 'selected_sites' => $selected_sites,
556 'selected_groups' => $selected_groups,
557 'selected_clients' => $selected_clients,
558 'class' => 'mainwp_select_sites_box_left',
559 'show_client' => true,
560 );
561 MainWP_UI_Select_Sites::select_sites_box( $sel_params );
562 ?>
563 </div>
564 <?php
565 /**
566 * Action: mainwp_manage_pages_after_select_sites
567 *
568 * Fires after the Select Sites section on Manage pages.
569 *
570 * @since 4.1
571 */
572 do_action( 'mainwp_manage_pages_after_select_sites' );
573 ?>
574 </div>
575 <div class="ui fitted divider"></div>
576 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
577 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Select Status', 'mainwp' ); ?></div>
578 <div class="content active">
579 <?php
580 /**
581 * Action: mainwp_manage_pages_before_search_options
582 *
583 * Fires before the Search Options on Manage Pages.
584 *
585 * @since 4.1
586 */
587 do_action( 'mainwp_manage_pages_before_search_options' );
588 ?>
589 <div class="ui mini form">
590 <div class="field">
591 <select multiple="" class="ui fluid dropdown" id="mainwp_page_search_type">
592 <option value=""><?php esc_html_e( 'Select status', 'mainwp' ); ?></option>
593 <option value="publish" selected><?php esc_html_e( 'Published', 'mainwp' ); ?></option>
594 <option value="pending"><?php esc_html_e( 'Pending', 'mainwp' ); ?></option>
595 <option value="private"><?php esc_html_e( 'Private', 'mainwp' ); ?></option>
596 <option value="future"><?php esc_html_e( 'Scheduled', 'mainwp' ); ?></option>
597 <option value="draft"><?php esc_html_e( 'Draft', 'mainwp' ); ?></option>
598 <option value="trash"><?php esc_html_e( 'Trash', 'mainwp' ); ?></option>
599 </select>
600 </div>
601 </div>
602 </div>
603 </div>
604 <div class="ui fitted divider"></div>
605 <div class="mainwp-search-options ui accordion mainwp-sidebar-accordion">
606 <div class="title active"><i class="dropdown icon"></i> <?php esc_html_e( 'Search Options', 'mainwp' ); ?></div>
607 <div class="content active">
608 <?php self::render_search_options(); ?>
609 <?php
610 /**
611 * Action: mainwp_manage_pages_after_search_options
612 *
613 * Fires after the Search Options on Manage Pages.
614 *
615 * @since 4.1
616 */
617 do_action( 'mainwp_manage_pages_after_search_options' );
618 ?>
619 </div>
620 </div>
621 <div class="ui fitted divider"></div>
622 <div class="mainwp-search-submit">
623 <?php
624 /**
625 * Action: mainwp_manage_pages_before_submit_button
626 *
627 * Fires before the Submit Button on Manage Pages.
628 *
629 * @since 4.1
630 */
631 do_action( 'mainwp_manage_pages_before_submit_button' );
632 $is_demo = MainWP_Demo_Handle::is_demo_mode();
633 if ( $is_demo ) {
634 MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<input type="button" class="ui green big fluid button disabled" disabled="disabled" value="' . esc_attr__( 'Show Pages', 'mainwp' ) . '"/>' );
635 } else {
636 ?>
637 <input type="button" name="mainwp_show_pages" id="mainwp_show_pages" class="ui green big fluid button" value="<?php esc_attr_e( 'Show Pages', 'mainwp' ); ?>"/>
638 <?php
639 }
640 /**
641 * Action: mainwp_manage_pages_after_submit_button
642 *
643 * Fires after the Submit Button on Manage Pages.
644 *
645 * @since 4.1
646 */
647 do_action( 'mainwp_manage_pages_after_submit_button' );
648 ?>
649 </div>
650 <?php
651 /**
652 * Action: mainwp_manage_pages_sidebar_bottom
653 *
654 * Fires at the bottom of the sidebar on Manage pages.
655 *
656 * @since 4.1
657 */
658 do_action( 'mainwp_manage_pages_sidebar_bottom' );
659 ?>
660 </div>
661 <div class="ui hidden clearing divider"></div>
662 </div>
663 <?php
664 }
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 ) && 0 < count( $statuses ) ) {
742 $status = '';
743 foreach ( $statuses as $st ) {
744 $status .= "'" . esc_html( $st ) . "',";
745 }
746 $status = rtrim( $status, ',' );
747 ?>
748 <script type="text/javascript">
749 jQuery( document ).ready( function () {
750 jQuery( '#mainwp_page_search_type' ).dropdown( 'set selected',[<?php echo $status; //phpcs:ignore -- safe output. ?>] );
751 } );
752 </script>
753 <?php
754 }
755 }
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 string $groups Groups to display.
768 * @param string $sites Site URLS.
769 * @param string $search_on Site on all sites. Default = all.
770 * @param mixed $clients Selected Clients.
771 *
772 * @return void Page table html.
773 *
774 * @uses \MainWP\Dashboard\MainWP_Cache::echo_body()
775 * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo()
776 */
777 public static function render_table( $cached, $keyword = '', $dtsstart = '', $dtsstop = '', $status = '', $groups = '', $sites = '', $search_on = 'all', $clients = '' ) {
778 ?>
779 <div id="mainwp_pages_error"></div>
780 <div id="mainwp-loading-pages-row" style="display: none;">
781 <div class="ui active inverted dimmer">
782 <div class="ui indeterminate large text loader"><?php esc_html_e( 'Loading Pages...', 'mainwp' ); ?></div>
783 </div>
784 </div>
785 <?php
786 /**
787 * Action: mainwp_before_pages_table
788 *
789 * Fires before the Manage Pages table.
790 *
791 * @since 4.1
792 */
793 do_action( 'mainwp_before_pages_table' );
794 ?>
795 <table id="mainwp-pages-table" class="ui unstackable single line table" style="width:100%">
796 <thead>
797 <tr>
798 <th class="no-sort check-column collapsing"><span class="ui checkbox"><input id="cb-select-all-top" type="checkbox" /></span></th>
799 <?php
800 /**
801 * Action: mainwp_pages_table_header
802 *
803 * Adds new column header to the Manage pages table.
804 *
805 * @since 4.1
806 */
807 do_action( 'mainwp_pages_table_header' );
808 ?>
809 <th id="title"><?php esc_html_e( 'Title', 'mainwp' ); ?></th>
810 <th id="author" class="min-tablet"><?php esc_html_e( 'Author', 'mainwp' ); ?></th>
811 <th id="comments"><i class="comment icon"></i></th>
812 <th id="date" class="min-tablet"><?php esc_html_e( 'Last Modified', 'mainwp' ); ?></th>
813 <th id="status"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
814 <?php if ( MainWP_Utility::enabled_wp_seo() ) : ?>
815 <th id="seo-links"><span title="<?php echo esc_attr__( 'Number of internal links in this page', 'mainwp' ); ?>"><?php esc_html_e( 'Links', 'mainwp' ); ?></span></th>
816 <th id="seo-linked"><span title="<?php echo esc_attr__( 'Number of internal links linking to this page', 'mainwp' ); ?>"><?php esc_html_e( 'Linked', 'mainwp' ); ?></span></th>
817 <th id="seo-score"><span title="<?php echo esc_attr__( 'SEO score', 'mainwp' ); ?>"><?php esc_html_e( 'SEO score', 'mainwp' ); ?></span></th>
818 <th id="seo-readability"><span title="<?php echo esc_attr__( 'Readability score', 'mainwp' ); ?>"><?php esc_html_e( 'Readability score', 'mainwp' ); ?></span></th>
819 <?php endif; ?>
820 <th id="website" class="min-tablet"><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
821 <th id="pages-actions" class="no-sort min-tablet"></th>
822 </tr>
823 </thead>
824 <tbody id="mainwp-posts-list">
825 <?php
826 if ( $cached ) {
827 MainWP_Cache::echo_body( 'Page' );
828 } else {
829 self::render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on, $clients );
830 }
831 ?>
832 </tbody>
833 </table>
834 <?php
835 /**
836 * Action: mainwp_after_pages_table
837 *
838 * Fires after the Manage Pages table.
839 *
840 * @since 4.1
841 */
842 do_action( 'mainwp_after_pages_table' );
843
844 $table_features = array(
845 'searching' => 'true',
846 'paging' => 'true',
847 'info' => 'true',
848 'stateSave' => 'true',
849 'scrollX' => 'true',
850 'colReorder' => '{ fixedColumnsLeft: 1, fixedColumnsRight: 1 }',
851 'order' => '[]',
852 'responsive' => 'true',
853 );
854
855 /**
856 * Filter: mainwp_pages_table_fatures
857 *
858 * Filters the Manage Pages table features.
859 *
860 * @since 4.1
861 */
862 $table_features = apply_filters( 'mainwp_pages_table_fatures', $table_features );
863 ?>
864 <script type="text/javascript">
865 var responsive = <?php echo esc_html( $table_features['responsive'] ); ?>;
866 if( jQuery( window ).width() > 1140 ) {
867 responsive = false;
868 }
869 jQuery( document ).ready( function () {
870 try {
871 jQuery("#mainwp-pages-table").DataTable().destroy(); // fixed re-initialize datatable issue.
872 $manage_pages_table = jQuery( '#mainwp-pages-table' ).DataTable( {
873 "responsive" : responsive,
874 "searching" : <?php echo esc_html( $table_features['searching'] ); ?>,
875 "colReorder" : <?php echo esc_html( $table_features['colReorder'] ); ?>,
876 "stateSave": <?php echo esc_html( $table_features['stateSave'] ); ?>,
877 "paging": <?php echo esc_html( $table_features['paging'] ); ?>,
878 "info": <?php echo esc_html( $table_features['info'] ); ?>,
879 "order": <?php echo esc_html( $table_features['order'] ); ?>,
880 "scrollX" : <?php echo esc_html( $table_features['scrollX'] ); ?>,
881 "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
882 "columnDefs": [ {
883 "targets": 'no-sort',
884 "orderable": false
885 } ],
886 "language" : { "emptyTable": "<?php esc_html_e( 'Use the search options to find the page you want to manage.', 'mainwp' ); ?>" },
887 "preDrawCallback": function( settings ) {
888 jQuery( '#mainwp_pages_wrap_table table .ui.dropdown' ).dropdown();
889 jQuery( '#mainwp_pages_wrap_table table .ui.checkbox' ).checkbox();
890 mainwp_datatable_fix_menu_overflow();
891 mainwp_table_check_columns_init(); // ajax: to fix checkbox all.
892 }
893 } );
894 } catch( err ) {
895 // to fix js error.
896 }
897
898 _init_manage_sites_screen = function() {
899 jQuery( '#mainwp-overview-screen-options-modal input[type=checkbox][id^="mainwp_show_column_"]' ).each( function() {
900 var col_id = jQuery( this ).attr( 'id' );
901 col_id = col_id.replace( "mainwp_show_column_", "" );
902 try {
903 $manage_pages_table.column( '#' + col_id ).visible( jQuery(this).is( ':checked' ) );
904 } catch(err) {
905 // to fix js error.
906 }
907 } );
908 };
909 _init_manage_sites_screen();
910 } );
911 </script>
912 <?php
913 }
914
915 /**
916 * Method render_table_body()
917 *
918 * Render table body.
919 *
920 * @param mixed $keyword Search keywords.
921 * @param mixed $dtsstart Date & time of Session start.
922 * @param mixed $dtsstop Date & time of Session stop.
923 * @param mixed $status Page statuses.
924 * @param mixed $groups Groups to display.
925 * @param mixed $sites Site URLS.
926 * @param string $search_on Site on all sites. Default = all.
927 * @param mixed $clients Selected Clients.
928 *
929 * @return void Output table body.
930 *
931 * @uses \MainWP\Dashboard\MainWP_Cache::init_cache()
932 * @uses \MainWP\Dashboard\MainWP_Cache::add_context()
933 * @uses \MainWP\Dashboard\MainWP_Cache::add_body()
934 * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed()
935 * @uses \MainWP\Dashboard\MainWP_DB::query()
936 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_by_group_id()
937 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
938 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
939 * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
940 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
941 * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo()
942 */
943 public static function render_table_body( $keyword, $dtsstart, $dtsstop, $status, $groups, $sites, $search_on = 'all', $clients = '' ) { // phpcs:ignore -- complex function.
944
945 MainWP_Cache::init_cache( 'Page' );
946
947 $data_fields = MainWP_System_Utility::get_default_map_site_fields();
948
949 $dbwebsites = array();
950 if ( ! empty( $sites ) ) {
951 foreach ( $sites as $k => $v ) {
952 if ( MainWP_Utility::ctype_digit( $v ) ) {
953 $website = MainWP_DB::instance()->get_website_by_id( $v );
954 if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
955 $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields );
956 }
957 }
958 }
959 }
960 if ( ! empty( $groups ) ) {
961 foreach ( $groups as $k => $v ) {
962 if ( MainWP_Utility::ctype_digit( $v ) ) {
963 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) );
964 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
965 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
966 continue;
967 }
968 $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields );
969 }
970 MainWP_DB::free_result( $websites );
971 }
972 }
973 }
974
975 if ( '' !== $clients && is_array( $clients ) ) {
976 $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids(
977 $clients,
978 array(
979 'select_data' => $data_fields,
980 )
981 );
982
983 foreach ( $websites as $website ) {
984 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
985 continue;
986 }
987 $dbwebsites[ $website->id ] = MainWP_Utility::map_site(
988 $website,
989 $data_fields
990 );
991 }
992 }
993
994 $output = new \stdClass();
995 $output->errors = array();
996 $output->pages = 0;
997
998 if ( 0 < count( $dbwebsites ) ) {
999 $post_data = array(
1000 'keyword' => $keyword,
1001 'dtsstart' => $dtsstart,
1002 'dtsstop' => $dtsstop,
1003 'status' => $status,
1004 'maxRecords' => ( ( false === get_option( 'mainwp_maximumPages' ) ) ? 50 : get_option( 'mainwp_maximumPages' ) ),
1005 'search_on' => $search_on,
1006 );
1007
1008 if ( MainWP_Utility::enabled_wp_seo() ) {
1009 $post_data['WPSEOEnabled'] = 1;
1010 }
1011
1012 /**
1013 * Get all pages data
1014 *
1015 * Set search parameters for the fetch process.
1016 *
1017 * @since 3.4
1018 */
1019 $post_data = apply_filters( 'mainwp_get_all_pages_data', $post_data );
1020 MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_pages', $post_data, array( self::get_class_name(), 'pages_search_handler' ), $output );
1021 }
1022
1023 MainWP_Cache::add_context(
1024 'Page',
1025 array(
1026 'count' => $output->pages,
1027 'keyword' => $keyword,
1028 'dtsstart' => $dtsstart,
1029 'dtsstop' => $dtsstop,
1030 'status' => $status,
1031 'sites' => ( ! empty( $sites ) ) ? $sites : '',
1032 'groups' => ( ! empty( $groups ) ) ? $groups : '',
1033 'search_on' => $search_on,
1034 )
1035 );
1036
1037 if ( empty( $output->pages ) ) {
1038 MainWP_Cache::add_body( 'Page', '' );
1039 return;
1040 }
1041 }
1042
1043 /**
1044 * Method get_status()
1045 *
1046 * Get page status. If the page status is
1047 * 'publish' change it to 'Published'.
1048 *
1049 * @param mixed $status Page Status.
1050 *
1051 * @return string Page status.
1052 */
1053 private static function get_status( $status ) {
1054 if ( 'publish' === $status ) {
1055 return 'Published';
1056 }
1057 return esc_html( ucfirst( $status ) );
1058 }
1059
1060
1061 /**
1062 * Method pages_search_handler()
1063 *
1064 * Pages Search handler.
1065 *
1066 * @param mixed $data Search data.
1067 * @param mixed $website Child Site ID to search on.
1068 * @param mixed $output Search output.
1069 *
1070 * @return void Search box html.
1071 *
1072 * @uses \MainWP\Dashboard\MainWP_Cache::add_body()
1073 * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message()
1074 * @uses \MainWP\Dashboard\MainWP_Exception
1075 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response()
1076 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
1077 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
1078 * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo()
1079 * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
1080 */
1081 public static function pages_search_handler( $data, $website, &$output ) { // phpcs:ignore -- complex function.
1082 if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) {
1083 return;
1084 }
1085 if ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) {
1086 $result = $results[1];
1087 $pages = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1088
1089 if ( is_array( $pages ) && isset( $pages['error'] ) ) {
1090 $output->errors[ $website->id ] = esc_html( $pages['error'] );
1091 return;
1092 }
1093
1094 unset( $results );
1095 foreach ( $pages as $page ) {
1096 $raw_dts = '';
1097 if ( isset( $page['dts'] ) ) {
1098 $raw_dts = $page['dts'];
1099 if ( ! stristr( $page['dts'], '-' ) ) {
1100 $page['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $page['dts'] ) );
1101 }
1102 }
1103
1104 if ( ! isset( $page['title'] ) || ( '' === $page['title'] ) ) {
1105 $page['title'] = '(No Title)';
1106 }
1107 ob_start();
1108 ?>
1109 <tr>
1110 <td class="check-column"><span class="ui checkbox"><input type="checkbox" name="page[]" value="1"></span></td>
1111 <?php
1112 /**
1113 * Action: mainwp_pages_table_column
1114 *
1115 * Adds a new column item in the Manage pages table.
1116 *
1117 * @param array $page Array containing the page data.
1118 * @param array $website Object containing the website data.
1119 *
1120 * @since 4.1
1121 */
1122 do_action( 'mainwp_pages_table_column', $page, $website );
1123 ?>
1124 <td class="page-title column-title">
1125 <strong>
1126 <abbr title="<?php echo esc_html( $page['title'] ); ?>">
1127 <?php if ( 'trash' !== $page['status'] ) { ?>
1128 <a class="row-title" href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $website->id ); ?>&location=<?php echo esc_attr( base64_encode( 'post.php?post=' . $page['id'] . '&action=edit' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" target="_blank" title="Edit '<?php echo esc_html( $page['title'] ); ?>'?"><?php echo esc_html( $page['title'] ); ?></a>
1129 <?php } else { ?>
1130 <?php echo esc_html( $page['title'] ); ?>
1131 <?php } ?>
1132 </abbr>
1133 </strong>
1134
1135 </td>
1136 <td class="author column-author">
1137 <?php echo esc_html( $page['author'] ); ?>
1138 </td>
1139 <td class="comments">
1140 <div class="page-com-count-wrapper">
1141 <a href="#" title="0 pending" class="post-com-count">
1142 <span class="comment-count"><abbr title="<?php echo esc_attr( $page['comment_count'] ); ?>"><?php echo esc_html( $page['comment_count'] ); ?></abbr></span>
1143 </a>
1144 </div>
1145 </td>
1146 <td class="date" data-order="<?php echo esc_attr( $raw_dts ); ?>">
1147 <abbr raw_value="<?php echo esc_attr( $raw_dts ); ?>" title="<?php echo esc_attr( $page['dts'] ); ?>"><?php echo esc_html( $page['dts'] ); ?></abbr>
1148 </td>
1149 <td class="status column-status <?php echo 'trash' === $page['status'] ? 'post-trash' : ''; ?>"><?php echo esc_html( self::get_status( $page['status'] ) ); ?>
1150 </td>
1151 <?php
1152 if ( MainWP_Utility::enabled_wp_seo() ) {
1153 $count_seo_links = null;
1154 $count_seo_linked = null;
1155 $seo_score = '';
1156 $readability_score = '';
1157 if ( isset( $page['seo_data'] ) ) {
1158 $seo_data = $page['seo_data'];
1159 $count_seo_links = esc_html( $seo_data['count_seo_links'] );
1160 $count_seo_linked = esc_html( $seo_data['count_seo_linked'] );
1161 $seo_score = MainWP_Utility::esc_content( $seo_data['seo_score'], 'mixed' );
1162 $readability_score = MainWP_Utility::esc_content( $seo_data['readability_score'], 'mixed' );
1163 }
1164 ?>
1165 <td class="column-seo-links"><abbr raw_value="<?php echo null !== $count_seo_links ? $count_seo_links : -1; ?>" title=""><?php echo null !== $count_seo_links ? $count_seo_links : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td>
1166 <td class="column-seo-linked"><abbr raw_value="<?php echo null !== $count_seo_linked ? $count_seo_linked : -1; ?>" title=""><?php echo null !== $count_seo_linked ? $count_seo_linked : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td>
1167 <td class="column-seo-score"><abbr raw_value="<?php echo $seo_score ? 1 : 0; ?>" title=""><?php echo $seo_score; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td>
1168 <td class="column-seo-readability"><abbr raw_value="<?php echo $readability_score ? 1 : 0; ?>" title=""><?php echo $readability_score; // phpcs:ignore WordPress.Security.EscapeOutput ?></abbr></td>
1169 <?php
1170 }
1171 ?>
1172 <td class="website">
1173 <a href="<?php echo esc_html( $website->url ); ?>" class="mainwp-may-hide-referrer" target="_blank"><?php echo esc_html( $website->url ); ?></a>
1174 </td>
1175 <td class="right aligned">
1176 <input class="pageId" type="hidden" name="id" value="<?php echo intval( $page['id'] ); ?>"/>
1177 <input class="allowedBulkActions" type="hidden" name="allowedBulkActions" value="|get_edit|trash|delete|<?php echo ( 'trash' === $page['status'] ) ? 'restore|' : ''; ?><?php echo ( 'future' === $page['status'] || 'draft' === $page['status'] ) ? 'publish|' : ''; ?>" />
1178 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/>
1179
1180 <div class="ui left pointing dropdown icon mini basic green button" style="z-index: 999">
1181 <a href="javascript:void(0)"><i class="ellipsis horizontal icon"></i></a>
1182 <div class="menu">
1183 <?php if ( 'future' === $page['status'] || 'draft' === $page['status'] ) : ?>
1184 <a class="item page_submitpublish" href="#"><?php esc_html_e( 'Publish', 'mainwp' ); ?></a>
1185 <?php endif; ?>
1186 <?php if ( 'trash' !== $page['status'] ) : ?>
1187 <a class="item page_getedit" href="#"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a>
1188 <?php do_action( 'mainwp_manage_pages_action_item', $page ); ?>
1189 <a class="item page_submitdelete" href="#"><?php esc_html_e( 'Trash', 'mainwp' ); ?></a>
1190 <?php endif; ?>
1191 <?php if ( 'publish' === $page['status'] ) { ?>
1192 <a class="item" href="<?php echo esc_html( $website->url ) . ( '/' !== substr( $website->url, -1 ) ? '/' : '' ) . '?p=' . intval( $page['id'] ); ?>" target="_blank"><?php esc_html_e( 'View', 'mainwp' ); ?></a>
1193 <?php } ?>
1194 <?php if ( 'trash' === $page['status'] ) { ?>
1195 <a class="item page_submitrestore" href="#"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a>
1196 <a class="item page_submitdelete_perm" href="#"><?php esc_html_e( 'Delete permanently', 'mainwp' ); ?></a>
1197 <?php } ?>
1198 <a class="item" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . intval( $website->id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="bottom right" data-inverted="" class="open_newwindow_wpadmin ui green basic icon button" target="_blank"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a>
1199 <?php
1200 /**
1201 * Action: mainwp_pages_table_action
1202 *
1203 * Adds a new item in the Actions menu in Manage Pages table.
1204 *
1205 * Suggested HTML markup:
1206 * <a class="item" href="Your custom URL">Your custom label</a>
1207 *
1208 * @param array $post Array containing the page data.
1209 * @param array $website Object containing the website data.
1210 *
1211 * @since 4.1
1212 */
1213 do_action( 'mainwp_pages_table_action', $page, $website );
1214 ?>
1215 </div>
1216 </div>
1217 </td>
1218 </tr>
1219 <?php
1220 $newOutput = ob_get_clean();
1221 echo $newOutput; // phpcs:ignore WordPress.Security.EscapeOutput
1222 MainWP_Cache::add_body( 'Page', $newOutput );
1223 ++$output->pages;
1224 }
1225 unset( $pages );
1226 } else {
1227 $output->errors[ $website->id ] = MainWP_Error_Helper::get_error_message( new MainWP_Exception( 'NOMAINWP', $website->url ) ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
1228 }
1229 }
1230
1231 /**
1232 * Method publish()
1233 *
1234 * Publish page.
1235 *
1236 * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action()
1237 */
1238 public static function publish() {
1239 MainWP_Recent_Posts::action( 'publish', 'page' );
1240 die( wp_json_encode( array( 'result' => 'Page has been published!' ) ) );
1241 }
1242
1243 /**
1244 * Method unpublish()
1245 *
1246 * Unpublish page.
1247 *
1248 * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action()
1249 */
1250 public static function unpublish() {
1251 MainWP_Recent_Posts::action( 'unpublish', 'page' );
1252 die( wp_json_encode( array( 'result' => 'Page has been unpublished!' ) ) );
1253 }
1254
1255 /**
1256 * Method trash()
1257 *
1258 * Trash page.
1259 *
1260 * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action()
1261 */
1262 public static function trash() {
1263 MainWP_Recent_Posts::action( 'trash', 'page' );
1264 die( wp_json_encode( array( 'result' => 'Page has been moved to trash!' ) ) );
1265 }
1266
1267 /**
1268 * Method delete()
1269 *
1270 * Delete page.
1271 *
1272 * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action()
1273 */
1274 public static function delete() {
1275 MainWP_Recent_Posts::action( 'delete', 'page' );
1276 die( wp_json_encode( array( 'result' => 'Page has been permanently deleted!' ) ) );
1277 }
1278
1279 /**
1280 * Method restore()
1281 *
1282 * Restore page.
1283 *
1284 * @uses \MainWP\Dashboard\MainWP_Recent_Posts::action()
1285 */
1286 public static function restore() {
1287 MainWP_Recent_Posts::action( 'restore', 'page' );
1288 die( wp_json_encode( array( 'result' => 'Page has been restored!' ) ) );
1289 }
1290
1291 /**
1292 * Method render_bulk_add()
1293 *
1294 * Check if user has the rights to manage pages,
1295 * grab the post id and pass onto render_addedit() method.
1296 *
1297 * @return void
1298 */
1299 public static function render_bulk_add() {
1300 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) {
1301 mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) );
1302 return;
1303 }
1304
1305 /**
1306 * MainWP default post to edit.
1307 *
1308 * @global string
1309 */
1310 global $_mainwp_default_post_to_edit;
1311
1312 $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0;
1313 self::render_addedit( $post_id, 'BulkAdd' );
1314 }
1315
1316 /**
1317 * Method render_bulk_edit()
1318 *
1319 * Check if user has the rights to manage pages,
1320 * grab the post id and pass onto render_addedit() method.
1321 *
1322 * @return void
1323 */
1324 public static function render_bulk_edit() {
1325 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) ) {
1326 mainwp_do_not_have_permissions( esc_html__( 'manage pages', 'mainwp' ) );
1327 return;
1328 }
1329
1330 $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1331 self::render_addedit( $post_id, 'BulkEdit' );
1332 }
1333
1334 /**
1335 * Method render_addedit()
1336 *
1337 * Render bulk posts page.
1338 *
1339 * @param mixed $post_id Post ID.
1340 * @param mixed $what Current page.
1341 *
1342 * @return void Display page header, bulkpost body & footer.
1343 *
1344 * @uses \MainWP\Dashboard\MainWP_Post::render_bulkpost()
1345 */
1346 public static function render_addedit( $post_id, $what ) {
1347 self::render_header( $what, $post_id );
1348 MainWP_Post::render_bulkpost( $post_id, 'bulkpage' );
1349 self::render_footer( $what );
1350 }
1351
1352 /**
1353 * Method posting()
1354 *
1355 * Render Posting page modal window.
1356 *
1357 * @return void Posting page modal window html.
1358 *
1359 * @uses \MainWP\Dashboard\MainWP_Connect::fetch_url_authed()
1360 * @uses \MainWP\Dashboard\MainWP_DB::query()
1361 * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
1362 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1363 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1364 * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze()
1365 * @uses \MainWP\Dashboard\MainWP_Bulk_Add::get_class_name()
1366 * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
1367 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
1368 */
1369 public static function posting() { // phpcs:ignore -- current complexity required to achieve desired results. Pull request solutions appreciated.
1370 $succes_message = '';
1371 $post_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1372
1373 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
1374 wp_die( 'Invalid request!' );
1375 }
1376
1377 $edit_id = 0;
1378 if ( $post_id ) {
1379 $edit_id = get_post_meta( $post_id, '_mainwp_edit_post_id', true );
1380 $edit_id = intval( $edit_id );
1381 if ( $edit_id ) {
1382 $succes_message = esc_html__( 'Page has been updated successfully', 'mainwp' );
1383 } else {
1384 $succes_message = esc_html__( 'New page created', 'mainwp' );
1385 }
1386 }
1387 $data_fields = MainWP_System_Utility::get_default_map_site_fields();
1388 ?>
1389 <div class="ui modal" id="mainwp-posting-page-modal">
1390 <i class="close icon"></i>
1391 <div class="header"><?php $edit_id ? esc_html_e( 'Edit Page', 'mainwp' ) : esc_html_e( 'New Page', 'mainwp' ); ?></div>
1392 <div class="scrolling content">
1393 <?php
1394 /**
1395 * Before Page post action
1396 *
1397 * Fires right before posting the 'bulkpage' to child sites.
1398 *
1399 * @param int $_GET['id'] Page ID.
1400 *
1401 * @since Unknown
1402 */
1403 do_action( 'mainwp_bulkpage_before_post', $post_id );
1404
1405 $skip_post = false;
1406 if ( $post_id ) {
1407 if ( 'yes' === get_post_meta( $post_id, '_mainwp_skip_posting', true ) ) {
1408 $skip_post = true;
1409 wp_delete_post( $post_id, true );
1410 }
1411 }
1412
1413 if ( ! $skip_post ) {
1414 if ( $post_id ) {
1415 $id = $post_id;
1416 $_post = get_post( $id );
1417 if ( $_post ) {
1418 $selected_by = get_post_meta( $id, '_selected_by', true );
1419 $val = get_post_meta( $id, '_selected_sites', true );
1420 $selected_sites = MainWP_System_Utility::maybe_unserialyze( $val );
1421 $val = get_post_meta( $id, '_selected_groups', true );
1422 $selected_groups = MainWP_System_Utility::maybe_unserialyze( $val );
1423 $selected_clients = get_post_meta( $id, '_selected_clients', true );
1424 $post_slug = base64_decode( get_post_meta( $id, '_slug', true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1425 $post_custom = get_post_custom( $id );
1426 include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php';
1427 $featured_image_id = get_post_thumbnail_id( $id );
1428 $post_featured_image = null;
1429 $featured_image_data = null;
1430 $mainwp_upload_dir = wp_upload_dir();
1431
1432 // to fix.
1433 $post_status = $_post->post_status;
1434 if ( 'publish' === $post_status ) {
1435 $post_status = get_post_meta( $id, '_edit_post_status', true );
1436 }
1437
1438 /**
1439 * Page status
1440 *
1441 * Sets page status when posting 'bulkpage' to child sites.
1442 *
1443 * @param int $id Page ID.
1444 *
1445 * @since Unknown
1446 */
1447 $post_status = apply_filters( 'mainwp_posting_bulkpost_post_status', $post_status, $id );
1448
1449 $new_post = array(
1450 'post_title' => $_post->post_title,
1451 'post_content' => $_post->post_content,
1452 'post_status' => $post_status,
1453 'post_date' => $_post->post_date,
1454 'post_date_gmt' => $_post->post_date_gmt,
1455 'post_type' => 'page',
1456 'post_name' => $post_slug,
1457 'post_excerpt' => MainWP_Utility::esc_content( $_post->post_excerpt, 'mixed' ),
1458 'post_password' => $_post->post_password,
1459 'comment_status' => $_post->comment_status,
1460 'ping_status' => $_post->ping_status,
1461 'mainwp_post_id' => $_post->ID,
1462 );
1463
1464 if ( ! empty( $featured_image_id ) ) {
1465 $img = wp_get_attachment_image_src( $featured_image_id, 'full' );
1466 $post_featured_image = $img[0];
1467 $attachment = get_post( $featured_image_id );
1468 $featured_image_data = array(
1469 'alt' => get_post_meta( $featured_image_id, '_wp_attachment_image_alt', true ),
1470 'caption' => MainWP_Utility::esc_content( $attachment->post_excerpt, 'mixed' ),
1471 'description' => $attachment->post_content,
1472 'title' => htmlspecialchars( $attachment->post_title ),
1473 );
1474 }
1475
1476 $galleries = get_post_gallery( $id, false );
1477 $post_gallery_images = array();
1478
1479 if ( is_array( $galleries ) && isset( $galleries['ids'] ) ) {
1480 $attached_images = explode( ',', $galleries['ids'] );
1481 foreach ( $attached_images as $attachment_id ) {
1482 $attachment = get_post( $attachment_id );
1483 if ( $attachment ) {
1484 $post_gallery_images[] = array(
1485 'id' => $attachment_id,
1486 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
1487 'caption' => MainWP_Utility::esc_content( $attachment->post_excerpt, 'mixed' ),
1488 'description' => $attachment->post_content,
1489 'src' => $attachment->guid,
1490 'title' => htmlspecialchars( $attachment->post_title ),
1491 );
1492 }
1493 }
1494 }
1495
1496 $dbwebsites = array();
1497 if ( 'site' === $selected_by ) {
1498 foreach ( $selected_sites as $k ) {
1499 if ( MainWP_Utility::ctype_digit( $k ) ) {
1500 $website = MainWP_DB::instance()->get_website_by_id( $k );
1501 if ( '' === $website->sync_errors && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
1502 $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields );
1503 }
1504 }
1505 }
1506 } elseif ( 'client' === $selected_by ) {
1507 if ( is_array( $selected_clients ) ) {
1508 $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids(
1509 $selected_clients,
1510 array(
1511 'select_data' => $data_fields,
1512 )
1513 );
1514 if ( $websites ) {
1515 foreach ( $websites as $website ) {
1516 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
1517 continue;
1518 }
1519 $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields );
1520 }
1521 }
1522 }
1523 } elseif ( 'group' === $selected_by ) {
1524 foreach ( $selected_groups as $k ) {
1525 if ( MainWP_Utility::ctype_digit( $k ) ) {
1526 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $k ) );
1527 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1528 if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) {
1529 continue;
1530 }
1531 $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields );
1532 }
1533 MainWP_DB::free_result( $websites );
1534 }
1535 }
1536 }
1537
1538 $output = new \stdClass();
1539 $output->ok = array();
1540 $output->errors = array();
1541 $startTime = time();
1542
1543 if ( 0 < count( $dbwebsites ) ) {
1544
1545 // prepare $post_custom values.
1546 $new_post_custom = array();
1547 foreach ( $post_custom as $meta_key => $meta_values ) {
1548 $new_meta_values = array();
1549 foreach ( $meta_values as $key_value => $meta_value ) {
1550 if ( is_serialized( $meta_value ) ) {
1551 $meta_value = unserialize( $meta_value ); // phpcs:ignore -- internal value safe.
1552 }
1553 $new_meta_values[ $key_value ] = $meta_value;
1554 }
1555 $new_post_custom[ $meta_key ] = $new_meta_values;
1556 }
1557
1558 $post_data = array(
1559 'new_post' => base64_encode( wp_json_encode( $new_post ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1560 'post_custom' => base64_encode( wp_json_encode( $new_post_custom ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1561 'post_featured_image' => ( null !== $post_featured_image ) ? base64_encode( $post_featured_image ) : null, // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1562 'post_gallery_images' => base64_encode( wp_json_encode( $post_gallery_images ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1563 'mainwp_upload_dir' => base64_encode( wp_json_encode( $mainwp_upload_dir ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1564 'featured_image_data' => ( null !== $featured_image_data ) ? base64_encode( wp_json_encode( $featured_image_data ) ) : null, // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
1565 );
1566
1567 /**
1568 * Posting new page
1569 *
1570 * Sets Page data to post to child sites.
1571 *
1572 * @param int $id Page ID.
1573 *
1574 * @since Unknown
1575 */
1576 $post_data = apply_filters( 'mainwp_bulkpage_posting', $post_data, $id );
1577 MainWP_Connect::fetch_urls_authed( $dbwebsites, 'newpost', $post_data, array( MainWP_Bulk_Add::get_class_name(), 'posting_bulk_handler' ), $output );
1578 }
1579
1580 foreach ( $dbwebsites as $website ) {
1581 if ( isset( $output->ok[ $website->id ] ) && ( 1 === (int) $output->ok[ $website->id ] ) && ( isset( $output->added_id[ $website->id ] ) ) ) {
1582 $links = isset( $output->link[ $website->id ] ) ? $output->link[ $website->id ] : null;
1583
1584 do_action_deprecated( 'mainwp-post-posting-page', array( $website, $output->added_id[ $website->id ], $links ), '4.0.7.2', 'mainwp_post_posting_page' ); // @deprecated Use 'mainwp_post_posting_page' instead.
1585 do_action_deprecated( 'mainwp-bulkposting-done', array( $_post, $website, $output ), '4.0.7.2', 'mainwp_bulkposting_done' ); // @deprecated Use 'mainwp_bulkposting_done' instead.
1586
1587 /**
1588 * Posting page
1589 *
1590 * Fires while posting page.
1591 *
1592 * @param object $website Object containing child site data.
1593 * @param int $output->added_id[ $website->id ] Child site ID.
1594 * @param array $links Links.
1595 *
1596 * @since Unknown
1597 */
1598 do_action( 'mainwp_post_posting_page', $website, $output->added_id[ $website->id ], $links );
1599
1600 /**
1601 * Posting page completed
1602 *
1603 * Fires after the page posting process is completed.
1604 *
1605 * @param array $_post Array containing the post data.
1606 * @param object $website Object containing child site data.
1607 * @param array $output Output data.
1608 *
1609 * @since Unknown
1610 */
1611 do_action( 'mainwp_bulkposting_done', $_post, $website, $output );
1612 }
1613 }
1614
1615 /**
1616 * After posting a new page
1617 *
1618 * Sets data after the posting process to show the process feedback.
1619 *
1620 * @param array $_post Array containing the post data.
1621 * @param array $dbwebsites Array containing processed sites.
1622 * @param array $output Output data.
1623 *
1624 * @since Unknown
1625 */
1626 $after_posting = apply_filters_deprecated( 'mainwp-after-posting-bulkpage-result', array( false, $_post, $dbwebsites, $output ), '4.0.7.2', 'mainwp_after_posting_bulkpage_result' ); // @deprecated Use 'mainwp_after_posting_bulkpage_result' instead.
1627 $after_posting = apply_filters( 'mainwp_after_posting_bulkpage_result', $after_posting, $_post, $dbwebsites, $output );
1628
1629 if ( false === $after_posting ) {
1630 ?>
1631 <div class="ui relaxed list">
1632 <?php foreach ( $dbwebsites as $website ) { ?>
1633 <div class="item"><a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a>
1634 : <?php echo ( isset( $output->ok[ $website->id ] ) && 1 === (int) $output->ok[ $website->id ] ? esc_html( $succes_message ) . ' <a href="' . esc_html( $output->link[ $website->id ] ) . '" class="mainwp-may-hide-referrer" target="_blank">View Page</a>' : 'ERROR: ' . $output->errors[ $website->id ] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
1635 </div>
1636 <?php } ?>
1637 </div>
1638
1639 <?php
1640 }
1641
1642 $do_not_del = get_post_meta( $id, '_bulkpost_do_not_del', true );
1643
1644 if ( 'yes' !== $do_not_del ) {
1645 wp_delete_post( $id, true );
1646 }
1647
1648 $countSites = 0;
1649 $countRealItems = 0;
1650 foreach ( $dbwebsites as $website ) {
1651 if ( isset( $output->ok[ $website->id ] ) && 1 === (int) $output->ok[ $website->id ] ) {
1652 ++$countSites;
1653 ++$countRealItems;
1654 }
1655 }
1656 }
1657 } else {
1658 ?>
1659 <div class="error">
1660 <p><strong>ERROR</strong>: <?php esc_html_e( 'An undefined error occured.', 'mainwp' ); ?></p>
1661 </div>
1662 <?php
1663 }
1664 }
1665 ?>
1666 </div>
1667 <div class="actions">
1668 <?php do_action( 'mainwp_pages_posting_popup_actions', $id ); ?>
1669 <a href="admin.php?page=PageBulkAdd" class="ui green button new-bulk-page"><?php esc_html_e( 'New Page', 'mainwp' ); ?></a>
1670 </div>
1671 </div>
1672 <div class="ui active inverted dimmer" id="mainwp-posting-running">
1673 <div class="ui indeterminate large text loader"><?php esc_html_e( 'Running ...', 'mainwp' ); ?></div>
1674 </div>
1675 <script type="text/javascript">
1676 jQuery( document ).ready( function () {
1677 jQuery( "#mainwp-posting-running" ).hide();
1678 jQuery( "#mainwp-posting-page-modal" ).modal( {
1679 closable: true,
1680 onHide: function() {
1681 location.href = 'admin.php?page=PageBulkManage';
1682 }
1683 } ).modal( 'show' );
1684 } );
1685 </script>
1686 <?php
1687 }
1688
1689 /**
1690 * Method mainwp_help_content()
1691 *
1692 * Hook the section help content to the Help Sidebar element
1693 *
1694 * @return void Help section html.
1695 */
1696 public static function mainwp_help_content() {
1697 if ( isset( $_GET['page'] ) && ( 'PageBulkManage' === $_GET['page'] || 'PageBulkAdd' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1698 ?>
1699 <p><?php esc_html_e( 'If you need help with managing pages, please review following help documents', 'mainwp' ); ?></p>
1700 <div class="ui relaxed bulleted list">
1701 <div class="item"><a href="https://kb.mainwp.com/docs/manage-pages/" target="_blank">Manage Pages</a> <i class="external alternate icon"></i></div>
1702 <div class="item"><a href="https://kb.mainwp.com/docs/create-a-new-page/" target="_blank">Create a New Page</a> <i class="external alternate icon"></i></div>
1703 <div class="item"><a href="https://kb.mainwp.com/docs/edit-an-existing-page/" target="_blank">Edit an Existing Page</a> <i class="external alternate icon"></i></div>
1704 <div class="item"><a href="https://kb.mainwp.com/docs/change-status-of-an-existing-page/" target="_blank">Change Status of an Existing Page</a> <i class="external alternate icon"></i></div>
1705 <div class="item"><a href="https://kb.mainwp.com/docs/view-an-existing-page/" target="_blank">View an Existing Page</a> <i class="external alternate icon"></i></div>
1706 <div class="item"><a href="https://kb.mainwp.com/docs/delete-pages/" target="_blank">Delete Page(s)</a> <i class="external alternate icon"></i></div>
1707 <?php
1708 /**
1709 * Action: mainwp_pages_help_item
1710 *
1711 * Fires at the bottom of the help articles list in the Help sidebar on the Pages page.
1712 *
1713 * Suggested HTML markup:
1714 *
1715 * <div class="item"><a href="Your custom URL">Your custom text</a></div>
1716 *
1717 * @since 4.1
1718 */
1719 do_action( 'mainwp_pages_help_item' );
1720 ?>
1721 </div>
1722 <?php
1723 }
1724 }
1725 }
1726