PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.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 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 6.1, at pages/page-mainwp-page.php

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