PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.4.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.4.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 / class / class-mainwp-ui.php

class-mainwp-ui.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 4.4.1, at class/class-mainwp-ui.php

2,113 lines 82.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP UI.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 /**
11 * Class MainWP_UI
12 *
13 * @package MainWP\Dashboard
14 */
15 class MainWP_UI {
16
17 /**
18 * Method get_class_name()
19 *
20 * Get Class Name.
21 *
22 * @return object
23 */
24 public static function get_class_name() {
25 return __CLASS__;
26 }
27
28 /**
29 * Method select_sites_box()
30 *
31 * Select sites box.
32 *
33 * @deprecated 4.3 Use MainWP_UI_Select_Sites::select_sites_box().
34 *
35 * @param string $type Input type, radio.
36 * @param bool $show_group Whether or not to show group, Default: true.
37 * @param bool $show_select_all Whether to show select all.
38 * @param string $class Default = ''.
39 * @param string $style Default = ''.
40 * @param array $selected_websites Selected Child Sites.
41 * @param array $selected_groups Selected Groups.
42 * @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not.
43 * @param integer $postId Post Meta ID.
44 *
45 * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze()
46 */
47 public static function select_sites_box( $type = 'checkbox', $show_group = true, $show_select_all = true, $class = '', $style = '', &$selected_websites = array(), &$selected_groups = array(), $enableOfflineSites = false, $postId = 0 ) {
48
49 if ( $postId ) {
50
51 $sites_val = get_post_meta( $postId, '_selected_sites', true );
52 $selected_websites = MainWP_System_Utility::maybe_unserialyze( $sites_val );
53
54 if ( '' == $selected_websites ) {
55 $selected_websites = array();
56 }
57
58 $groups_val = get_post_meta( $postId, '_selected_groups', true );
59 $selected_groups = MainWP_System_Utility::maybe_unserialyze( $groups_val );
60
61 if ( '' == $selected_groups ) {
62 $selected_groups = array();
63 }
64 }
65
66 if ( empty( $selected_websites ) && isset( $_GET['selected_sites'] ) && ! empty( $_GET['selected_sites'] ) ) {
67 $selected_sites = explode( '-', sanitize_text_field( wp_unslash( $_GET['selected_sites'] ) ) ); // sanitize ok.
68 $selected_sites = array_map( 'intval', $selected_sites );
69 $selected_websites = array_filter( $selected_sites );
70 }
71
72 /**
73 * Action: mainwp_before_seclect_sites
74 *
75 * Fires before the Select Sites box.
76 *
77 * @since 4.1
78 */
79 do_action( 'mainwp_before_seclect_sites' );
80 ?>
81 <div id="mainwp-select-sites" class="mainwp_select_sites_wrapper">
82 <?php self::select_sites_box_body( $selected_websites, $selected_groups, $type, $show_group, $show_select_all, false, $enableOfflineSites, $postId ); ?>
83 </div>
84 <?php
85 /**
86 * Action: mainwp_after_seclect_sites
87 *
88 * Fires after the Select Sites box.
89 *
90 * @since 4.1
91 */
92 do_action( 'mainwp_after_seclect_sites' );
93 }
94
95 /**
96 * Method select_sites_box_body()
97 *
98 * Select sites box Body.
99 *
100 * @deprecated 4.3 Use MainWP_UI_Select_Sites::select_sites_box_body().
101 *
102 * @param array $selected_websites Child Site that are selected.
103 * @param array $selected_groups Group that are selected.
104 * @param string $type Selector type.
105 * @param bool $show_group Whether or not to show group, Default: true.
106 * @param bool $show_select_all Whether or not to show select all, Default: true.
107 * @param bool $updateQty Whether or not to update quantity, Default = false.
108 * @param bool $enableOfflineSites Whether or not to enable offline sites, Default: true.
109 * @param int $postId Post ID.
110 *
111 * @uses \MainWP\Dashboard\MainWP_DB::query()
112 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
113 */
114 public static function select_sites_box_body( &$selected_websites = array(), &$selected_groups = array(), $type = 'checkbox', $show_group = true, $show_select_all = true, $updateQty = false, $enableOfflineSites = false, $postId = 0 ) {
115
116 if ( 'all' !== $selected_websites && ! is_array( $selected_websites ) ) {
117 $selected_websites = array();
118 }
119
120 if ( ! is_array( $selected_groups ) ) {
121 $selected_groups = array();
122 }
123
124 $selectedby = 'site';
125 if ( ! empty( $selected_groups ) ) {
126 $selectedby = 'group';
127 }
128
129 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
130 $groups = MainWP_DB_Common::instance()->get_not_empty_groups( null, $enableOfflineSites );
131
132 // support staging extension.
133 $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
134
135 $edit_site_id = false;
136 if ( $postId ) {
137 $edit_site_id = get_post_meta( $postId, '_mainwp_edit_post_site_id', true );
138 $edit_site_id = intval( $edit_site_id );
139 }
140
141 if ( $edit_site_id ) {
142 $show_group = false;
143 }
144 // to fix layout with multi sites selector.
145 $tab_id = wp_rand();
146
147 self::render_select_sites_header( $tab_id, $staging_enabled, $selectedby, $show_group );
148 ?>
149 <div class="ui tab <?php echo 'site' == $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-sites-<?php echo $tab_id; ?>" id="mainwp-select-sites">
150 <?php
151 self::render_select_sites( $websites, $type, $selected_websites, $enableOfflineSites, $edit_site_id, $show_select_all );
152 ?>
153 </div>
154 <?php if ( $staging_enabled ) { ?>
155 <div class="ui tab <?php echo 'staging' == $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-staging-sites-<?php echo $tab_id; ?>">
156 <?php
157 self::render_select_sites_staging( $selected_websites, $edit_site_id, $type );
158 ?>
159 </div>
160 <?php
161 }
162 if ( $show_group ) {
163 ?>
164 <div class="ui tab <?php echo 'group' == $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-groups-<?php echo $tab_id; ?>" id="mainwp-select-groups">
165 <?php
166 self::render_select_sites_group( $groups, $selected_groups, $type );
167 ?>
168 </div>
169 <?php
170 }
171 ?>
172 <script type="text/javascript">
173 jQuery( document ).ready( function () {
174 jQuery('#mainwp-select-sites-header .ui.menu .item').tab( {'onVisible': function() { mainwp_sites_selection_onvisible_callback( this ); } } );
175 } );
176 </script>
177 <?php
178 }
179
180 /**
181 * Method render_select_sites_header()
182 *
183 * Render selected sites header.
184 *
185 * @param int $tab_id Datatab ID.
186 * @param bool $staging_enabled True, if in the active plugins list. False, not in the list.
187 * @param array $selectedby Selected by.
188 * @param bool $show_group Whether or not to show group, Default: true.
189 * @param bool $show_client Whether or not to show client, Default: true.
190 *
191 * @todo Move to view folder.
192 */
193 public static function render_select_sites_header( $tab_id, $staging_enabled, $selectedby, $show_group = true, $show_client = false ) {
194
195 /**
196 * Action: mainwp_before_select_sites_filters
197 *
198 * Fires before the Select Sites box filters.
199 *
200 * @since 4.1
201 */
202 do_action( 'mainwp_before_select_sites_filters' );
203 ?>
204 <div id="mainwp-select-sites-filters">
205 <div class="ui mini fluid icon input">
206 <input type="text" id="mainwp-select-sites-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" <?php echo 'site' == $selectedby ? '' : 'style="display: none;"'; ?> />
207 <i class="filter icon"></i>
208 </div>
209 </div>
210 <?php
211 /**
212 * Action: mainwp_after_select_sites_filters
213 *
214 * Fires after the Select Sites box filters.
215 *
216 * @since 4.1
217 */
218 do_action( 'mainwp_after_select_sites_filters' );
219 ?>
220 <input type="hidden" name="select_by" id="select_by" value="<?php echo esc_attr( $selectedby ); ?>"/>
221 <input type="hidden" id="select_sites_tab" value="<?php echo esc_attr( $selectedby ); ?>"/>
222 <div id="mainwp-select-sites-header">
223 <div class="ui pointing green secondary menu">
224 <a class="item ui tab <?php echo ( 'site' == $selectedby ) ? 'active' : ''; ?>" data-tab="mainwp-select-sites-<?php echo $tab_id; ?>" select-by="site"><?php esc_html_e( 'Sites', 'mainwp' ); ?></a>
225 <?php if ( $show_group ) : ?>
226 <a class="item ui tab <?php echo ( 'group' == $selectedby ) ? 'active' : ''; ?>" data-tab="mainwp-select-groups-<?php echo $tab_id; ?>" select-by="group"><?php esc_html_e( 'Tags', 'mainwp' ); ?></a>
227 <?php endif; ?>
228 <?php if ( $show_client ) : ?>
229 <a class="item ui tab <?php echo ( 'client' == $selectedby ) ? 'active' : ''; ?>" data-tab="mainwp-select-clients-<?php echo $tab_id; ?>" select-by="client"><?php esc_html_e( 'Clients', 'mainwp' ); ?></a>
230 <?php endif; ?>
231 <?php if ( $staging_enabled ) : ?>
232 <a class="item ui tab" data-tab="mainwp-select-staging-sites-<?php echo $tab_id; ?>" select-by="staging"><?php esc_html_e( 'Staging', 'mainwp' ); ?></a>
233 <?php endif; ?>
234 </div>
235 </div>
236 <?php
237 }
238
239 /**
240 * Method render_select_sites()
241 *
242 * @param object $websites Object containing child sites info.
243 * @param string $type Selector type.
244 * @param mixed $selected_websites Selected Child Sites.
245 * @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not.
246 * @param mixed $edit_site_id Child Site ID to edit.
247 * @param bool $show_select_all Whether or not to show select all, Default: true.
248 * @param mixed $add_edit_client_id Show enable sites for client. Default: false, 0: add new client, 0 <: edit client.
249 *
250 * @return void Render Select Sites html.
251 *
252 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
253 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
254 */
255 public static function render_select_sites( $websites, $type, $selected_websites, $enableOfflineSites, $edit_site_id, $show_select_all, $add_edit_client_id = false ) {
256 ?>
257 <?php
258 /**
259 * Action: mainwp_before_select_sites_list
260 *
261 * Fires before the Select Sites list.
262 *
263 * @param object $websites Object containing child sites info.
264 *
265 * @since 4.1
266 */
267 do_action( 'mainwp_before_select_sites_list', $websites );
268 ?>
269 <div id="mainwp-select-sites-body">
270 <div class="ui relaxed divided list" id="mainwp-select-sites-list">
271 <?php if ( ! $websites ) : ?>
272 <h2 class="ui icon header">
273 <i class="folder open outline icon"></i>
274 <div class="content"><?php esc_html_e( 'No Sites connected!', 'mainwp' ); ?></div>
275 <div class="ui divider hidden"></div>
276 <a href="admin.php?page=managesites&do=new" class="ui green button basic"><?php esc_html_e( 'Add Site', 'mainwp' ); ?></a>
277 </h2>
278 <?php
279 else :
280 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
281 $enable_site = true;
282 if ( false === $add_edit_client_id ) {
283 $enable_site = true;
284 } elseif ( 0 === intval( $add_edit_client_id ) && false !== $add_edit_client_id ) {
285 if ( 0 < intval( $website->client_id ) ) {
286 $enable_site = false;
287 }
288 } elseif ( is_numeric( $add_edit_client_id ) && intval( $add_edit_client_id ) > 0 ) {
289 if ( 0 < intval( $website->client_id ) && intval( $website->client_id ) !== intval( $add_edit_client_id ) ) {
290 $enable_site = false;
291 }
292 }
293
294 $selected = false;
295 if ( ( '' == $website->sync_errors || $enableOfflineSites ) && ! MainWP_System_Utility::is_suspended_site( $website ) && $enable_site ) {
296 $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
297 $disabled = '';
298 if ( $edit_site_id ) {
299 if ( $website->id == $edit_site_id ) {
300 $selected = true;
301 } else {
302 $disabled = 'disabled="disabled"';
303 }
304 }
305 ?>
306 <div title="<?php echo esc_html( $website->url ); ?>" class="mainwp_selected_sites_item ui <?php echo esc_html( $type ); ?> item <?php echo ( $selected ? 'selected_sites_item_checked' : '' ); ?>">
307 <input <?php echo $disabled; ?> type="<?php echo $type; ?>" name="<?php echo ( 'radio' === $type ? 'selected_sites' : 'selected_sites[]' ); ?>" siteid="<?php echo intval( $website->id ); ?>" value="<?php echo intval( $website->id ); ?>" id="selected_sites_<?php echo intval( $website->id ); ?>" <?php echo ( $selected ? 'checked="true"' : '' ); ?> />
308 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
309 <?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
310 </label>
311 </div>
312 <?php
313 } else {
314 ?>
315 <div title="<?php echo esc_html( $website->url ); ?>" class="mainwp_selected_sites_item item ui <?php echo esc_html( $type ); ?> <?php echo ( $selected ? 'selected_sites_item_checked' : '' ); ?>">
316 <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
317 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
318 <?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
319 </label>
320 </div>
321 <?php
322 }
323 }
324 MainWP_DB::free_result( $websites );
325 endif;
326 ?>
327 </div>
328 </div>
329 <?php
330 /**
331 * Action: mainwp_after_select_sites_list
332 *
333 * Fires after the Select Sites list.
334 *
335 * @param object $websites Object containing child sites info.
336 *
337 * @since 4.1
338 */
339 do_action( 'mainwp_after_select_sites_list', $websites );
340 ?>
341 <?php
342 }
343
344 /**
345 * Method render_select_sites_staging()
346 *
347 * Render selected staging sites.
348 *
349 * @param mixed $selected_websites Selected Child Sites.
350 * @param mixed $edit_site_id Child Site ID to edit.
351 * @param string $type Selector type.
352 *
353 * @return void Render selected staging sites html.
354 *
355 * @uses \MainWP\Dashboard\MainWP_DB::query()
356 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
357 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
358 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
359 */
360 public static function render_select_sites_staging( $selected_websites, $edit_site_id, $type = 'checkbox' ) {
361 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'favi_icon' ), $is_staging = 'yes' ) );
362 ?>
363 <div id="mainwp-select-sites-body">
364 <div class="ui relaxed divided list" id="mainwp-select-staging-sites-list">
365 <?php if ( ! $websites ) : ?>
366 <h2 class="ui icon header">
367 <i class="folder open outline icon"></i>
368 <div class="content"><?php esc_html_e( 'No staging websites have been found!', 'mainwp' ); ?></div>
369 </h2>
370 <?php
371 else :
372 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
373 $selected = false;
374 if ( '' == $website->sync_errors && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
375 $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
376 $disabled = '';
377 if ( $edit_site_id ) {
378 if ( $website->id != $edit_site_id ) {
379 $disabled = 'disabled="disabled"';
380 }
381 }
382 ?>
383 <div title="<?php echo esc_html( $website->url ); ?>" class="mainwp_selected_sites_item ui <?php echo esc_html( $type ); ?> item <?php echo ( $selected ? 'selected_sites_item_checked' : '' ); ?>">
384 <input <?php echo $disabled; ?> type="<?php echo esc_html( $type ); ?>" name="<?php echo ( 'radio' === $type ? 'selected_sites' : 'selected_sites[]' ); ?>" siteid="<?php echo intval( $website->id ); ?>" value="<?php echo intval( $website->id ); ?>" id="selected_sites_<?php echo intval( $website->id ); ?>" <?php echo ( $selected ? 'checked="true"' : '' ); ?> />
385 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
386 <?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
387 </label>
388 </div>
389 <?php
390 } else {
391 ?>
392 <div title="<?php echo esc_html( $website->url ); ?>" class="mainwp_selected_sites_item item ui <?php echo esc_html( $type ); ?> <?php echo ( $selected ? 'selected_sites_item_checked' : '' ); ?>">
393 <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
394 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
395 <?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
396 </label>
397 </div>
398 <?php
399 }
400 }
401 MainWP_DB::free_result( $websites );
402 endif;
403 ?>
404 </div>
405 </div>
406 <?php
407 }
408
409 /**
410 * Method render_select_sites_group()
411 *
412 * Render selected sites group.
413 *
414 * @param array $groups Array of groups.
415 * @param mixed $selected_groups Selected groups.
416 * @param string $type Selector type.
417 *
418 * @return void Render selected sites group html.
419 */
420 public static function render_select_sites_group( $groups, $selected_groups, $type = 'checkbox' ) {
421 /**
422 * Action: mainwp_before_select_groups_list
423 *
424 * Fires before the Select Groups list.
425 *
426 * @param object $groups Object containing groups info.
427 *
428 * @since 4.1
429 */
430 do_action( 'mainwp_before_select_groups_list', $groups );
431 ?>
432 <div id="mainwp-select-sites-body">
433 <div class="ui relaxed divided list" id="mainwp-select-groups-list">
434 <?php
435 if ( 0 === count( $groups ) ) {
436 ?>
437 <h2 class="ui icon header">
438 <i class="folder open outline icon"></i>
439 <div class="content"><?php esc_html_e( 'No Tags created!', 'mainwp' ); ?></div>
440 <div class="ui divider hidden"></div>
441 <a href="admin.php?page=ManageGroups" class="ui green button basic"><?php esc_html_e( 'Create Tags', 'mainwp' ); ?></a>
442 </h2>
443 <?php
444 }
445 foreach ( $groups as $group ) {
446 $selected = in_array( $group->id, $selected_groups );
447 ?>
448 <div class="mainwp_selected_groups_item ui item <?php echo esc_html( $type ); ?> <?php echo ( $selected ? 'selected_groups_item_checked' : '' ); ?>">
449 <input type="<?php echo esc_html( $type ); ?>" name="<?php echo ( 'radio' === $type ? 'selected_groups' : 'selected_groups[]' ); ?>" value="<?php echo $group->id; ?>" id="selected_groups_<?php echo $group->id; ?>" <?php echo ( $selected ? 'checked="true"' : '' ); ?> />
450 <label for="selected_groups_<?php echo $group->id; ?>">
451 <?php echo stripslashes( $group->name ); ?>
452 </label>
453 </div>
454 <?php
455 }
456 ?>
457 </div>
458 </div>
459 <?php
460 /**
461 * Action: mainwp_after_select_groups_list
462 *
463 * Fires after the Select Groups list.
464 *
465 * @param object $groups Object containing groups info.
466 *
467 * @since 4.1
468 */
469 do_action( 'mainwp_after_select_groups_list', $groups );
470 }
471
472 /**
473 * Method render_top_header()
474 *
475 * Render top header.
476 *
477 * @param array $params Page parameters.
478 *
479 * @uses \MainWP\Dashboard\MainWP_DB::query()
480 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
481 * @uses \MainWP\Dashboard\MainWP_Menu::render_left_menu()
482 */
483 public static function render_top_header( $params = array() ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded
484
485 $title = isset( $params['title'] ) ? $params['title'] : '';
486 $which = isset( $params['which'] ) ? $params['which'] : '';
487
488 /**
489 * Filter: mainwp_header_title
490 *
491 * Filter the MainWP page title in the header element.
492 *
493 * @since 4.0
494 */
495 $title = apply_filters( 'mainwp_header_title', $title );
496
497 $show_menu = true;
498 $show_new_items = true;
499
500 if ( isset( $params['show_menu'] ) ) {
501 $show_menu = $params['show_menu'];
502 }
503
504 $more_tags = array(
505 'img' => array(
506 'src' => array(),
507 'width' => array(),
508 'height' => array(),
509 ),
510 );
511 $title = MainWP_Utility::esc_content( $title, 'note', $more_tags );
512
513 /**
514 * Filter: mainwp_header_left
515 *
516 * Filter the MainWP header element left side content.
517 *
518 * @since 4.0
519 */
520 $left = apply_filters( 'mainwp_header_left', $title );
521
522 $right = self::render_header_actions();
523
524 /**
525 * Filter: mainwp_header_right
526 *
527 * Filter the MainWP header element right side content.
528 *
529 * @since 4.0
530 */
531 $right = apply_filters( 'mainwp_header_right', $right );
532
533 if ( $show_menu ) {
534 MainWP_Menu::render_left_menu();
535 }
536
537 $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
538 if ( false === $sidebarPosition ) {
539 $sidebarPosition = 1;
540 }
541
542 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
543
544 $count_sites = MainWP_DB::instance()->get_websites_count();
545
546 if ( 0 == $count_sites ) {
547 if ( ! isset( $_GET['do'] ) ) {
548 echo self::render_modal_no_sites_note();
549 }
550 }
551
552 $siteViewMode = MainWP_Utility::get_siteview_mode();
553
554 $tour_id = '';
555 if ( isset( $_GET['page'] ) && 'mainwp_tab' == $_GET['page'] ) {
556 $tour_id = '13112';
557 } elseif ( isset( $_GET['page'] ) && 'managesites' == $_GET['page'] ) {
558 if ( isset( $_GET['do'] ) && 'new' == $_GET['do'] ) {
559 $tour_id = '13210';
560 } elseif ( isset( $_GET['do'] ) && 'bulknew' == $_GET['do'] ) {
561 $tour_id = '27274';
562 } elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
563 if ( 'grid' == $siteViewMode ) {
564 $tour_id = '27217';
565 } else {
566 $tour_id = '29331';
567 }
568 }
569 } elseif ( isset( $_GET['page'] ) && 'MonitoringSites' == $_GET['page'] ) {
570 $tour_id = '29003';
571 } elseif ( isset( $_GET['page'] ) && 'ManageClients' == $_GET['page'] ) {
572 if ( isset( $_GET['client_id'] ) ) {
573 $tour_id = '28258';
574 } else {
575 $tour_id = '28240';
576 }
577 } elseif ( isset( $_GET['page'] ) && 'ClientAddNew' == $_GET['page'] ) {
578 if ( isset( $_GET['client_id'] ) ) {
579 $tour_id = '28962';
580 } else {
581 $tour_id = '28256';
582 }
583 } elseif ( isset( $_GET['page'] ) && 'ClientAddField' == $_GET['page'] ) {
584 $tour_id = '28257';
585 } elseif ( isset( $_GET['page'] ) && 'PluginsManage' == $_GET['page'] ) {
586 $tour_id = '28510';
587 } elseif ( isset( $_GET['page'] ) && 'ManageGroups' == $_GET['page'] ) {
588 $tour_id = '27275';
589 } elseif ( isset( $_GET['page'] ) && 'UpdatesManage' == $_GET['page'] ) {
590 if ( isset( $_GET['tab'] ) && 'plugins-updates' == $_GET['tab'] ) {
591 $tour_id = '28259';
592 } elseif ( isset( $_GET['tab'] ) && 'themes-updates' == $_GET['tab'] ) {
593 $tour_id = '28447';
594 } elseif ( isset( $_GET['tab'] ) && 'wordpress-updates' == $_GET['tab'] ) {
595 $tour_id = '29005';
596 } elseif ( isset( $_GET['tab'] ) && 'translations-updates' == $_GET['tab'] ) {
597 $tour_id = '29007';
598 } elseif ( isset( $_GET['tab'] ) && 'abandoned-plugins' == $_GET['tab'] ) {
599 $tour_id = '29008';
600 } elseif ( isset( $_GET['tab'] ) && 'abandoned-themes' == $_GET['tab'] ) {
601 $tour_id = '29009';
602 } elseif ( isset( $_GET['tab'] ) && 'plugin-db-updates' == $_GET['tab'] ) {
603 $tour_id = '33161';
604 } else {
605 $tour_id = '28259';
606 }
607 } elseif ( isset( $_GET['page'] ) && 'PluginsInstall' == $_GET['page'] ) {
608 $tour_id = '29011';
609 } elseif ( isset( $_GET['page'] ) && 'PluginsAutoUpdate' == $_GET['page'] ) {
610 $tour_id = '29015';
611 } elseif ( isset( $_GET['page'] ) && 'PluginsIgnore' == $_GET['page'] ) {
612 $tour_id = '29018';
613 } elseif ( isset( $_GET['page'] ) && 'PluginsIgnoredAbandoned' == $_GET['page'] ) {
614 $tour_id = '29329';
615 } elseif ( isset( $_GET['page'] ) && 'ThemesManage' == $_GET['page'] ) {
616 $tour_id = '28511';
617 } elseif ( isset( $_GET['page'] ) && 'ThemesInstall' == $_GET['page'] ) {
618 $tour_id = '29010';
619 } elseif ( isset( $_GET['page'] ) && 'ThemesAutoUpdate' == $_GET['page'] ) {
620 $tour_id = '29016';
621 } elseif ( isset( $_GET['page'] ) && 'ThemesIgnore' == $_GET['page'] ) {
622 $tour_id = '29019';
623 } elseif ( isset( $_GET['page'] ) && 'ThemesIgnoredAbandoned' == $_GET['page'] ) {
624 $tour_id = '29330';
625 } elseif ( isset( $_GET['page'] ) && 'UserBulkManage' == $_GET['page'] ) {
626 $tour_id = '28574';
627 } elseif ( isset( $_GET['page'] ) && 'UserBulkAdd' == $_GET['page'] ) {
628 $tour_id = '28575';
629 } elseif ( isset( $_GET['page'] ) && 'BulkImportUsers' == $_GET['page'] ) {
630 $tour_id = '28736';
631 } elseif ( isset( $_GET['page'] ) && 'UpdateAdminPasswords' == $_GET['page'] ) {
632 $tour_id = '28737';
633 } elseif ( isset( $_GET['page'] ) && 'PostBulkManage' == $_GET['page'] ) {
634 $tour_id = '28796';
635 } elseif ( isset( $_GET['page'] ) && 'PostBulkAdd' == $_GET['page'] ) {
636 $tour_id = '28799';
637 } elseif ( isset( $_GET['page'] ) && 'PageBulkManage' == $_GET['page'] ) {
638 $tour_id = '29045';
639 } elseif ( isset( $_GET['page'] ) && 'PageBulkAdd' == $_GET['page'] ) {
640 $tour_id = '29048';
641 } elseif ( isset( $_GET['page'] ) && 'Extensions' == $_GET['page'] ) {
642 $tour_id = '28800';
643 } elseif ( isset( $_GET['page'] ) && 'Settings' == $_GET['page'] ) {
644 $tour_id = '28883';
645 } elseif ( isset( $_GET['page'] ) && 'SettingsAdvanced' == $_GET['page'] ) {
646 $tour_id = '28886';
647 } elseif ( isset( $_GET['page'] ) && 'SettingsEmail' == $_GET['page'] ) {
648 $tour_id = '29054';
649 } elseif ( isset( $_GET['page'] ) && 'MainWPTools' == $_GET['page'] ) {
650 $tour_id = '29272';
651 } elseif ( isset( $_GET['page'] ) && 'RESTAPI' == $_GET['page'] ) {
652 $tour_id = '29273';
653 } elseif ( isset( $_GET['page'] ) && 'ServerInformation' == $_GET['page'] ) {
654 $tour_id = '28873';
655 } elseif ( isset( $_GET['page'] ) && 'ServerInformationCron' == $_GET['page'] ) {
656 $tour_id = '28874';
657 } elseif ( isset( $_GET['page'] ) && 'ErrorLog' == $_GET['page'] ) {
658 $tour_id = '28876';
659 } elseif ( isset( $_GET['page'] ) && 'ActionLogs' == $_GET['page'] ) {
660 $tour_id = '28877';
661 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Jetpack-Protect-Extension' == $_GET['page'] ) {
662 $tour_id = '31700';
663 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Jetpack-Scan-Extension' == $_GET['page'] ) {
664 $tour_id = '31694';
665 } elseif ( isset( $_GET['page'] ) && 'Extensions-Termageddon-For-Mainwp' == $_GET['page'] ) {
666 $tour_id = '32104';
667 } elseif ( isset( $_GET['page'] ) && 'Extensions-Advanced-Uptime-Monitor-Extension' == $_GET['page'] ) {
668 $tour_id = '32149';
669 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Custom-Dashboard-Extension' == $_GET['page'] ) {
670 $tour_id = '32150';
671 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Updraftplus-Extension' == $_GET['page'] ) {
672 $tour_id = '32151';
673 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Sucuri-Extension' == $_GET['page'] ) {
674 $tour_id = '32152';
675 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Clean-And-Lock-Extension' == $_GET['page'] ) {
676 $tour_id = '32153';
677 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' == $_GET['page'] ) {
678 $tour_id = '32851';
679 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Buddy-Extension' == $_GET['page'] ) {
680 $tour_id = '33064';
681 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Backwpup-Extension' == $_GET['page'] ) {
682 $tour_id = '32923';
683 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Ssl-Monitor-Extension' == $_GET['page'] ) {
684 $tour_id = '33164';
685 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Cache-Control-Extension' == $_GET['page'] ) {
686 $tour_id = '33167';
687 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Maintenance-Extension' == $_GET['page'] ) {
688 $tour_id = '33301';
689 } elseif ( isset( $_GET['page'] ) && 'Extensions-Mainwp-Domain-Monitor-Extension' == $_GET['page'] ) {
690 $tour_id = '33300';
691 }
692
693 ?>
694 <div class="ui segment right sites sidebar" style="padding:0px" id="mainwp-sites-menu-sidebar">
695 <div class="ui segment" style="margin-bottom:0px">
696 <div class="ui header"><?php esc_html_e( 'Quick Site Shortcuts', 'mainwp' ); ?></div>
697 </div>
698 <div class="ui fitted divider"></div>
699 <div class="ui segment" style="margin-bottom:0px">
700 <div class="ui mini fluid icon input" <?php echo $websites ? '' : 'style="display: none;"'; ?> >
701 <input type="text" id="mainwp-sites-menu-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" />
702 <i class="filter icon"></i>
703 </div>
704 </div>
705 <div class="ui fluid vertical accordion menu" id="mainwp-sites-sidebar-menu" style="margin-top:0px;border-radius:0px;box-shadow:none;">
706 <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
707 <div class="item mainwp-site-menu-item">
708 <a class="title">
709 <i class="dropdown icon"></i>
710 <label><?php echo esc_html( $website->name ); ?></label>
711 </a>
712 <div class="content">
713 <div class="ui link tiny list">
714 <a class="item" href="<?php echo 'admin.php?page=managesites&dashboard=' . $website->id; ?>">
715 <i class="grid layout icon"></i>
716 <?php esc_html_e( 'Overview', 'mainwp' ); ?>
717 </a>
718 <a class="item" href="<?php echo 'admin.php?page=managesites&updateid=' . $website->id; ?>">
719 <i class="sync alternate icon"></i>
720 <?php esc_html_e( 'Updates', 'mainwp' ); ?>
721 </a>
722 <a class="item" href="<?php echo 'admin.php?page=managesites&id=' . $website->id; ?>">
723 <i class="edit icon"></i>
724 <?php esc_html_e( 'Edit Site', 'mainwp' ); ?>
725 </a>
726 <a class="item" href="<?php echo 'admin.php?page=managesites&scanid=' . $website->id; ?>">
727 <i class="shield icon"></i>
728 <?php esc_html_e( 'Security Scan', 'mainwp' ); ?>
729 </a>
730 <a class="item" target="_blank" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $website->id; ?>&_opennonce=<?php echo wp_create_nonce( 'mainwp-admin-nonce' ); ?>">
731 <i class="sign in icon"></i>
732 <?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?>
733 </a>
734 <a class="item" target="_blank" href="<?php echo esc_url( $website->url ); ?>">
735 <i class="globe icon"></i>
736 <?php esc_html_e( 'Visit Site', 'mainwp' ); ?>
737 </a>
738 <?php
739 /**
740 * Action: mainwp_quick_sites_shortcut
741 *
742 * Adds a new shortcut item in the Quick Sites Shortcuts sidebar menu.
743 *
744 * @param array $website Array containing the child site data.
745 *
746 * Suggested HTML markup:
747 *
748 * <a class="item" href="your custom URL">
749 * <i class="your custom icon"></i>
750 * Your custom label text
751 * </a>
752 *
753 * @since 4.1
754 */
755 do_action( 'mainwp_quick_sites_shortcut', $website );
756 ?>
757 </div>
758 </div>
759 </div>
760 <?php } ?>
761 </div>
762 </div>
763 <div class="ui segment right wide help sidebar" id="mainwp-documentation-sidebar">
764 <div class="ui header"><?php esc_html_e( 'MainWP Guided Tours', 'mainwp' ); ?> <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></div>
765 <div class="ui hidden divider"></div>
766 <div class="ui info message" style="display:block!important;">
767 <?php echo sprintf( esc_html__( 'This feature is implemented using Javascript provided by Usetiful and is subject to the %sUsetiful Privacy Policy%s.', 'mainwp' ), '<a href="https://www.usetiful.com/privacy-policy" target="_blank">', '</a>' ); ?>
768 </div>
769 <div class="ui hidden divider"></div>
770 <div class="ui toggle checkbox">
771 <input type="checkbox" id="mainwp-select-guided-tours-option" onchange="mainwp_guidedtours_onchange(this);"<?php echo ( ( 1 == get_option( 'mainwp_enable_guided_tours', 0 ) ) ? 'checked="true"' : '' ); ?> /> <label><?php esc_html_e( 'Switch to enable or disable tours.', 'mainwp' ); ?></label>
772 </div>
773 <div class="ui hidden divider"></div>
774 <?php if ( 1 == get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
775 <p><?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?></p>
776 <p><?php esc_html_e( 'Click the Start Page Tour button to start the guided tour for the current page.', 'mainwp' ); ?></p>
777 <div class="ui hidden divider"></div>
778 <a href="javacscript:void(0);" id="mainwp-start-page-tour-button" class="ui big green fluid basic button" tour-id="<?php esc_attr_e( $tour_id ); ?>"><?php esc_html_e( 'Start Page Tour', 'mainwp' ); ?></a>
779 <?php if ( isset( $_GET['page'] ) && 'mainwp_tab' == $_GET['page'] ) : ?>
780 <div class="ui hidden divider"></div>
781 <a href="javacscript:void(0);" id="mainwp-interface-tour-button" class="ui big green fluid basic button"><?php esc_html_e( 'MainWP Interface Basics Tour', 'mainwp' ); ?></a>
782 <?php endif; ?>
783 <?php endif; ?>
784 <div class="ui header"><?php esc_html_e( 'MainWP Documenation', 'mainwp' ); ?></div>
785 <div class="ui hidden divider"></div>
786 <?php
787 /**
788 * Action: mainwp_help_sidebar_content
789 *
790 * Fires Help sidebar content
791 *
792 * @since 4.0
793 */
794 do_action( 'mainwp_help_sidebar_content' );
795 ?>
796 <div class="ui hidden divider"></div>
797 <a href="https://kb.mainwp.com/" class="ui big green fluid button"><?php esc_html_e( 'Help Documentation', 'mainwp' ); ?></a>
798 <div class="ui hidden divider"></div>
799 <div id="mainwp-sticky-help-button" class="" style="position: absolute; bottom: 1em; left: 1em; right: 1em;">
800 <a href="https://managers.mainwp.com/" target="_blank" class="ui fluid button"><?php esc_html_e( 'Still Need Help?', 'mainwp' ); ?></a>
801 </div>
802 </div>
803 <?php
804 /**
805 * Action: mainwp_before_mainwp_content_wrap
806 *
807 * Fires before the #mainwp-content-wrap element.
808 *
809 * @param array $websites Array containing the child site data.
810 *
811 * @since 4.1
812 */
813 do_action( 'mainwp_before_mainwp_content_wrap', $websites );
814 global $wp_version;
815 $fix_menu_overflow = 1;
816 if ( version_compare( $wp_version, '5.5.3', '>' ) ) {
817 $fix_menu_overflow = 2;
818 }
819
820 if ( 'page_clients_overview' !== $which ) {
821 ?>
822
823 <div class="ui modal" id="mainwp-overview-screen-options-modal">
824 <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
825 <div class="content ui form">
826 <?php
827 /**
828 * Action: mainwp_overview_screen_options_top
829 *
830 * Fires at the top of the Sceen Options modal on the Overview page.
831 *
832 * @since 4.1
833 */
834 do_action( 'mainwp_overview_screen_options_top' );
835 ?>
836 <form method="POST" action="" name="mainwp_overview_screen_options_form" id="mainwp-overview-screen-options-form">
837 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
838 <input type="hidden" name="wp_nonce" value="<?php echo wp_create_nonce( 'MainWPScrOptions' ); ?>" />
839 <?php echo self::render_screen_options( false ); ?>
840 <?php
841 /**
842 * Action: mainwp_overview_screen_options_bottom
843 *
844 * Fires at the bottom of the Sceen Options modal on the Overview page.
845 *
846 * @since 4.1
847 */
848 do_action( 'mainwp_overview_screen_options_bottom' );
849 ?>
850 </div>
851 <div class="actions">
852 <div class="ui two columns grid">
853 <div class="left aligned column">
854 <span data-tooltip="<?php esc_attr_e( 'Returns this page to the state it was in when installed. The feature also restores any widgets you have moved through the drag and drop feature on the page.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><input type="button" class="ui button" name="reset" id="reset-overview-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span>
855 </div>
856 <div class="ui right aligned column">
857 <input type="submit" class="ui green button" id="submit-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
858 <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
859 </div>
860 </div>
861 </div>
862
863 <input type="hidden" name="reset_overview_settings" value="" />
864 </form>
865 </div>
866 <?php } ?>
867
868 <div class="mainwp-content-wrap <?php echo empty( $sidebarPosition ) ? 'mainwp-sidebar-left' : ''; ?>" menu-overflow="<?php echo intval( $fix_menu_overflow ); ?>">
869 <?php
870 /**
871 * Action: mainwp_before_header
872 *
873 * Fires before the MainWP header element.
874 *
875 * @param array $websites Array containing the child site data.
876 *
877 * @since 4.0
878 */
879 do_action( 'mainwp_before_header', $websites );
880
881 ?>
882 <div id="mainwp-top-header" class="">
883 <div class="ui grid">
884
885 <div class="five wide column"><h4 class="mainwp-page-title"><?php echo $left; ?></h4></div>
886
887 <div class="two wide column middle aligned right aligned">
888 <?php if ( isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) : ?>
889 <select class="ui mini selection fluid dropdown" id="mainwp-jump-to-site-overview-dropdown">
890 <?php $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); ?>
891 <option class="item"><?php esc_html_e( 'Jump to site overview...', 'mainwp' ); ?></option>
892 <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
893 <option class="item" value="<?php echo esc_attr( $website->id ); ?>"><?php echo esc_html( $website->name ); ?></option>
894 <?php } ?>
895 <?php MainWP_DB::free_result( $websites ); ?>
896 </select>
897 <?php endif; ?>
898 </div>
899 <div class="nine wide right aligned column"><?php echo $right; ?></div>
900
901 </div>
902 </div>
903
904 <?php if ( 1 == get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
905 <script type="text/javascript">
906 jQuery( document ).ready( function() {
907 jQuery( '#mainwp-start-page-tour-button' ).on( 'click', function() {
908 var tourId = jQuery( this ).attr( 'tour-id' );
909 jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
910 window.USETIFUL.tour.start( parseInt( tourId ) );
911 } );
912 jQuery( '#mainwp-interface-tour-button' ).on( 'click', function() {
913 jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
914 window.USETIFUL.tour.start( 13282 );
915 } );
916 } );
917 </script>
918 <?php endif; ?>
919
920 <script type="text/javascript">
921 jQuery( document ).ready( function () {
922
923 jQuery( '#mainwp-jump-to-site-overview-dropdown' ).on( 'change', function() {
924 var site_id = jQuery( this ).val();
925 window.location.href = 'admin.php?page=managesites&dashboard=' + site_id;
926 } );
927
928 jQuery( '#mainwp-sites-menu-sidebar' ).prependTo( 'body' );
929 jQuery( '#mainwp-documentation-sidebar' ).prependTo( 'body' );
930 jQuery( 'body > div#wpwrap' ).addClass( 'pusher' );
931
932 jQuery( '.ui.sticky' ).sticky( { pushing: false } ).sticky();
933
934 jQuery( '#mainwp-help-sidebar' ).on( 'click', function() {
935 jQuery( '.ui.help.sidebar' ).sidebar( {
936 transition: 'overlay'
937 } );
938 jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' );
939 return false;
940 } );
941 jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() {
942 jQuery( '.ui.sites.sidebar' ).sidebar( {
943 transition: 'overlay',
944 'onShow': function() {
945 jQuery( '#mainwp-sites-menu-filter' ).focus();
946 }
947 } );
948 jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' );
949 return false;
950 } );
951 jQuery( '#mainwp-sites-sidebar-menu' ).accordion();
952 } );
953 </script>
954 <?php
955 /**
956 * Action: mainwp_after_header
957 *
958 * Fires after the MainWP header element.
959 *
960 * @param array $websites Array containing the child site data.
961 *
962 * @since 4.0
963 */
964 do_action( 'mainwp_after_header', $websites );
965 ?>
966 <?php
967 }
968
969
970 /**
971 * Method render_showhide_columns_settings()
972 *
973 * Render show/hide columns settings.
974 *
975 * @param array $cols Columns.
976 * @param array $show_columns Show Columns.
977 * @param string $what what.
978 */
979 public static function render_showhide_columns_settings( $cols, $show_columns, $what ) {
980 ?>
981 <div class="ui grid field">
982 <label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label>
983 <div class="ten wide column" data-tooltip="<?php echo esc_attr_e( 'Select columns that you want to hide.', 'mainwp' ); ?> data-inverted="" data-position="top left">
984 <ul>
985 <?php
986 foreach ( $cols as $name => $title ) {
987 $_selected = '';
988 if ( ! isset( $show_columns[ $name ] ) || 1 == $show_columns[ $name ] ) {
989 $_selected = 'checked';
990 }
991 ?>
992 <li>
993 <div class="ui checkbox">
994 <input type="checkbox" id="mainwp_show_column_<?php echo esc_attr( $name ); ?>" name="mainwp_show_columns[]" <?php echo $_selected; ?> value="<?php echo esc_attr( $name ); ?>">
995 <label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
996 </div>
997 <input type="hidden" name="mainwp_columns_name[]" value="<?php echo esc_attr( $name ); ?>">
998 </li>
999 <?php
1000 }
1001 ?>
1002 </ul>
1003 </div>
1004
1005 </div>
1006 <?php
1007
1008 $input_name = '';
1009 if ( 'post' === $what ) {
1010 $input_name = 'mainwp_manageposts_show_columns_settings';
1011 } elseif ( 'page' === $what ) {
1012 $input_name = 'mainwp_managepages_show_columns_settings';
1013 } elseif ( 'user' === $what ) {
1014 $input_name = 'mainwp_manageusers_show_columns_settings';
1015 }
1016
1017 if ( ! empty( $input_name ) ) {
1018 ?>
1019 <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1020 <?php
1021 }
1022 }
1023
1024 /**
1025 * Method render_second_top_header()
1026 *
1027 * Render second top header.
1028 *
1029 * @param string $which Current page.
1030 *
1031 * @return void Render second top header html.
1032 */
1033 public static function render_second_top_header( $which = '' ) {
1034
1035 /**
1036 * Action: mainwp_before_subheader
1037 *
1038 * Fires before the MainWP sub-header element.
1039 *
1040 * @since 4.0
1041 */
1042 do_action( 'mainwp_before_subheader' );
1043 if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) {
1044 ?>
1045 <div class="mainwp-sub-header">
1046 <?php if ( 'overview' === $which ) : ?>
1047 <div class="ui stackable grid">
1048 <div class="column full">
1049 <?php self::gen_groups_sites_selection(); ?>
1050 </div>
1051 </div>
1052 <?php endif; ?>
1053 <?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?>
1054 <?php
1055 /**
1056 * Action: mainwp_managesites_tabletop
1057 *
1058 * Fires at the table top on the Manage Sites and Monitoring page.
1059 *
1060 * @since 4.0
1061 */
1062 do_action( 'mainwp_managesites_tabletop' );
1063 ?>
1064
1065 <?php else : ?>
1066 <?php
1067 /**
1068 * Action: mainwp_subheader_actions
1069 *
1070 * Fires at the subheader element to hook available actions.
1071 *
1072 * @since 4.0
1073 */
1074 do_action( 'mainwp_subheader_actions' );
1075 ?>
1076 <?php endif; ?>
1077 </div>
1078 <?php
1079 }
1080 /**
1081 * Action: mainwp_after_subheader
1082 *
1083 * Fires after the MainWP sub-header element.
1084 *
1085 * @since 4.0
1086 */
1087 do_action( 'mainwp_after_subheader' );
1088 }
1089
1090 /**
1091 * Method gen_groups_sites_selection()
1092 *
1093 * Generate group sites selection box.
1094 *
1095 * @return void Render group sites selection box.
1096 *
1097 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_manage_sites()
1098 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_not_empty_groups()
1099 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1100 * @uses \MainWP\Dashboard\MainWP_DB::query()
1101 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1102 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1103 */
1104 public static function gen_groups_sites_selection() {
1105 $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
1106 $websites = MainWP_DB::instance()->query( $sql );
1107 $g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1;
1108 $s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1;
1109 ?>
1110 <div class="column full wide">
1111 <select id="mainwp_top_quick_jump_group" class="ui dropdown">
1112 <option value="" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1113 <option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1114 <?php
1115 $groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites();
1116 foreach ( $groups as $group ) {
1117 ?>
1118 <option class="item" <?php echo ( $g == $group->id ) ? 'selected' : ''; ?> value="<?php echo $group->id; ?>"><?php echo stripslashes( $group->name ); ?></option>
1119 <?php
1120 }
1121 ?>
1122 </select>
1123 <select class="ui dropdown" id="mainwp_top_quick_jump_page">
1124 <option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1125 <option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1126 <?php
1127 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1128 ?>
1129 <option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s == $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo stripslashes( $website->name ); ?></option>
1130 <?php
1131 }
1132 ?>
1133 </select>
1134 </div>
1135 <script type="text/javascript">
1136 jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () {
1137 var jumpid = jQuery( this ).val();
1138 window.location = 'admin.php?page=managesites&g=' + jumpid;
1139 } );
1140 jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () {
1141 var jumpid = jQuery( this ).val();
1142 if ( jumpid == -1 )
1143 window.location = 'admin.php?page=managesites&s=' + jumpid;
1144 else
1145 window.location = 'admin.php?page=managesites&dashboard=' + jumpid;
1146 } );
1147 </script>
1148 <?php
1149 MainWP_DB::free_result( $websites );
1150 }
1151
1152 /**
1153 * Method render_header_actions()
1154 *
1155 * Render header action buttons,
1156 * (Sync|Add|Options|Community|User|Updates).
1157 *
1158 * @return mixed $output Render header action buttons html.
1159 *
1160 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1161 */
1162 public static function render_header_actions() { //phpcs:ignore -- complex method.
1163 $sites_count = MainWP_DB::instance()->get_websites_count();
1164 $website_id = '';
1165 $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1166 $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1167 $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
1168 ob_start();
1169 if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) :
1170 $id = 0;
1171 if ( isset( $_GET['dashboard'] ) ) {
1172 $id = intval( $_GET['dashboard'] );
1173 } elseif ( isset( $_GET['id'] ) ) {
1174 $id = intval( $_GET['id'] );
1175 } elseif ( isset( $_GET['updateid'] ) ) {
1176 $id = intval( $_GET['updateid'] );
1177 } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1178 $id = intval( $_GET['emailsettingsid'] );
1179 } elseif ( isset( $_GET['scanid'] ) ) {
1180 $id = intval( $_GET['scanid'] );
1181 }
1182
1183 $website = MainWP_DB::instance()->get_website_by_id( $id );
1184
1185 if ( $id && $website && '' != $website->sync_errors ) :
1186 ?>
1187 <a href="#" class="mainwp-updates-overview-reconnect-site ui green button" siteid="<?php echo $website->id; ?>" data-position="bottom right" data-tooltip="Reconnect <?php echo stripslashes( $website->name ); ?>" data-inverted=""><?php esc_html_e( 'Reconnect Site', 'mainwp' ); ?></a>
1188 <?php else : ?>
1189 <button class="ui button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?>" id="mainwp-sync-sites" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Get fresh data from your child sites.', 'mainwp' ); ?>">
1190 <i class="sync icon mainwp-sync-button-icon"></i>
1191 <span class="mainwp-sync-button-text">
1192 <?php
1193 /**
1194 * Filter: mainwp_main_sync_button_text
1195 *
1196 * Filters the Sync Dashboard with Child Sites button text.
1197 *
1198 * @since 4.1
1199 */
1200 echo esc_html( apply_filters( 'mainwp_site_sync_button_text', esc_html__( 'Sync Site', 'mainwp' ) ) );
1201 ?>
1202 </span>
1203 </button>
1204 <?php
1205 endif;
1206 else :
1207 ?>
1208 <button class="ui button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?> " id="mainwp-sync-sites" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Get fresh data from your child sites.', 'mainwp' ); ?>">
1209 <i class="sync icon mainwp-sync-button-icon"></i>
1210 <span class="mainwp-sync-button-text">
1211 <?php
1212 /**
1213 * Filter: mainwp_main_sync_button_text
1214 *
1215 * Filters the Sync Dashboard with Child Sites button text.
1216 *
1217 * @since 4.1
1218 */
1219 echo esc_html( apply_filters( 'mainwp_main_sync_button_text', esc_html__( 'Sync Dashboard with Sites', 'mainwp' ) ) );
1220 ?>
1221 </span>
1222 </button>
1223 <?php
1224 endif;
1225 ?>
1226
1227 <div class="ui <?php echo ( 0 == $sites_count ? 'green' : '' ); ?> buttons" id="mainwp-add-new-buttons">
1228 <a class="ui icon button" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Add a new Website to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><i class="plus icon"></i></a>
1229 <a class="ui button" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Add a new Website to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Add New', 'mainwp' ); ?></a>
1230 <div class="ui floating dropdown icon button" style="z-index: 999;" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'More options', 'mainwp' ); ?>">
1231 <i class="dropdown icon"></i>
1232 <div class="menu">
1233 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Website to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Website', 'mainwp' ); ?></a>
1234 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Post to your child sites', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=PostBulkAdd' ) ); ?>"><?php esc_html_e( 'Post', 'mainwp' ); ?></a>
1235 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Page to your child sites', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>"><?php esc_html_e( 'Page', 'mainwp' ); ?></a>
1236 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Install a new Plugin to your child sites', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=PluginsInstall' ) ); ?>"><?php esc_html_e( 'Plugin', 'mainwp' ); ?></a>
1237 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Install a new Theme to your child sites', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=ThemesInstall' ) ); ?>"><?php esc_html_e( 'Theme', 'mainwp' ); ?></a>
1238 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Create a new User to your child sites', 'mainwp' ); ?>" href="<?php echo esc_attr( admin_url( 'admin.php?page=UserBulkAdd' ) ); ?>"><?php esc_html_e( 'User', 'mainwp' ); ?></a>
1239 <?php
1240 /**
1241 * Action: mainwp_add_new_menu_option
1242 *
1243 * Fires at bottom of the Add New menu options list.
1244 *
1245 * Suggested HTML markup:
1246 * <a class="item" href="your custom URL">Your custom label</a>
1247 *
1248 * @since 4.1
1249 */
1250 do_action( 'mainwp_add_new_menu_option' );
1251 ?>
1252 </div>
1253 </div>
1254 </div>
1255 <?php if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) || isset( $_GET['cacheControlId'] ) ) : ?>
1256 <?php if ( isset( $_GET['dashboard'] ) ) : ?>
1257 <?php $website_id = intval( $_GET['dashboard'] ); ?>
1258 <?php elseif ( isset( $_GET['updateid'] ) ) : ?>
1259 <?php $website_id = intval( $_GET['updateid'] ); ?>
1260 <?php elseif ( isset( $_GET['emailsettingsid'] ) ) : ?>
1261 <?php $website_id = intval( $_GET['emailsettingsid'] ); ?>
1262 <?php elseif ( isset( $_GET['scanid'] ) ) : ?>
1263 <?php $website_id = intval( $_GET['scanid'] ); ?>
1264 <?php elseif ( isset( $_GET['cacheControlId'] ) ) : ?>
1265 <?php $website_id = intval( $_GET['cacheControlId'] ); ?>
1266 <?php else : ?>
1267 <?php $website_id = intval( $_GET['id'] ); ?>
1268 <?php endif; ?>
1269 <a id="mainwp-go-wp-admin-button" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $website_id; ?>&_opennonce=<?php echo 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"><i class="sign in icon"></i></a>
1270 <a id="mainwp-remove-site-button" href="#" site-id="<?php echo $website_id; ?>" data-tooltip="<?php esc_attr_e( 'Remove the site from your MainWP Dashboard.', 'mainwp' ); ?>" data-position="bottom right" data-inverted="" class="mainwp-remove-site-button ui red basic icon button" target="_blank"><i class="times icon"></i></a>
1271 <?php endif; ?>
1272 <?php if ( ( isset( $_GET['page'] ) && 'mainwp_tab' === $_GET['page'] ) || isset( $_GET['dashboard'] ) || in_array( $_GET['page'], $sidebar_pages ) ) : ?>
1273 <a id="mainwp-screen-options-button" class="ui button basic icon" onclick="jQuery( '#mainwp-overview-screen-options-modal' ).modal({allowMultiple:true}).modal( 'show' ); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_html_e( 'Page Settings', 'mainwp' ); ?>">
1274 <i class="cog icon"></i>
1275 </a>
1276 <?php endif; ?>
1277 <?php
1278 /**
1279 * Filter: mainwp_header_actions_right
1280 *
1281 * Filters the MainWP header element actions.
1282 *
1283 * @since 4.0
1284 */
1285 $actions = apply_filters( 'mainwp_header_actions_right', '' );
1286 if ( ! empty( $actions ) ) {
1287 echo $actions;
1288 }
1289 ?>
1290 <a class="ui button basic icon" id="mainwp-sites-sidebar" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Quick sites shortcuts', 'mainwp' ); ?>">
1291 <i class="globe icon"></i>
1292 </a>
1293 <a class="ui button basic icon" id="mainwp-help-sidebar" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Need help?', 'mainwp' ); ?>">
1294 <i class="life ring icon"></i>
1295 </a>
1296 <a id="mainwp-community-button" class="ui button basic icon" data-inverted="" data-position="bottom right" href="https://managers.mainwp.com/" target="_blank" data-tooltip="<?php esc_attr_e( 'MainWP Community', 'mainwp' ); ?>">
1297 <i class="discourse icon"></i>
1298 </a>
1299 <a id="mainwp-account-button" class="ui button basic icon" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to your MainWP Account at MainWP.com', 'mainwp' ); ?>" target="_blank" href="https://mainwp.com/my-account/">
1300 <i class="user icon"></i>
1301 </a>
1302 <?php
1303 $custom_theme = MainWP_Settings::get_instance()->get_current_user_theme();
1304 ?>
1305 <div id="mainwp-select-theme-button" class="ui button icon mainwp-selecte-theme-button" custom-theme="default" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_html_e( 'Select MainWP theme', 'mainwp' ); ?>">
1306 <i class="sun icon"></i>
1307 </div>
1308 <?php
1309 $all_updates = wp_get_update_data();
1310 if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) {
1311 ?>
1312 <a id="mainwp-available-dashboard-updates-button" class="ui red icon button" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Your MainWP Dashboard sites needs your attention. Please check the available updates', 'mainwp' ); ?>" href="update-core.php">
1313 <i class="exclamation triangle icon"></i>
1314 </a>
1315 <?php
1316 }
1317 $output = ob_get_clean();
1318 return $output;
1319 }
1320
1321 /**
1322 * Method render_page_navigation()
1323 *
1324 * Render page navigation.
1325 *
1326 * @param array $subitems [access, active, style].
1327 * @param null $name_caller Menu Name.
1328 */
1329 public static function render_page_navigation( $subitems = array(), $name_caller = null ) {
1330
1331 /**
1332 * Filter: mainwp_page_navigation
1333 *
1334 * Filters MainWP page navigation menu items.
1335 *
1336 * @since 4.0
1337 */
1338 $subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller );
1339 ?>
1340 <div id="mainwp-page-navigation-wrapper">
1341 <div class="ui secondary green pointing menu stackable mainwp-page-navigation">
1342 <?php
1343
1344 if ( is_array( $subitems ) ) {
1345 foreach ( $subitems as $item ) {
1346
1347 if ( ! is_array( $item ) ) {
1348 continue;
1349 }
1350
1351 if ( isset( $item['access'] ) && ! $item['access'] ) {
1352 continue;
1353 }
1354
1355 $active = '';
1356 if ( isset( $item['active'] ) && $item['active'] ) {
1357 $active = 'active';
1358 }
1359 $style = '';
1360 if ( isset( $item['style'] ) ) {
1361 $style = 'style="' . $item['style'] . '"';
1362 }
1363
1364 ?>
1365 <a class="<?php echo esc_attr( $active ); ?> item" <?php echo esc_attr( $style ); ?> href="<?php echo esc_url( $item['href'] ); ?>">
1366 <?php echo esc_html( $item['title'] ); ?> <?php echo isset( $item['after_title'] ) ? $item['after_title'] : ''; ?>
1367 </a>
1368 <?php
1369 }
1370 }
1371 do_action( 'mainwp_page_navigation_menu' );
1372 ?>
1373 </div>
1374 </div>
1375 <?php
1376 }
1377
1378 /**
1379 * Method render_header()
1380 *
1381 * Render page title.
1382 *
1383 * @param string $title Page title.
1384 *
1385 * @return void Render page title and hidden divider html.
1386 */
1387 public static function render_header( $title = '' ) {
1388 self::render_top_header( array( 'title' => $title ) );
1389 echo '<div class="ui hidden clearing fitted divider"></div>';
1390 echo '<div class="wrap">';
1391 }
1392
1393 /**
1394 * Method render_footer()
1395 *
1396 * Render page footer.
1397 *
1398 * @return void Render closing tags for page container.
1399 */
1400 public static function render_footer() {
1401 echo '</div>';
1402 echo '</div>';
1403 }
1404
1405 /**
1406 * Method add_widget_box()
1407 *
1408 * Customize WordPress add_meta_box() function.
1409 *
1410 * @param mixed $id Widget ID parameter.
1411 * @param mixed $callback Callback function.
1412 * @param null $screen Current page.
1413 * @param string|null $context right|null. If 3 columns then = 'middle'.
1414 * @param null $title Widget title.
1415 * @param string $priority high|core|default|low, Default: default.
1416 *
1417 * @return void Sets Global $mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ].
1418 *
1419 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1420 */
1421 public static function add_widget_box( $id, $callback, $screen = null, $context = null, $title = null, $priority = 'default' ) { // phpcs:ignore -- complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1422 /**
1423 * MainWP widget boxes array.
1424 *
1425 * @global object
1426 */
1427 global $mainwp_widget_boxes;
1428
1429 $page = MainWP_System_Utility::get_page_id( $screen );
1430
1431 if ( empty( $page ) ) {
1432 return;
1433 }
1434
1435 if ( 'mainwp_page_manageclients' == $page ) {
1436 $overviewColumns = get_option( 'mainwp_number_clients_overview_columns', 2 );
1437 } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1438 $overviewColumns = get_option( 'mainwp_number_overview_columns', 2 );
1439 } else {
1440 $overviewColumns = apply_filters( 'mainwp_widget_boxes_number_columns', 2, $page );
1441 }
1442
1443 $contexts = array( 'left', 'right' );
1444 if ( 3 == $overviewColumns ) {
1445 $contexts[] = 'middle';
1446 }
1447
1448 if ( null === $context || ! in_array( $context, $contexts ) ) {
1449 $context = 'right';
1450 }
1451
1452 if ( ! isset( $mainwp_widget_boxes ) ) {
1453 $mainwp_widget_boxes = array();
1454 }
1455 if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
1456 $mainwp_widget_boxes[ $page ] = array();
1457 }
1458 if ( ! isset( $mainwp_widget_boxes[ $page ][ $context ] ) ) {
1459 $mainwp_widget_boxes[ $page ][ $context ] = array();
1460 }
1461
1462 foreach ( array_keys( $mainwp_widget_boxes[ $page ] ) as $a_context ) {
1463 foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
1464 if ( ! isset( $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
1465 continue;
1466 }
1467
1468 // If box previously deleted, don't add.
1469 if ( false == $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) {
1470 return;
1471 }
1472
1473 // If no priority given and id already present, use existing priority.
1474 if ( empty( $priority ) ) {
1475 $priority = $a_priority;
1476
1477 /*
1478 * Else, if we're adding to the sorted priority, we don't know the title
1479 * or callback. Grab them from the previously added context/priority.
1480 */
1481 } elseif ( 'sorted' == $priority ) {
1482 $title = $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
1483 $callback = $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
1484 }
1485
1486 // An id can be in only one context.
1487 if ( $priority != $a_priority || $context != $a_context ) {
1488 unset( $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
1489 }
1490 }
1491 }
1492
1493 if ( ! isset( $mainwp_widget_boxes[ $page ][ $context ] ) ) {
1494 $mainwp_widget_boxes[ $page ][ $context ] = array();
1495 }
1496
1497 if ( empty( $priority ) ) {
1498 $priority = 'default';
1499 }
1500
1501 if ( empty( $title ) ) {
1502 $title = 'No Title';
1503 }
1504 $mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
1505 'id' => $id,
1506 'title' => $title,
1507 'callback' => $callback,
1508 );
1509 }
1510
1511 /**
1512 * Method do_widget_boxes()
1513 *
1514 * Customize WordPress do_meta_boxes() function.
1515 *
1516 * @param mixed $screen Current page.
1517 * @param string|null $context right|null. If 3 columns then = 'middle'.
1518 * @param string $object Empty string.
1519 *
1520 * @return void Renders widget container box.
1521 *
1522 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1523 */
1524 public static function do_widget_boxes( $screen, $context = null, $object = '' ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1525 global $mainwp_widget_boxes;
1526 static $already_sorted = false;
1527
1528 $page = MainWP_System_Utility::get_page_id( $screen );
1529
1530 if ( empty( $page ) ) {
1531 return;
1532 }
1533
1534 if ( 'mainwp_page_manageclients' == $page ) {
1535 $overviewColumns = get_option( 'mainwp_number_clients_overview_columns', 2 );
1536 } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1537 $overviewColumns = get_option( 'mainwp_number_overview_columns', 2 );
1538 } else {
1539 $overviewColumns = apply_filters( 'mainwp_widget_boxes_number_columns', 2, $page );
1540 }
1541
1542 $contexts = array( 'left', 'right' );
1543 if ( 3 == $overviewColumns ) {
1544 $contexts[] = 'middle';
1545 }
1546
1547 if ( null == $context || ! in_array( $context, $contexts ) ) {
1548 $context = 'right';
1549 }
1550
1551 $sorted = get_user_option( 'mainwp_widgets_sorted_' . strtolower( $page ) );
1552
1553 if ( 'mainwp_page_manageclients' == $page ) {
1554 $sorted_array = $sorted;
1555 $sorted = '';
1556 $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0;
1557 if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
1558 $sorted = $sorted_array[ $client_id ];
1559 }
1560 }
1561
1562 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose.
1563 if ( ! $already_sorted && $sorted ) {
1564 foreach ( explode( ',', $sorted ) as $val ) {
1565 list( $widget_context, $id ) = explode( ':', $val );
1566 if ( ! empty( $widget_context ) && ! empty( $id ) ) {
1567 self::add_widget_box( $id, null, $screen, $widget_context, null, $priority = 'sorted' );
1568 $already_sorted = true;
1569 }
1570 }
1571 }
1572
1573 if ( 'mainwp_page_manageclients' == $page ) {
1574 $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
1575 } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1576 $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
1577 } else {
1578 $show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
1579 }
1580
1581 if ( ! is_array( $show_widgets ) ) {
1582 $show_widgets = array();
1583 }
1584
1585 if ( isset( $mainwp_widget_boxes[ $page ][ $context ] ) ) {
1586 foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
1587 if ( isset( $mainwp_widget_boxes[ $page ][ $context ][ $priority ] ) ) {
1588 foreach ( (array) $mainwp_widget_boxes[ $page ][ $context ][ $priority ] as $box ) {
1589 if ( false == $box || ! isset( $box['callback'] ) ) {
1590 continue;
1591 }
1592
1593 // to avoid hidden widgets.
1594 if ( isset( $show_widgets[ $box['id'] ] ) && 0 == $show_widgets[ $box['id'] ] ) {
1595 continue;
1596 }
1597
1598 echo '<div class="column grid-item" id="widget-' . esc_html( $box['id'] ) . '">' . "\n";
1599 echo '<div class="ui segment mainwp-widget" >' . "\n";
1600
1601 /**
1602 * Action: mainwp_widget_content_top
1603 *
1604 * Fires at the top of widget content.
1605 *
1606 * @since 4.1
1607 */
1608 do_action( 'mainwp_widget_content_top', $box, $page );
1609
1610 call_user_func( $box['callback'], $object, $box );
1611
1612 /**
1613 * Action: mainwp_widget_content_bottom
1614 *
1615 * Fires at the bottom of widget content.
1616 *
1617 * @since 4.1
1618 */
1619 do_action( 'mainwp_widget_content_bottom', $box, $page );
1620
1621 echo "</div>\n";
1622 echo "</div>\n";
1623 }
1624 }
1625 }
1626 }
1627 }
1628
1629 /**
1630 * Method render_empty_bulk_actions()
1631 *
1632 * Render empty bulk actions when drop down is disabled.
1633 */
1634 public static function render_empty_bulk_actions() {
1635 ?>
1636 <select class="ui disabled dropdown" id="mainwp-bulk-actions">
1637 <option value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
1638 </select>
1639 <button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
1640 <?php
1641 }
1642
1643 /**
1644 * Method render_modal_install_plugin_theme()
1645 *
1646 * Render modal window for installing plugins & themes.
1647 *
1648 * @param string $what Which window to render, plugin|theme.
1649 */
1650 public static function render_modal_install_plugin_theme( $what = 'plugin' ) {
1651 ?>
1652 <div id="plugintheme-installation-progress-modal" class="ui modal">
1653 <div class="header">
1654 <?php
1655 if ( 'plugin' === $what ) {
1656 esc_html_e( 'Plugin Installation', 'mainwp' );
1657 } elseif ( 'theme' === $what ) {
1658 esc_html_e( 'Theme Installation', 'mainwp' );
1659 }
1660 ?>
1661 </div>
1662 <div class="ui green progress mainwp-modal-progress">
1663 <div class="bar"><div class="progress"></div></div>
1664 <div class="label"></div>
1665 </div>
1666 <div class="scrolling content">
1667 <?php
1668 /**
1669 * Action: mainwp_before_plugin_theme_install_progress
1670 *
1671 * Fires before the progress list in the install modal element.
1672 *
1673 * @since 4.1
1674 */
1675 do_action( 'mainwp_before_plugin_theme_install_progress' );
1676 ?>
1677 <div id="plugintheme-installation-queue"></div>
1678 <?php
1679 /**
1680 * Action: mainwp_after_plugin_theme_install_progress
1681 *
1682 * Fires after the progress list in the install modal element.
1683 *
1684 * @since 4.1
1685 */
1686 do_action( 'mainwp_after_plugin_theme_install_progress' );
1687 ?>
1688 </div>
1689 <div class="actions">
1690 <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1691 </div>
1692 </div>
1693 <?php
1694 }
1695
1696 /**
1697 * Method render_modal_upload_icon()
1698 *
1699 * Render modal window for upload plugins & themes icon.
1700 */
1701 public static function render_modal_upload_icon() {
1702
1703 ?>
1704 <div id="mainwp-upload-custom-icon-modal" class="ui modal">
1705 <div class="header">
1706 <?php
1707 esc_html_e( 'Update Icon', 'mainwp' );
1708 ?>
1709 </div>
1710 <div class="content" id="mainwp-upload-custom-icon-content">
1711 <form action="" method="post" enctype="multipart/form-data" name="uploadicon_form" id="uploadicon_form" class="">
1712 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1713 <div class="ui message" id="mainwp-message-zone-upload" style="display:none;"></div>
1714 <?php
1715 /**
1716 * Action: mainwp_after_upload_custom_icon
1717 *
1718 * Fires before the modal element.
1719 *
1720 * @since 4.3
1721 */
1722 do_action( 'mainwp_before_upload_custom_icon' );
1723 ?>
1724 <div class="ui form">
1725 <div class="ui grid field">
1726 <label class="six wide column middle aligned"><?php esc_html_e( 'Custom icon', 'mainwp' ); ?></label>
1727 <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1728 <input type="file" id="mainwp_upload_icon_uploader" name="mainwp_upload_icon_uploader[]" accept="image/*" data-inverted="" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" />
1729 </div>
1730 </div>
1731 <div class="ui grid field" id="mainwp_delete_image_field">
1732 <label class="six wide column middle aligned"></label>
1733 <div class="six wide column">
1734 <img class="ui tiny image" src="" /><br/>
1735 <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, delete image.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1736 <input type="checkbox"id="mainwp_delete_image_chk" />
1737 <label for="mainwp_delete_image_chk"><?php esc_html_e( 'Delete Image', 'mainwp' ); ?></label>
1738 </div>
1739 </div>
1740 </div>
1741 </div>
1742 <?php
1743 /**
1744 * Action: mainwp_after_upload_custom_icon
1745 *
1746 * Fires after the modal element.
1747 *
1748 * @since 4.3
1749 */
1750 do_action( 'mainwp_after_upload_custom_icon' );
1751 ?>
1752 </form>
1753 </div>
1754 <div class="actions">
1755 <div class="ui green button" id="update_custom_icon_btn"><?php esc_html_e( 'Update', 'mainwp' ); ?></div>
1756 <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1757 </div>
1758 </div>
1759 <?php
1760 }
1761
1762 /**
1763 * Method render_show_all_updates_button()
1764 *
1765 * Render show all updates button.
1766 *
1767 * @return void Render Show All Updates button html.
1768 */
1769 public static function render_show_all_updates_button() {
1770 ?>
1771 <a href="javascript:void(0)" class="ui mini button trigger-all-accordion">
1772 <?php
1773 /**
1774 * Filter: mainwp_show_all_updates_button_text
1775 *
1776 * Filters the Show All Updates button text.
1777 *
1778 * @since 4.1
1779 */
1780 echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', esc_html__( 'Show All Updates', 'mainwp' ) ) );
1781 ?>
1782 </a>
1783 <?php
1784 }
1785
1786 /**
1787 * Method render_sorting_icons()
1788 *
1789 * Render sorting up & down icons.
1790 *
1791 * @return void Render Sort up & down incon html.
1792 */
1793 public static function render_sorting_icons() {
1794 ?>
1795 <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"></i>
1796 <?php
1797 }
1798
1799 /**
1800 * Method render_modal_edit_notes()
1801 *
1802 * Render modal window for edit notes.
1803 *
1804 * @param string $what What modal window to render. Default = site.
1805 *
1806 * @return void
1807 */
1808 public static function render_modal_edit_notes( $what = 'site' ) {
1809 ?>
1810 <div id="mainwp-notes-modal" class="ui modal">
1811 <div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div>
1812 <div class="content" id="mainwp-notes-content">
1813 <div id="mainwp-notes-status" class="ui message hidden"></div>
1814 <?php
1815 /**
1816 * Action: mainwp_before_edit_site_note
1817 *
1818 * Fires before the site note content in the Edit Note modal element.
1819 *
1820 * @since 4.1
1821 */
1822 do_action( 'mainwp_before_edit_site_note' );
1823 ?>
1824 <div id="mainwp-notes-html"></div>
1825 <div id="mainwp-notes-editor" class="ui form" style="display:none;">
1826 <div class="field">
1827 <label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label>
1828 <textarea id="mainwp-notes-note"></textarea>
1829 </div>
1830 <div><?php esc_html_e( 'Allowed HTML tags:', 'mainwp' ); ?> &lt;p&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;br&gt;, &lt;hr&gt;, &lt;a&gt;, &lt;ul&gt;, &lt;ol&gt;, &lt;li&gt;, &lt;h1&gt;, &lt;h2&gt; </div>
1831 </div>
1832 <?php
1833 /**
1834 * Action: mainwp_after_edit_site_note
1835 *
1836 * Fires after the site note content in the Edit Note modal element.
1837 *
1838 * @since 4.1
1839 */
1840 do_action( 'mainwp_after_edit_site_note' );
1841 ?>
1842 </div>
1843 <div class="actions">
1844 <div class="ui grid">
1845 <div class="eight wide left aligned middle aligned column">
1846 <input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save Note', 'mainwp' ); ?>" style="display:none;"/>
1847 <input type="button" class="ui green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit Note', 'mainwp' ); ?>"/>
1848 </div>
1849 <div class="eight wide column">
1850 <input type="button" class="ui button" id="mainwp-notes-cancel" value="<?php esc_attr_e( 'Close', 'mainwp' ); ?>"/>
1851 <input type="hidden" id="mainwp-notes-websiteid" value=""/>
1852 <input type="hidden" id="mainwp-notes-slug" value=""/>
1853 <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
1854 <input type="hidden" id="mainwp-notes-itemid" value=""/>
1855 </div>
1856 </div>
1857 </div>
1858 </div>
1859
1860 <?php
1861 }
1862
1863 /**
1864 * No Sites Modal
1865 *
1866 * Renders modal window for notification when there are no connected sites.
1867 *
1868 * @return void
1869 */
1870 public static function render_modal_no_sites_note() {
1871 if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-no-sites-modal-notice' ) ) :
1872 ?>
1873 <div id="mainwp-no-sites-modal" class="ui small modal">
1874 <div class="content" id="mainwp-no-sites-modal-content" style="text-align:center">
1875 <div class="ui hidden divider"></div>
1876 <div class="ui hidden divider"></div>
1877 <h4><?php esc_html_e( 'Hi MainWP Manager, there is not anything to see here before connecting your first site.', 'mainwp' ); ?></h4>
1878 <div class="ui hidden divider"></div>
1879 <div class="ui hidden divider"></div>
1880 <a href="admin.php?page=managesites&do=new" class="ui big green button"><?php esc_html_e( 'Connect Your WordPress Site', 'mainwp' ); ?></a>
1881 <div class="ui hidden fitted divider"></div>
1882 <small><?php echo sprintf( esc_html__( 'or you can %1$sbulk import%2$s your sites.', 'mainwp' ), '<a href="admin.php?page=managesites&do=bulknew">', '</a>' ); ?></small>
1883 </div>
1884 <div class="actions">
1885 <div class="ui grid">
1886 <div class="eight wide left aligned middle aligned column">
1887 <a href="https://kb.mainwp.com/docs/add-site-to-your-dashboard/" class="ui basic green mini button" target="_blank"><?php esc_html_e( 'See How to Connect Sites', 'mainwp' ); ?></a>
1888 </div>
1889 <div class="eight wide column">
1890 <input type="button" class="ui mini basic cancel button mainwp-notice-dismiss" notice-id="mainwp-no-sites-modal-notice" value="<?php esc_attr_e( 'Let Me Look Around', 'mainwp' ); ?>"/>
1891 </div>
1892 </div>
1893 </div>
1894 </div>
1895 <script type="text/javascript">
1896 jQuery( '#mainwp-no-sites-modal' ).modal( {
1897 blurring: true,
1898 inverted: true,
1899 closable: false
1900 } ).modal( 'show' );
1901 </script>
1902 <?php
1903 endif;
1904 }
1905
1906 /**
1907 * Method render_screen_options()
1908 *
1909 * Render modal window for Page Settings.
1910 *
1911 * @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Overview page.
1912 *
1913 * @return void Render modal window for Page Settings html.
1914 */
1915 public static function render_screen_options( $setting_page = true ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1916
1917 $default_widgets = array(
1918 'overview' => esc_html__( 'Updates Overview', 'mainwp' ),
1919 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
1920 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
1921 'plugins' => esc_html__( 'Plugins (Individual Site Overview page)', 'mainwp' ),
1922 'themes' => esc_html__( 'Themes (Individual Site Overview page)', 'mainwp' ),
1923 'connection_status' => esc_html__( 'Connection Status', 'mainwp' ),
1924 'security_issues' => esc_html__( 'Security Issues', 'mainwp' ),
1925 'notes' => esc_html__( 'Notes (Individual Site Overview page)', 'mainwp' ),
1926 'clients' => esc_html__( 'Clients', 'mainwp' ),
1927 'child_site_info' => esc_html__( 'Child site info (Individual Site Overview page)', 'mainwp' ),
1928 'client_info' => esc_html__( 'Client info (Individual Site Overview page)', 'mainwp' ),
1929 'non_mainwp_changes' => esc_html__( 'Non-MainWP Changes', 'mainwp' ),
1930 );
1931
1932 $custom_opts = apply_filters_deprecated( 'mainwp-widgets-screen-options', array( array() ), '4.0.7.2', 'mainwp_widgets_screen_options' ); // @deprecated Use 'mainwp_widgets_screen_options' instead.
1933
1934 /**
1935 * Filter: mainwp_widgets_screen_options
1936 *
1937 * Filters available widgets on the Overview page allowing users to unsent unwanted widgets.
1938 *
1939 * @since 4.0
1940 */
1941 $custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts );
1942
1943 if ( is_array( $custom_opts ) && 0 < count( $custom_opts ) ) {
1944 $default_widgets = array_merge( $default_widgets, $custom_opts );
1945 }
1946
1947 $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
1948
1949 if ( ! is_array( $show_widgets ) ) {
1950 $show_widgets = array();
1951 }
1952
1953 $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1954 $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1955 $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
1956
1957 /**
1958 * Action: mainwp_screen_options_modal_top
1959 *
1960 * Fires at the top of the Page Settings modal element.
1961 *
1962 * @since 4.1
1963 */
1964 do_action( 'mainwp_screen_options_modal_top' );
1965 $which_settings = 'overview_settings';
1966 ?>
1967 <?php if ( ! $setting_page ) : ?>
1968 <?php if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $sidebar_pages ) ) : ?>
1969 <?php
1970 $which_settings = 'sidebar_settings';
1971 $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
1972 if ( false === $sidebarPosition ) {
1973 $sidebarPosition = 1;
1974 }
1975 $manageGroupsPage = false;
1976 if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) {
1977 $manageGroupsPage = true;
1978 }
1979 ?>
1980 <div class="ui grid field">
1981 <label tabindex="0" class="six wide column middle aligned"><?php echo $manageGroupsPage ? esc_html__( 'Tags menu position', 'mainwp' ) : esc_html__( 'Sidebar position', 'mainwp' ); ?></label>
1982 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Select if you want to show the element on left or right.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1983 <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
1984 <option value="1" <?php echo ( 1 == $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Right', 'mainwp' ); ?></option>
1985 <option value="0" <?php echo ( 0 == $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
1986 </select>
1987 </div>
1988 </div>
1989 <?php endif; ?>
1990 <?php endif; ?>
1991 <?php if ( isset( $_GET['page'] ) && ! in_array( $_GET['page'], $sidebar_pages ) ) : ?>
1992 <div class="ui grid field">
1993 <label class="six wide column middle aligned"><?php esc_html_e( 'Hide the Update Everything button', 'mainwp' ); ?></label>
1994 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the "Update Everything" button will be hidden in the Updates Overview widget.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1995 <input type="checkbox" name="hide_update_everything" <?php echo ( ( 1 == get_option( 'mainwp_hide_update_everything' ) ) ? 'checked="true"' : '' ); ?> />
1996 </div>
1997 </div>
1998 <?php
1999 $overviewColumns = get_option( 'mainwp_number_overview_columns', 2 );
2000 if ( 2 != $overviewColumns && 3 != $overviewColumns ) {
2001 $overviewColumns = 2;
2002 }
2003
2004 ?>
2005 <div class="ui grid field">
2006 <label class="six wide column middle aligned"><?php esc_html_e( 'Widgets columns', 'mainwp' ); ?></label>
2007 <div class="ten wide column">
2008 <div class="ui radio checkbox">
2009 <input type="radio" name="number_overview_columns" required="required" <?php echo ( 2 == $overviewColumns ? 'checked="true"' : '' ); ?> value="2">
2010 <label><?php esc_html_e( 'Show widgets in 2 columns', 'mainwp' ); ?></label>
2011 </div>
2012 <div class="ui fitted hidden divider"></div>
2013 <div class="ui radio checkbox">
2014 <input type="radio" name="number_overview_columns" required="required" <?php echo ( 3 == $overviewColumns ? 'checked="true"' : '' ); ?> value="3">
2015 <label><?php esc_html_e( 'Show widgets in 3 columns', 'mainwp' ); ?></label>
2016 </div>
2017 </div>
2018 </div>
2019
2020 <div class="ui grid field">
2021 <label class="six wide column"><?php esc_html_e( 'Show widgets', 'mainwp' ); ?></label>
2022 <div class="ten wide column" <?php echo $setting_page ? 'data-tooltip="' . esc_attr_e( 'Select widgets that you want to hide in the MainWP Overview page.', 'mainwp' ) . '"' : ''; ?> data-inverted="" data-position="top left">
2023 <ul class="mainwp_hide_wpmenu_checkboxes">
2024 <?php
2025 foreach ( $default_widgets as $name => $title ) {
2026 $_selected = '';
2027 if ( ! isset( $show_widgets[ $name ] ) || 1 == $show_widgets[ $name ] ) {
2028 $_selected = 'checked';
2029 }
2030 ?>
2031 <li>
2032 <div class="ui checkbox">
2033 <input type="checkbox" id="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" name="mainwp_show_widgets[]" <?php echo $_selected; ?> value="<?php echo esc_attr( $name ); ?>">
2034 <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
2035 </div>
2036 <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
2037 </li>
2038 <?php
2039 }
2040 ?>
2041 </ul>
2042 </div>
2043 </div>
2044 <?php endif; ?>
2045 <input type="hidden" name="reset_overview_which_settings" value="<?php echo esc_html( $which_settings ); ?>" />
2046 <?php
2047 /**
2048 * Action: mainwp_screen_options_modal_bottom
2049 *
2050 * Fires at the bottom of the Page Settings modal element.
2051 *
2052 * @since 4.1
2053 */
2054 do_action( 'mainwp_screen_options_modal_bottom' );
2055 }
2056
2057 /**
2058 * Method render_select_mainwp_themes_modal()
2059 *
2060 * Render modal window for mainwp themes selection.
2061 *
2062 * @return void Render modal window for themes selection.
2063 */
2064 public static function render_select_mainwp_themes_modal() {
2065 ?>
2066 <div class="ui modal" id="mainwp-select-mainwp-themes-modal">
2067 <div class="header"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></div>
2068 <div class="content ui form">
2069 <div class="ui blue message">
2070 <div class=""><?php echo sprintf( esc_html__( 'Did you know you can create your custom theme? %1$sSee here how to do it%2$s!', '' ), '<a href="https://kb.mainwp.com/docs/how-to-change-the-theme-for-mainwp/" target="_blank">', '</a>' ); ?></div>
2071 </div>
2072 <form method="POST" action="" name="mainwp_select_mainwp_themes_form" id="mainwp_select_mainwp_themes_form">
2073 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2074 <input type="hidden" name="wp_scr_options_nonce" value="<?php echo wp_create_nonce( 'MainWPSelectThemes' ); ?>" />
2075 <?php
2076 /**
2077 * Action: mainwp_select_themes_modal_top
2078 *
2079 * Fires at the top of the modal.
2080 *
2081 * @since 4.3
2082 */
2083 do_action( 'mainwp_select_themes_modal_top' );
2084
2085 MainWP_Settings::get_instance()->render_select_custom_themes();
2086
2087 /**
2088 * Action: mainwp_select_themes_modal_bottom
2089 *
2090 * Fires at the bottom of the modal.
2091 *
2092 * @since 4.3
2093 */
2094 do_action( 'mainwp_select_themes_modal_bottom' );
2095 ?>
2096 </div>
2097 <div class="actions">
2098 <div class="ui two columns grid">
2099 <div class="left aligned column">
2100 <input type="submit" class="ui green button" id="submit-select-mainwp-themes" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2101 </div>
2102 <div class="ui right aligned column">
2103 <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
2104 </div>
2105 </div>
2106 </div>
2107 </form>
2108 </div>
2109 <?php
2110 }
2111
2112 }
2113