PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.3
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / class / class-mainwp-ui.php

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

2,598 lines 95.2 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_style 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 = '', $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 ( empty( $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 ( empty( $selected_groups ) ) {
62 $selected_groups = array();
63 }
64 }
65
66 if ( empty( $selected_websites ) && isset( $_GET['selected_sites'] ) && ! empty( $_GET['selected_sites'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
67 $selected_sites = explode( '-', sanitize_text_field( wp_unslash( $_GET['selected_sites'] ) ) );// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
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( false, null, 'wp.name' ) );
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 esc_attr( $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 esc_attr( $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 esc_attr( $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( 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 esc_attr( $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 esc_attr( $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 esc_attr( $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 esc_attr( $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 * @param bool $show_select_all_disc Whether or not to show select all disconnect sites, Default: false.
250 *
251 * @return void Render Select Sites html.
252 *
253 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
254 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
255 */
256 public static function render_select_sites( $websites, $type, $selected_websites, $enableOfflineSites, $edit_site_id, $show_select_all, $add_edit_client_id = false, $show_select_all_disc = false ) { // phpcs:ignore
257 /**
258 * Action: mainwp_before_select_sites_list
259 *
260 * Fires before the Select Sites list.
261 *
262 * @param object $websites Object containing child sites info.
263 *
264 * @since 4.1
265 */
266 do_action( 'mainwp_before_select_sites_list', $websites );
267 $count_disc = 0;
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 <div id="mainwp-select-sites-placeholder" class="ui segment">
273 <?php self::render_empty_element_placeholder( __( 'No sites connected.', 'mainwp' ) ); ?>
274 </div>
275 <?php
276 else :
277 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
278 $enable_site = true;
279 if ( false === $add_edit_client_id ) {
280 $enable_site = true;
281 } elseif ( 0 === intval( $add_edit_client_id ) && false !== $add_edit_client_id ) {
282 if ( 0 < intval( $website->client_id ) ) {
283 $enable_site = false;
284 }
285 } elseif ( is_numeric( $add_edit_client_id ) && intval( $add_edit_client_id ) > 0 ) {
286 if ( 0 < intval( $website->client_id ) && intval( $website->client_id ) !== intval( $add_edit_client_id ) ) {
287 $enable_site = false;
288 }
289 }
290
291 $site_client_editing = ( $add_edit_client_id && $website->client_id && $add_edit_client_id === $website->client_id ) ? true : false;
292
293 $selected = false;
294 $disconnected = false;
295 if ( ( empty( $website->sync_errors ) || $enableOfflineSites ) && ( ! MainWP_System_Utility::is_suspended_site( $website ) || $site_client_editing ) && $enable_site ) {
296 $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
297 $disabled = '';
298 if ( $edit_site_id ) {
299 if ( (int) $website->id === $edit_site_id ) {
300 $selected = true;
301 } else {
302 $disabled = 'disabled="disabled"';
303 }
304 }
305
306 if ( '' !== $website->sync_errors ) {
307 $disconnected = true;
308 ++$count_disc;
309 }
310 ?>
311 <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' : '' ); ?> <?php echo esc_html( $disconnected ? 'warning' : '' ); ?>">
312 <input <?php echo esc_html( $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"' : '' ); ?> />
313 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
314 <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
315 </label>
316 </div>
317 <?php
318 } else {
319 ?>
320 <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' : '' ); ?>">
321 <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
322 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
323 <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
324 </label>
325 </div>
326 <?php
327 }
328 }
329 MainWP_DB::free_result( $websites );
330 endif;
331 ?>
332 </div>
333 </div>
334 <?php
335 /**
336 * Action: mainwp_after_select_sites_list
337 *
338 * Fires after the Select Sites list.
339 *
340 * @param object $websites Object containing child sites info.
341 *
342 * @since 4.1
343 */
344 do_action( 'mainwp_after_select_sites_list', $websites );
345 ?>
346 <?php
347 }
348
349 /**
350 * Method render_select_sites_staging()
351 *
352 * Render selected staging sites.
353 *
354 * @param mixed $selected_websites Selected Child Sites.
355 * @param mixed $edit_site_id Child Site ID to edit.
356 * @param string $type Selector type.
357 *
358 * @return void Render selected staging sites html.
359 *
360 * @uses \MainWP\Dashboard\MainWP_DB::query()
361 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
362 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
363 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
364 */
365 public static function render_select_sites_staging( $selected_websites, $edit_site_id, $type = 'checkbox' ) {
366 $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' ) );
367 ?>
368 <div id="mainwp-select-sites-body">
369 <div class="ui relaxed divided list" id="mainwp-select-staging-sites-list">
370 <?php if ( ! $websites ) : ?>
371 <h2 class="ui icon header">
372 <i class="folder open outline icon"></i>
373 <div class="content"><?php esc_html_e( 'No staging websites have been found!', 'mainwp' ); ?></div>
374 </h2>
375 <?php
376 else :
377 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
378 $selected = false;
379 if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
380 $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
381 $disabled = '';
382 if ( $edit_site_id ) {
383 if ( $website->id !== $edit_site_id ) {
384 $disabled = 'disabled="disabled"';
385 }
386 }
387 ?>
388 <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' : '' ); ?>">
389 <input <?php echo esc_html( $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"' : '' ); ?> />
390 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
391 <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
392 </label>
393 </div>
394 <?php
395 } else {
396 ?>
397 <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' : '' ); ?>">
398 <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
399 <label for="selected_sites_<?php echo intval( $website->id ); ?>">
400 <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
401 </label>
402 </div>
403 <?php
404 }
405 }
406 MainWP_DB::free_result( $websites );
407 endif;
408 ?>
409 </div>
410 </div>
411 <?php
412 }
413
414 /**
415 * Method render_select_sites_group()
416 *
417 * Render selected sites group.
418 *
419 * @param array $groups Array of groups.
420 * @param mixed $selected_groups Selected groups.
421 * @param string $type Selector type.
422 *
423 * @return void Render selected sites group html.
424 */
425 public static function render_select_sites_group( $groups, $selected_groups, $type = 'checkbox' ) {
426 /**
427 * Action: mainwp_before_select_groups_list
428 *
429 * Fires before the Select Groups list.
430 *
431 * @param object $groups Object containing groups info.
432 *
433 * @since 4.1
434 */
435 do_action( 'mainwp_before_select_groups_list', $groups );
436 ?>
437 <div id="mainwp-select-sites-body">
438 <div class="ui relaxed divided list" id="mainwp-select-groups-list">
439 <?php
440 if ( 0 === count( $groups ) ) {
441 ?>
442 <h2 class="ui icon header">
443 <i class="folder open outline icon"></i>
444 <div class="content"><?php esc_html_e( 'No Tags created!', 'mainwp' ); ?></div>
445 <div class="ui divider hidden"></div>
446 <a href="admin.php?page=ManageGroups" class="ui green button basic"><?php esc_html_e( 'Create Tags', 'mainwp' ); ?></a>
447 </h2>
448 <?php
449 }
450 foreach ( $groups as $group ) {
451 $selected = in_array( $group->id, $selected_groups );
452 ?>
453 <div class="mainwp_selected_groups_item ui item <?php echo esc_html( $type ); ?> <?php echo ( $selected ? 'selected_groups_item_checked' : '' ); ?>">
454 <input type="<?php echo esc_html( $type ); ?>" name="<?php echo ( 'radio' === $type ? 'selected_groups' : 'selected_groups[]' ); ?>" value="<?php echo esc_attr( $group->id ); ?>" id="selected_groups_<?php echo esc_attr( $group->id ); ?>" <?php echo ( $selected ? 'checked="true"' : '' ); ?> />
455 <label for="selected_groups_<?php echo esc_attr( $group->id ); ?>">
456 <?php echo esc_html( stripslashes( $group->name ) ); ?>
457 </label>
458 </div>
459 <?php
460 }
461 ?>
462 </div>
463 </div>
464 <?php
465 /**
466 * Action: mainwp_after_select_groups_list
467 *
468 * Fires after the Select Groups list.
469 *
470 * @param object $groups Object containing groups info.
471 *
472 * @since 4.1
473 */
474 do_action( 'mainwp_after_select_groups_list', $groups );
475 }
476
477 /**
478 * Method render_top_header()
479 *
480 * Render top header.
481 *
482 * @param array $params Page parameters.
483 *
484 * @uses \MainWP\Dashboard\MainWP_DB::query()
485 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
486 * @uses \MainWP\Dashboard\MainWP_Menu::render_left_menu()
487 */
488 public static function render_top_header( $params = array() ) { // phpcs:ignore -- complex.
489
490 $before_title = isset( $params['before_title'] ) ? $params['before_title'] . ' ' : '';
491 $title = isset( $params['title'] ) ? $params['title'] : '';
492
493 $which = isset( $params['which'] ) ? $params['which'] : '';
494
495 /**
496 * Filter: mainwp_header_title
497 *
498 * Filter the MainWP page title in the header element.
499 *
500 * @since 4.0
501 */
502 $title = apply_filters( 'mainwp_header_title', $title );
503
504 $show_menu = true;
505 $show_new_items = true;
506
507 if ( isset( $params['show_menu'] ) ) {
508 $show_menu = $params['show_menu'];
509 }
510
511 $more_tags = array(
512 'img' => array(
513 'src' => array(),
514 'width' => array(),
515 'height' => array(),
516 'class' => array(),
517 ),
518 'div' => array(
519 'class' => array(),
520 ),
521 'a' => array(
522 'href' => array(),
523 'class' => array(),
524 'target' => array(),
525 'style' => array(),
526 'site-id' => array(),
527 'siteid' => array(),
528 ),
529 'i' => array(
530 'class' => array(),
531 'target' => array(),
532 'style' => array(),
533 ),
534 );
535
536 $title = $before_title . $title;
537
538 /**
539 * Filter: mainwp_header_left
540 *
541 * Filter the MainWP header element left side content.
542 *
543 * @since 4.0
544 */
545 $left = apply_filters( 'mainwp_header_left', $title, $params );
546
547 $right = self::render_header_actions();
548
549 /**
550 * Filter: mainwp_header_right
551 *
552 * Filter the MainWP header element right side content.
553 *
554 * @since 4.0
555 */
556 $right = apply_filters( 'mainwp_header_right', $right );
557
558 if ( $show_menu ) {
559 MainWP_Menu::render_left_menu();
560 MainWP_Menu::render_mobile_menu();
561 }
562
563 $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
564 if ( false === $sidebarPosition ) {
565 $sidebarPosition = 1;
566 }
567
568 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.name' ) );
569
570 $count_sites = MainWP_DB::instance()->get_websites_count();
571
572 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
573 if ( empty( $count_sites ) ) {
574 if ( ! isset( $_GET['do'] ) ) {
575 self::render_modal_no_sites_note();
576 }
577 }
578
579 $siteViewMode = MainWP_Utility::get_siteview_mode();
580
581 $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
582
583 $tour_id = '';
584 if ( 'mainwp_tab' === $page ) {
585 $tour_id = '13112';
586 } elseif ( 'managesites' === $page ) {
587 if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) {
588 $tour_id = '13210';
589 } elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) {
590 $tour_id = '27274';
591 } elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
592 if ( 'grid' === $siteViewMode ) {
593 $tour_id = '27217';
594 } else {
595 $tour_id = '29331';
596 }
597 }
598 } elseif ( 'MonitoringSites' === $page ) {
599 $tour_id = '29003';
600 } elseif ( 'ManageClients' === $page ) {
601 if ( isset( $_GET['client_id'] ) ) {
602 $tour_id = '28258';
603 } else {
604 $tour_id = '28240';
605 }
606 } elseif ( 'ClientAddNew' === $page ) {
607 if ( isset( $_GET['client_id'] ) ) {
608 $tour_id = '28962';
609 } else {
610 $tour_id = '28256';
611 }
612 } elseif ( 'ClientAddField' === $page ) {
613 $tour_id = '28257';
614 } elseif ( 'PluginsManage' === $page ) {
615 $tour_id = '28510';
616 } elseif ( 'ManageGroups' === $page ) {
617 $tour_id = '27275';
618 } elseif ( 'UpdatesManage' === $page ) {
619 $tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
620 if ( 'plugins-updates' === $tab ) {
621 $tour_id = '28259';
622 } elseif ( 'themes-updates' === $tab ) {
623 $tour_id = '28447';
624 } elseif ( 'wordpress-updates' === $tab ) {
625 $tour_id = '29005';
626 } elseif ( 'translations-updates' === $tab ) {
627 $tour_id = '29007';
628 } elseif ( 'abandoned-plugins' === $tab ) {
629 $tour_id = '29008';
630 } elseif ( 'abandoned-themes' === $tab ) {
631 $tour_id = '29009';
632 } elseif ( 'plugin-db-updates' === $tab ) {
633 $tour_id = '33161';
634 } else {
635 $tour_id = '28259';
636 }
637 } elseif ( 'PluginsInstall' === $page ) {
638 $tour_id = '29011';
639 } elseif ( 'PluginsAutoUpdate' === $page ) {
640 $tour_id = '29015';
641 } elseif ( 'PluginsIgnore' === $page ) {
642 $tour_id = '29018';
643 } elseif ( 'PluginsIgnoredAbandoned' === $page ) {
644 $tour_id = '29329';
645 } elseif ( 'ThemesManage' === $page ) {
646 $tour_id = '28511';
647 } elseif ( 'ThemesInstall' === $page ) {
648 $tour_id = '29010';
649 } elseif ( 'ThemesAutoUpdate' === $page ) {
650 $tour_id = '29016';
651 } elseif ( 'ThemesIgnore' === $page ) {
652 $tour_id = '29019';
653 } elseif ( 'ThemesIgnoredAbandoned' === $page ) {
654 $tour_id = '29330';
655 } elseif ( 'UserBulkManage' === $page ) {
656 $tour_id = '28574';
657 } elseif ( 'UserBulkAdd' === $page ) {
658 $tour_id = '28575';
659 } elseif ( 'BulkImportUsers' === $page ) {
660 $tour_id = '28736';
661 } elseif ( 'UpdateAdminPasswords' === $page ) {
662 $tour_id = '28737';
663 } elseif ( 'PostBulkManage' === $page ) {
664 $tour_id = '28796';
665 } elseif ( 'PostBulkAdd' === $page ) {
666 $tour_id = '28799';
667 } elseif ( 'PageBulkManage' === $page ) {
668 $tour_id = '29045';
669 } elseif ( 'PageBulkAdd' === $page ) {
670 $tour_id = '29048';
671 } elseif ( 'Extensions' === $page ) {
672 $tour_id = '28800';
673 } elseif ( 'Settings' === $page ) {
674 $tour_id = '28883';
675 } elseif ( 'SettingsAdvanced' === $page ) {
676 $tour_id = '28886';
677 } elseif ( 'SettingsEmail' === $page ) {
678 $tour_id = '29054';
679 } elseif ( 'MainWPTools' === $page ) {
680 $tour_id = '29272';
681 } elseif ( 'RESTAPI' === $page ) {
682 $tour_id = '29273';
683 } elseif ( 'ServerInformation' === $page ) {
684 $tour_id = '28873';
685 } elseif ( 'ServerInformationCron' === $page ) {
686 $tour_id = '28874';
687 } elseif ( 'ErrorLog' === $page ) {
688 $tour_id = '28876';
689 } elseif ( 'ActionLogs' === $page ) {
690 $tour_id = '28877';
691 } elseif ( 'Extensions-Mainwp-Jetpack-Protect-Extension' === $page ) {
692 $tour_id = '31700';
693 } elseif ( 'Extensions-Mainwp-Jetpack-Scan-Extension' === $page ) {
694 $tour_id = '31694';
695 } elseif ( 'Extensions-Termageddon-For-Mainwp' === $page ) {
696 $tour_id = '32104';
697 } elseif ( 'Extensions-Advanced-Uptime-Monitor-Extension' === $page ) {
698 $tour_id = '32149';
699 } elseif ( 'Extensions-Mainwp-Custom-Dashboard-Extension' === $page ) {
700 $tour_id = '32150';
701 } elseif ( 'Extensions-Mainwp-Updraftplus-Extension' === $page ) {
702 $tour_id = '32151';
703 } elseif ( 'Extensions-Mainwp-Sucuri-Extension' === $page ) {
704 $tour_id = '32152';
705 } elseif ( 'Extensions-Mainwp-Clean-And-Lock-Extension' === $page ) {
706 $tour_id = '32153';
707 } elseif ( 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' === $page ) {
708 $tour_id = '32851';
709 } elseif ( 'Extensions-Mainwp-Buddy-Extension' === $page ) {
710 $tour_id = '33064';
711 } elseif ( 'Extensions-Mainwp-Backwpup-Extension' === $page ) {
712 $tour_id = '32923';
713 } elseif ( 'Extensions-Mainwp-Ssl-Monitor-Extension' === $page ) {
714 $tour_id = '33164';
715 } elseif ( 'Extensions-Mainwp-Cache-Control-Extension' === $page ) {
716 $tour_id = '33167';
717 } elseif ( 'Extensions-Mainwp-Maintenance-Extension' === $page ) {
718 $tour_id = '33301';
719 } elseif ( 'Extensions-Mainwp-Domain-Monitor-Extension' === $page ) {
720 $tour_id = '33300';
721 }
722 // phpcs:enable
723 ?>
724 <div class="ui segment right sites sidebar" style="padding:0px" id="mainwp-sites-menu-sidebar">
725 <div class="ui segment" style="margin-bottom:0px">
726 <div class="ui header"><?php esc_html_e( 'Quick Site Shortcuts', 'mainwp' ); ?></div>
727 </div>
728 <div class="ui fitted divider"></div>
729 <div class="ui segment" style="margin-bottom:0px">
730 <div class="ui mini fluid icon input" <?php echo $websites ? '' : 'style="display: none;"'; ?> >
731 <input type="text" id="mainwp-sites-menu-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" />
732 <i class="filter icon"></i>
733 </div>
734 </div>
735 <div class="ui fluid vertical accordion menu" id="mainwp-sites-sidebar-menu" style="margin-top:0px;border-radius:0px;box-shadow:none;">
736 <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
737 <div class="item mainwp-site-menu-item">
738 <div class="title">
739 <i class="dropdown icon"></i>
740 <label><?php echo esc_html( $website->name ); ?></label>
741 </div>
742 <div class="content">
743 <div class="ui hiden divider"></div>
744 <div class="ui fluid relaxed list">
745 <div class="item" >
746 <i class="grid layout icon"></i>
747 <a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website->id ); ?>"><?php esc_html_e( 'Overview', 'mainwp' ); ?></a>
748 </div>
749 <div class="item" >
750 <i class="redo icon"></i>
751 <a href="<?php echo 'admin.php?page=managesites&updateid=' . intval( $website->id ); ?>"><?php esc_html_e( 'Updates', 'mainwp' ); ?></a>
752 </div>
753 <div class="item">
754 <i class="edit icon"></i>
755 <a href="<?php echo 'admin.php?page=managesites&id=' . intval( $website->id ); ?>"><?php esc_html_e( 'Edit Site', 'mainwp' ); ?></a>
756 </div>
757 <div class="item">
758 <i class="sync alt icon"></i>
759 <a href="#" siteid="<?php echo intval( $website->id ); ?>" onClick="updatesoverview_wp_sync( '<?php echo intval( $website->id ); ?>' )"><?php esc_html_e( 'Sync Site', 'mainwp' ); ?></a>
760 </div>
761 <div class="item">
762 <i class="shield icon"></i>
763 <a href="<?php echo 'admin.php?page=managesites&scanid=' . intval( $website->id ); ?>"><?php esc_html_e( 'Site Hardening', 'mainwp' ); ?></a>
764 </div>
765 <div class="item">
766 <i class="sign in icon"></i>
767 <a target="_blank" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . intval( $website->id ); ?>&_opennonce=<?php echo esc_attr( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a>
768 </div>
769 <div class="item">
770 <i class="globe icon"></i>
771 <a target="_blank" href="<?php echo esc_url( $website->url ); ?>"><?php esc_html_e( 'Visit Site', 'mainwp' ); ?></a>
772 </div>
773 <?php
774 /**
775 * Action: mainwp_quick_sites_shortcut
776 *
777 * Adds a new shortcut item in the Quick Sites Shortcuts sidebar menu.
778 *
779 * @param array $website Array containing the child site data.
780 *
781 * Suggested HTML markup:
782 *
783 * <a class="item" href="your custom URL">
784 * <i class="your custom icon"></i>
785 * Your custom label text
786 * </a>
787 *
788 * @since 4.1
789 */
790 do_action( 'mainwp_quick_sites_shortcut', $website );
791 ?>
792 </div>
793 </div>
794 </div>
795 <?php } ?>
796 </div>
797 </div>
798 <div class="ui segment right wide help sidebar" id="mainwp-documentation-sidebar">
799 <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>
800 <div class="ui hidden divider"></div>
801 <div class="ui info message" style="display:block!important;">
802 <?php printf( esc_html__( 'This feature is implemented using Javascript provided by Usetiful and is subject to the %1$sUsetiful Privacy Policy%2$s.', 'mainwp' ), '<a href="https://www.usetiful.com/privacy-policy" target="_blank">', '</a>' ); ?>
803 </div>
804 <div class="ui hidden divider"></div>
805 <div class="ui toggle checkbox">
806 <input type="checkbox" id="mainwp-select-guided-tours-option" onchange="mainwp_guidedtours_onchange(this);"<?php echo ( ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) ? 'checked="true"' : '' ); ?> /> <label><?php esc_html_e( 'Switch to enable or disable tours.', 'mainwp' ); ?></label>
807 </div>
808 <div class="ui hidden divider"></div>
809 <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
810 <p><?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?></p>
811 <p><?php esc_html_e( 'Click the Start Page Tour button to start the guided tour for the current page.', 'mainwp' ); ?></p>
812 <div class="ui hidden divider"></div>
813 <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>
814 <?php if ( 'mainwp_tab' === $page ) : ?>
815 <div class="ui hidden divider"></div>
816 <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>
817 <?php endif; ?>
818 <?php endif; ?>
819 <div class="ui header"><?php esc_html_e( 'MainWP Knowledge Base', 'mainwp' ); ?></div>
820 <div class="ui hidden divider"></div>
821 <?php
822 /**
823 * Action: mainwp_help_sidebar_content
824 *
825 * Fires Help sidebar content
826 *
827 * @since 4.0
828 */
829 do_action( 'mainwp_help_sidebar_content' );
830 ?>
831 <div class="ui hidden divider"></div>
832 <a href="https://kb.mainwp.com/" class="ui big green fluid button"><?php esc_html_e( 'Help Documentation', 'mainwp' ); ?></a>
833 <div class="ui hidden divider"></div>
834 <div id="mainwp-sticky-help-button" class="" style="position: absolute; bottom: 1em; left: 1em; right: 1em;">
835 <a href="https://managers.mainwp.com/" target="_blank" class="ui fluid button"><?php esc_html_e( 'Still Need Help?', 'mainwp' ); ?></a>
836 </div>
837 </div>
838 <?php
839 /**
840 * Action: mainwp_before_mainwp_content_wrap
841 *
842 * Fires before the #mainwp-content-wrap element.
843 *
844 * @param array $websites Array containing the child site data.
845 *
846 * @since 4.1
847 */
848 do_action( 'mainwp_before_mainwp_content_wrap', $websites );
849 global $wp_version;
850 $fix_menu_overflow = 1;
851 if ( version_compare( $wp_version, '5.5.3', '>' ) ) {
852 $fix_menu_overflow = 2;
853 }
854
855 if ( 'page_clients_overview' !== $which ) {
856 ?>
857
858 <div class="ui modal" id="mainwp-overview-screen-options-modal">
859 <i class="close icon"></i>
860 <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
861 <div class="content ui form">
862 <?php
863 /**
864 * Action: mainwp_overview_screen_options_top
865 *
866 * Fires at the top of the Sceen Options modal on the Overview page.
867 *
868 * @since 4.1
869 */
870 do_action( 'mainwp_overview_screen_options_top' );
871 ?>
872 <form method="POST" action="" name="mainwp_overview_screen_options_form" id="mainwp-overview-screen-options-form">
873 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
874 <input type="hidden" name="wp_nonce" value="<?php echo esc_html( wp_create_nonce( 'MainWPScrOptions' ) ); ?>" />
875 <?php self::render_screen_options( false ); ?>
876 <?php
877 /**
878 * Action: mainwp_overview_screen_options_bottom
879 *
880 * Fires at the bottom of the Sceen Options modal on the Overview page.
881 *
882 * @since 4.1
883 */
884 do_action( 'mainwp_overview_screen_options_bottom' );
885 ?>
886 </div>
887 <div class="actions">
888 <div class="ui two columns grid">
889 <div class="left aligned column">
890 <span data-tooltip="<?php esc_attr_e( 'Resets the page to its original layout and reinstates relocated widgets.', '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>
891 </div>
892 <div class="ui right aligned column">
893 <input type="submit" class="ui green button" id="submit-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
894 </div>
895 </div>
896 </div>
897
898 <input type="hidden" name="reset_overview_settings" value="" />
899 </form>
900 </div>
901 <?php } ?>
902 <?php
903 $wrap_class = isset( $params['wrap_class'] ) ? $params['wrap_class'] : '';
904 ?>
905 <div class="mainwp-content-wrap <?php echo esc_attr( $wrap_class ); ?> <?php echo empty( $sidebarPosition ) ? 'mainwp-sidebar-left' : ''; ?>" menu-overflow="<?php echo intval( $fix_menu_overflow ); ?>">
906 <?php if ( MainWP_Demo_Handle::is_demo_mode() ) : ?>
907 <div class="ui segment" style="background-color:#1c1d1b!important;margin-bottom:0px;">
908 <div class="ui inverted accordion" id="mainwp_demo_mode_accordion" style="background-color:#1c1d1b;">
909 <div class="title">
910 <i class="dropdown icon"></i>
911 <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
912 <strong style="color:#fff;font-size:16px;"><?php esc_html_e( 'You are in Demo Mode. Click here for more info or to disable it', 'mainwp' ); ?></strong>
913 <?php } else { ?>
914 <strong style="color:#fff;font-size:16px;"><?php esc_html_e( 'You are in Demo Mode. Click here for more info', 'mainwp' ); ?></strong>
915 <?php } ?>
916 </div>
917 <div class="content">
918 <br/>
919 <div class="ui stackable grid">
920 <div class="eleven wide middle aligned column">
921 <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
922 <p style="color:#fff;font-size:16px;"><?php esc_html_e( 'Once you are ready to get started with MainWP, click the Disable Demo Mode & Remove Demo Content button to remove the demo content and start adding your own. ', 'mainwp' ); ?></p>
923 <?php } ?>
924 <p style="color:#fff;font-size:16px;"><strong><?php esc_html_e( 'The demo content serves as placeholder data to give you a feel for the MainWP Dashboard. Please note that because no real websites are connected in this demo, some functionality will be restricted. Features that require a connection to actual websites will be disabled for the duration of the demo.', 'mainwp' ); ?></strong></p>
925 </div>
926 <div class="five wide middle aligned column">
927 <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
928 <div data-tooltip="<?php esc_attr_e( 'Delete the Demo content from your MainWP Dashboard and disable the Demo mode.', 'mainwp' ); ?>" data-inverted="" data-position="left center"><button class="ui big fluid button mainwp-remove-demo-data-button"><?php esc_html_e( 'Disable Demo Mode & Remove Demo Content', 'mainwp' ); ?></button></div>
929 <?php } else { ?>
930 <div data-tooltip="<?php esc_attr_e( 'Get started with MainWP.', 'mainwp' ); ?>" data-inverted="" data-position="left center"><a class="ui big fluid button" target="_blank" href="https://mainwp.com/install-mainwp/?utm_source=instawp-demo&utm_medium=banner&utm_campaign=download_black_banner&utm_id=instawp"><?php esc_html_e( 'Download MainWP', 'mainwp' ); ?></a></div>
931 <?php } ?>
932 </div>
933 </div>
934 <br/>
935 </div>
936 </div>
937 </div>
938 <script type="text/javascript">
939 jQuery( '#mainwp_demo_mode_accordion' ).accordion();
940 </script>
941 <?php endif; ?>
942 <?php
943 /**
944 * Action: mainwp_before_header
945 *
946 * Fires before the MainWP header element.
947 *
948 * @param array $websites Array containing the child site data.
949 *
950 * @since 4.0
951 */
952 do_action( 'mainwp_before_header', $websites );
953 ?>
954 <div id="mainwp-top-header" class="ui native sticky">
955 <div class="ui middle aligned stackable grid">
956 <div class="six wide left aligned middle aligned column">
957 <h4 class="mainwp-page-title ui header">
958 <?php echo $left; // phpcs:ignore WordPress.Security.EscapeOutput ?>
959 </h4>
960 </div>
961
962 <div class="ten wide right aligned column"><?php echo $right; ?></div> <?php // phpcs:ignore WordPress.Security.EscapeOutput ?>
963
964 </div>
965 </div>
966
967 <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
968 <script type="text/javascript">
969 jQuery( document ).ready( function() {
970 jQuery( '#mainwp-start-page-tour-button' ).on( 'click', function() {
971 var tourId = jQuery( this ).attr( 'tour-id' );
972 jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
973 window.USETIFUL.tour.start( parseInt( tourId ) );
974 } );
975 jQuery( '#mainwp-interface-tour-button' ).on( 'click', function() {
976 jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
977 window.USETIFUL.tour.start( 13282 );
978 } );
979 } );
980 </script>
981 <?php endif; ?>
982
983 <?php
984 if ( isset( $_GET['message'] ) && ( 'qsw-import' === $_GET['message'] || 'enable-demo-mode' === $_GET['message'] ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
985 ?>
986 <script type= 'text/javascript'>
987 var _count_retry = 0;
988 _try_start_usetiful_tour = function () {
989 setTimeout(
990 function () {
991 try {
992 window.USETIFUL.tour.start( parseInt( 40279 ) );
993 } catch ( e ) {
994 if ( _count_retry < 10 ) {
995 _count_retry++;
996 console.log('retry:' + _count_retry);
997 _try_start_usetiful_tour();
998 }
999 }
1000 },
1001 1000
1002 );
1003 }
1004 jQuery(document).ready(
1005 function () {
1006 _try_start_usetiful_tour();
1007 }
1008 );
1009 </script>
1010 <?php
1011 endif;
1012 ?>
1013
1014 <script type="text/javascript">
1015 jQuery( document ).ready( function () {
1016
1017 jQuery( '#mainwp-jump-to-site-overview-dropdown' ).on( 'change', function() {
1018 var site_id = jQuery( this ).val();
1019 window.location.href = 'admin.php?page=managesites&dashboard=' + site_id;
1020 } );
1021
1022 jQuery( '#mainwp-sites-menu-sidebar' ).prependTo( 'body' );
1023 jQuery( '#mainwp-documentation-sidebar' ).prependTo( 'body' );
1024 jQuery( 'body > div#wpwrap' ).addClass( 'pusher' );
1025
1026 jQuery( '.ui.sticky' ).sticky( {
1027 pushing: false,
1028 } ).sticky();
1029
1030 jQuery( '#mainwp-help-sidebar' ).on( 'click', function() {
1031 jQuery( '.ui.help.sidebar' ).sidebar( {
1032 transition: 'overlay'
1033 } );
1034 jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' );
1035 return false;
1036 } );
1037 jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() {
1038 jQuery( '.ui.sites.sidebar' ).sidebar( {
1039 transition: 'overlay',
1040 'onVisible': function() {
1041 jQuery( '#mainwp-sites-menu-filter' ).focus();
1042 }
1043 } );
1044 jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' );
1045 return false;
1046 } );
1047 jQuery( '#mainwp-sites-sidebar-menu' ).accordion();
1048 } );
1049 </script>
1050 <?php
1051 /**
1052 * Action: mainwp_after_header
1053 *
1054 * Fires after the MainWP header element.
1055 *
1056 * @param array $websites Array containing the child site data.
1057 *
1058 * @since 4.0
1059 */
1060 do_action( 'mainwp_after_header', $websites );
1061 ?>
1062 <?php
1063 }
1064
1065
1066 /**
1067 * Method render_showhide_columns_settings()
1068 *
1069 * Render show/hide columns settings.
1070 *
1071 * @param array $cols Columns.
1072 * @param array $show_columns Show Columns.
1073 * @param string $what what.
1074 */
1075 public static function render_showhide_columns_settings( $cols, $show_columns, $what ) {
1076 ?>
1077 <div class="ui grid field">
1078 <label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label>
1079 <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">
1080 <ul>
1081 <?php
1082 foreach ( $cols as $name => $title ) {
1083 $_selected = '';
1084 if ( ! isset( $show_columns[ $name ] ) || 1 === (int) $show_columns[ $name ] ) {
1085 $_selected = 'checked';
1086 }
1087 ?>
1088 <li>
1089 <div class="ui checkbox">
1090 <input type="checkbox" id="mainwp_show_column_<?php echo esc_attr( $name ); ?>" name="mainwp_show_columns[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
1091 <label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
1092 </div>
1093 <input type="hidden" name="mainwp_columns_name[]" value="<?php echo esc_attr( $name ); ?>">
1094 </li>
1095 <?php
1096 }
1097 ?>
1098 </ul>
1099 </div>
1100
1101 </div>
1102 <?php
1103
1104 $input_name = '';
1105 if ( 'post' === $what ) {
1106 $input_name = 'mainwp_manageposts_show_columns_settings';
1107 } elseif ( 'page' === $what ) {
1108 $input_name = 'mainwp_managepages_show_columns_settings';
1109 } elseif ( 'user' === $what ) {
1110 $input_name = 'mainwp_manageusers_show_columns_settings';
1111 }
1112
1113 if ( ! empty( $input_name ) ) {
1114 ?>
1115 <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1116 <?php
1117 }
1118 }
1119
1120 /**
1121 * Method render_second_top_header()
1122 *
1123 * Render second top header.
1124 *
1125 * @param string $which Current page.
1126 *
1127 * @return void Render second top header html.
1128 */
1129 public static function render_second_top_header( $which = '' ) {
1130
1131 /**
1132 * Action: mainwp_before_subheader
1133 *
1134 * Fires before the MainWP sub-header element.
1135 *
1136 * @since 4.0
1137 */
1138 do_action( 'mainwp_before_subheader' );
1139 if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) {
1140 ?>
1141 <div class="mainwp-sub-header">
1142 <?php
1143 if ( 'overview' === $which ) {
1144 ?>
1145 <div class="ui stackable grid">
1146 <div class="column full">
1147 <?php self::gen_groups_sites_selection(); ?>
1148 </div>
1149 </div>
1150 <?php
1151 }
1152 ?>
1153 <?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?>
1154 <?php
1155 /**
1156 * Action: mainwp_managesites_tabletop
1157 *
1158 * Fires at the table top on the Manage Sites and Monitoring page.
1159 *
1160 * @since 4.0
1161 */
1162 do_action( 'mainwp_managesites_tabletop' );
1163 ?>
1164
1165 <?php else : ?>
1166 <?php
1167 /**
1168 * Action: mainwp_subheader_actions
1169 *
1170 * Fires at the subheader element to hook available actions.
1171 *
1172 * @since 4.0
1173 */
1174 do_action( 'mainwp_subheader_actions' );
1175 ?>
1176 <?php endif; ?>
1177 </div>
1178 <?php
1179 }
1180 /**
1181 * Action: mainwp_after_subheader
1182 *
1183 * Fires after the MainWP sub-header element.
1184 *
1185 * @since 4.0
1186 */
1187 do_action( 'mainwp_after_subheader' );
1188 }
1189
1190 /**
1191 * Method gen_groups_sites_selection()
1192 *
1193 * Generate group sites selection box.
1194 *
1195 * @return void Render group sites selection box.
1196 *
1197 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_manage_sites()
1198 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_not_empty_groups()
1199 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1200 * @uses \MainWP\Dashboard\MainWP_DB::query()
1201 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1202 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1203 */
1204 public static function gen_groups_sites_selection() {
1205 $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' ) );
1206 $websites = MainWP_DB::instance()->query( $sql );
1207 $g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1208 $s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1209 ?>
1210 <div class="column full wide">
1211 <select id="mainwp_top_quick_jump_group" class="ui dropdown">
1212 <option value="" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1213 <option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1214 <?php
1215 $groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites();
1216 foreach ( $groups as $group ) {
1217 ?>
1218 <option class="item" <?php echo ( $g === (int) $group->id ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $group->id ); ?>"><?php echo esc_html( stripslashes( $group->name ) ); ?></option>
1219 <?php
1220 }
1221 ?>
1222 </select>
1223 <select class="ui dropdown" id="mainwp_top_quick_jump_page">
1224 <option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1225 <option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1226 <?php
1227 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1228 ?>
1229 <option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s === (int) $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo esc_html( stripslashes( $website->name ) ); ?></option>
1230 <?php
1231 }
1232 ?>
1233 </select>
1234 </div>
1235 <script type="text/javascript">
1236 jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () {
1237 var jumpid = jQuery( this ).val();
1238 window.location = 'admin.php?page=managesites&g=' + jumpid;
1239 } );
1240 jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () {
1241 var jumpid = jQuery( this ).val();
1242 if ( jumpid == -1 )
1243 window.location = 'admin.php?page=managesites&s=' + jumpid;
1244 else
1245 window.location = 'admin.php?page=managesites&dashboard=' + jumpid;
1246 } );
1247 </script>
1248 <?php
1249 MainWP_DB::free_result( $websites );
1250 }
1251
1252 /**
1253 * Method render_header_actions()
1254 *
1255 * Render header action buttons,
1256 * (Sync|Add|Options|Community|User|Updates).
1257 *
1258 * @return mixed $output Render header action buttons html.
1259 *
1260 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1261 */
1262 public static function render_header_actions() { //phpcs:ignore -- complex method.
1263 $sites_count = MainWP_DB::instance()->get_websites_count();
1264 $website_id = '';
1265 $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1266 $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1267 $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
1268
1269 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1270 $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
1271 ob_start();
1272 if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) :
1273 $id = 0;
1274 if ( isset( $_GET['dashboard'] ) ) {
1275 $id = intval( $_GET['dashboard'] );
1276 } elseif ( isset( $_GET['id'] ) ) {
1277 $id = intval( $_GET['id'] );
1278 } elseif ( isset( $_GET['updateid'] ) ) {
1279 $id = intval( $_GET['updateid'] );
1280 } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1281 $id = intval( $_GET['emailsettingsid'] );
1282 } elseif ( isset( $_GET['scanid'] ) ) {
1283 $id = intval( $_GET['scanid'] );
1284 }
1285
1286 $website = MainWP_DB::instance()->get_website_by_id( $id );
1287 ?>
1288 <?php if ( $id && $website && '' !== $website->sync_errors ) : ?>
1289 <a href="#" class="mainwp-updates-overview-reconnect-site ui green icon button" siteid="<?php echo intval( $website->id ); ?>" data-position="bottom right" data-tooltip="Reconnect <?php echo esc_html( stripslashes( $website->name ) ); ?>" data-inverted=""><i class="undo alternate icon"></i></a>
1290 <?php else : ?>
1291 <a class="ui icon button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?>" id="mainwp-sync-sites" data-tooltip="<?php esc_attr_e( 'Get fresh data from your child sites.', 'mainwp' ); ?> data-inverted="" data-position="bottom right">
1292 <i class="sync icon"></i>
1293 </a>
1294 <?php endif; ?>
1295 <?php else : ?>
1296 <span data-tooltip="<?php esc_attr_e( 'Click here to sync data now.', 'mainwp' ); ?>" data-inverted="" data-position="left center">
1297 <a class="ui icon button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?> " id="mainwp-sync-sites">
1298 <i class="sync alternate icon"></i>
1299 </a>
1300 </span>
1301 <?php endif; ?>
1302
1303 <div class="ui icon top left pointing dropdown <?php echo ( empty( $sites_count ) ? 'green' : '' ); ?> button" id="mainwp-add-new-buttons">
1304 <i class="plus icon"></i>
1305 <div class="menu">
1306 <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_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Add Website', 'mainwp' ); ?></a>
1307 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Client to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=ClientAddNew' ) ); ?>"><?php esc_html_e( 'Add Client', 'mainwp' ); ?></a>
1308 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Cost to for tracking', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=CostTrackerAdd' ) ); ?>"><?php esc_html_e( 'Add Cost', 'mainwp' ); ?></a>
1309 <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_url( admin_url( 'admin.php?page=PostBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Post', 'mainwp' ); ?></a>
1310 <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_url( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Page', 'mainwp' ); ?></a>
1311 <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_url( admin_url( 'admin.php?page=PluginsInstall' ) ); ?>"><?php esc_html_e( 'Install Plugin', 'mainwp' ); ?></a>
1312 <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_url( admin_url( 'admin.php?page=ThemesInstall' ) ); ?>"><?php esc_html_e( 'Install Theme', 'mainwp' ); ?></a>
1313 <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_url( admin_url( 'admin.php?page=UserBulkAdd' ) ); ?>"><?php esc_html_e( ' Create User', 'mainwp' ); ?></a>
1314 </div>
1315 </div>
1316
1317 <?php if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) || isset( $_GET['cacheControlId'] ) ) : ?>
1318 <?php if ( isset( $_GET['dashboard'] ) ) : ?>
1319 <?php $website_id = intval( $_GET['dashboard'] ); ?>
1320 <?php elseif ( isset( $_GET['updateid'] ) ) : ?>
1321 <?php $website_id = intval( $_GET['updateid'] ); ?>
1322 <?php elseif ( isset( $_GET['emailsettingsid'] ) ) : ?>
1323 <?php $website_id = intval( $_GET['emailsettingsid'] ); ?>
1324 <?php elseif ( isset( $_GET['scanid'] ) ) : ?>
1325 <?php $website_id = intval( $_GET['scanid'] ); ?>
1326 <?php elseif ( isset( $_GET['cacheControlId'] ) ) : ?>
1327 <?php $website_id = intval( $_GET['cacheControlId'] ); ?>
1328 <?php else : ?>
1329 <?php $website_id = intval( $_GET['id'] ); ?>
1330 <?php endif; ?>
1331
1332 <?php endif; ?>
1333 <?php if ( ( 'mainwp_tab' === $page ) || isset( $_GET['dashboard'] ) || in_array( $page, $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
1334 <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' ); ?>">
1335 <i class="cog icon"></i>
1336 </a>
1337 <?php endif; ?>
1338 <?php
1339 // phpcs:enable
1340 /**
1341 * Filter: mainwp_header_actions_right
1342 *
1343 * Filters the MainWP header element actions.
1344 *
1345 * @since 4.0
1346 */
1347 $actions = apply_filters( 'mainwp_header_actions_right', '' );
1348 if ( ! empty( $actions ) ) {
1349 echo $actions; // phpcs:ignore WordPress.Security.EscapeOutput
1350 }
1351 ?>
1352 <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' ); ?>">
1353 <i class="globe icon"></i>
1354 </a>
1355
1356 <?php $custom_theme = MainWP_Settings::get_instance()->get_current_user_theme(); ?>
1357 <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' ); ?>">
1358 <i class="palette icon"></i>
1359 </div>
1360
1361 <?php
1362 /**
1363 * After select theme actions.
1364 *
1365 * @since 4.5.2
1366 */
1367 do_action( 'mainwp_header_actions_after_select_themes' );
1368 ?>
1369 <div class="ui icon top left pointing dropdown button" id="mainwp-help-menu-icon-button">
1370 <i class="ellipsis horizontal icon"></i>
1371 <div class="menu">
1372 <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=Settings' ) ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to MainWP Settings', 'mainwp' ); ?>">
1373 <i class="cog icon"></i> <?php esc_html_e( 'Settings', 'mainwp' ); ?></span>
1374 </a>
1375 <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformation' ) ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to MainWP Info', 'mainwp' ); ?>">
1376 <i class="circle info icon"></i> <?php esc_html_e( 'Info', 'mainwp' ); ?></span>
1377 </a>
1378 <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to WP Admin', 'mainwp' ); ?>">
1379 <i class="wordpress icon"></i> <?php //phpcs:ignore -- ignore wordpress icon. ?> <?php esc_html_e( 'WP Admin', 'mainwp' ); ?></span>
1380 </a>
1381 <a class="item" href="<?php echo wp_logout_url(); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Log out of your MainWP Dashboard', 'mainwp' ); ?>">
1382 <i class="sign out icon"></i> <?php esc_html_e( 'Log Out', 'mainwp' ); ?></span>
1383 </a>
1384 <a id="mainwp-help-sidebar" class="item" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Need help?', 'mainwp' ); ?>">
1385 <i class="life ring icon"></i> <?php esc_html_e( 'Get Support', 'mainwp' ); ?>
1386 </a>
1387 <a class="item" id="mainwp-community-button" data-inverted="" data-position="bottom right" href="https://managers.mainwp.com/" target="_blank" data-tooltip="<?php esc_attr_e( 'MainWP Community', 'mainwp' ); ?>">
1388 <i class="discourse icon"></i> <?php esc_html_e( 'Managers Community', 'mainwp' ); ?>
1389 </a>
1390 <a class="item" id="mainwp-account-button" 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/">
1391 <i class="user icon"></i> <?php esc_html_e( 'My MainWP Account', 'mainwp' ); ?>
1392 </a>
1393 </div>
1394 </div>
1395 <script>
1396 jQuery( document ).ready( function( $ ) {
1397 $( '#mainwp-help-menu-icon-button' ).dropdown();
1398 } );
1399 </script>
1400
1401 <?php
1402
1403 $all_updates = wp_get_update_data();
1404 if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) {
1405 ?>
1406 <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">
1407 <i class="exclamation triangle icon"></i>
1408 </a>
1409 <?php
1410 }
1411 $output = ob_get_clean();
1412 return $output;
1413 }
1414
1415 /**
1416 * Method render_page_navigation()
1417 *
1418 * Render page navigation.
1419 *
1420 * @param array $subitems [access, active, style].
1421 * @param null $name_caller Menu Name.
1422 */
1423 public static function render_page_navigation( $subitems = array(), $name_caller = null ) {
1424
1425 /**
1426 * Filter: mainwp_page_navigation
1427 *
1428 * Filters MainWP page navigation menu items.
1429 *
1430 * @since 4.0
1431 */
1432 $subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller );
1433 ?>
1434 <div id="mainwp-page-navigation-wrapper">
1435
1436 <div class="ui vertical menu mainwp-page-navigation">
1437 <?php
1438
1439 if ( is_array( $subitems ) ) {
1440 foreach ( $subitems as $item ) {
1441
1442 if ( ! is_array( $item ) ) {
1443 continue;
1444 }
1445
1446 if ( isset( $item['access'] ) && ! $item['access'] ) {
1447 continue;
1448 }
1449
1450 $class = '';
1451 if ( isset( $item['active'] ) && $item['active'] ) {
1452 $class = 'active';
1453 }
1454
1455 if ( isset( $item['class'] ) ) {
1456 $class = $class . ' ' . $item['class'];
1457 }
1458
1459 $style = '';
1460 if ( isset( $item['style'] ) ) {
1461 $style = $item['style'];
1462 }
1463
1464 ?>
1465
1466 <a class="<?php echo esc_attr( $class ); ?> item" style="<?php echo esc_attr( $style ); ?>" href="<?php echo esc_url( $item['href'] ); ?>">
1467 <?php echo isset( $item['before_title'] ) ? $item['before_title'] : ''; ?> <?php echo esc_html( $item['title'] ); ?> <?php echo isset( $item['after_title'] ) ? $item['after_title'] : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?>
1468 </a>
1469 <?php
1470 }
1471 }
1472
1473 do_action( 'mainwp_page_navigation_menu' );
1474 ?>
1475 </div>
1476
1477 </div>
1478 <?php
1479 $is_site = MainWP_System::is_mainwp_site_page();
1480 if ( $is_site ) {
1481 ?>
1482 <div id="mainwp-site-mode-wrap">
1483 <?php } ?>
1484
1485 <?php
1486 }
1487
1488 /**
1489 * Method render_header()
1490 *
1491 * Render page title.
1492 *
1493 * @param string $title Page title.
1494 *
1495 * @return void Render page title and hidden divider html.
1496 */
1497 public static function render_header( $title = '' ) {
1498 self::render_top_header( array( 'title' => $title ) );
1499 echo '<div class="ui hidden clearing fitted divider"></div>';
1500 echo '<div class="wrap">';
1501 }
1502
1503 /**
1504 * Method render_footer()
1505 *
1506 * Render page footer.
1507 *
1508 * @return void Render closing tags for page container.
1509 */
1510 public static function render_footer() {
1511 $is_site = MainWP_System::is_mainwp_site_page();
1512 if ( $is_site ) {
1513 echo '</div>';
1514 }
1515 echo '</div>';
1516 echo '</div>';
1517 }
1518
1519 /**
1520 * Method add_widget_box()
1521 *
1522 * Customize WordPress add_meta_box() function.
1523 *
1524 * @param mixed $id Widget ID parameter.
1525 * @param mixed $callback Callback function.
1526 * @param null $screen Current page.
1527 * @param array $layout widget layout.
1528 *
1529 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1530 */
1531 public static function add_widget_box( $id, $callback, $screen = null, $layout = array() ) {
1532 /**
1533 * MainWP widget boxes array.
1534 *
1535 * @global object
1536 */
1537 global $mainwp_widget_boxes;
1538
1539 $page = MainWP_System_Utility::get_page_id( $screen );
1540
1541 if ( empty( $page ) ) {
1542 return;
1543 }
1544
1545 if ( ! isset( $mainwp_widget_boxes ) ) {
1546 $mainwp_widget_boxes = array();
1547 }
1548 if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
1549 $mainwp_widget_boxes[ $page ] = array();
1550 }
1551
1552 if ( empty( $title ) ) {
1553 $title = 'No Title';
1554 }
1555 $mainwp_widget_boxes[ $page ][ $id ] = array(
1556 'id' => $id,
1557 'callback' => $callback,
1558 'layout' => $layout,
1559 );
1560 }
1561
1562 /**
1563 * Method do_widget_boxes()
1564 *
1565 * Customize WordPress do_meta_boxes() function.
1566 *
1567 * @param mixed $screen_id Current page ID.
1568 * @param array ...$args Widget callback args.
1569 *
1570 * @return void Renders widget container box.
1571 *
1572 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1573 */
1574 public static function do_widget_boxes( $screen_id, ...$args ) { // phpcs:ignore -- complex.
1575 global $mainwp_widget_boxes;
1576 $page = MainWP_System_Utility::get_page_id( $screen_id );
1577 if ( empty( $page ) ) {
1578 return;
1579 }
1580 $wgsorted = get_user_option( 'mainwp_widgets_sorted_' . strtolower( $page ) );
1581
1582 if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
1583 $wgsorted = json_decode( $wgsorted, true );
1584 }
1585
1586 $client_id = 0;
1587 if ( 'mainwp_page_manageclients' === $page ) {
1588 $sorted_array = is_array( $wgsorted ) ? $wgsorted : array();
1589 $wgsorted = array();
1590 $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1591 if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
1592 $wgsorted = $sorted_array[ $client_id ];
1593 }
1594 }
1595
1596 $wgsorted = apply_filters( 'mainwp_do_widget_boxes_sorted', $wgsorted, $page, $client_id );
1597
1598 if ( ! is_array( $wgsorted ) ) {
1599 $wgsorted = array();
1600 }
1601
1602 if ( 'mainwp_page_manageclients' === $page ) {
1603 $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
1604 } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1605 $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
1606 } else {
1607 $show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
1608 }
1609
1610 if ( ! is_array( $show_widgets ) ) {
1611 $show_widgets = array();
1612 }
1613
1614 if ( isset( $mainwp_widget_boxes[ $page ] ) ) {
1615 foreach ( (array) $mainwp_widget_boxes[ $page ] as $box ) {
1616 if ( false === $box || ! isset( $box['callback'] ) ) {
1617 continue;
1618 }
1619
1620 // to avoid hidden widgets.
1621 if ( isset( $show_widgets[ $box['id'] ] ) && 0 === (int) $show_widgets[ $box['id'] ] ) {
1622 continue;
1623 }
1624
1625 $layout = array();
1626 if ( isset( $wgsorted[ $box['id'] ] ) ) {
1627 $val = $wgsorted[ $box['id'] ];
1628 if ( is_array( $val ) && isset( $val['col'] ) ) {
1629 $layout = array(
1630 'col' => $val['col'],
1631 'row' => $val['row'],
1632 'size_x' => $val['size_x'],
1633 'size_y' => $val['size_y'],
1634 );
1635 }
1636 }
1637 if ( ! isset( $layout['col'] ) && isset( $box['layout'][0] ) ) {
1638 $layout = array(
1639 'col' => $box['layout'][0],
1640 'row' => $box['layout'][1],
1641 'size_x' => $box['layout'][2],
1642 'size_y' => $box['layout'][3],
1643 );
1644 }
1645 $layout_attrs_escaped = ' data-row="' . ( isset( $layout['row'] ) ? esc_attr( $layout['row'] ) : '' ) . '" data-col="' . ( isset( $layout['col'] ) ? esc_attr( $layout['col'] ) : '' ) . '" data-sizex="' . ( isset( $layout['size_x'] ) ? esc_attr( $layout['size_x'] ) : '' ) . '" data-sizey="' . ( isset( $layout['size_y'] ) ? esc_attr( $layout['size_y'] ) : '' ) . '" ';
1646 echo '<div id="widget-' . esc_html( $box['id'] ) . '" class="ui segment mainwp-widget" ' . $layout_attrs_escaped . '>' . "\n"; //phpcs:ignore -- escaped.
1647 call_user_func( $box['callback'], $screen_id, $args );
1648 echo '<span class="mainwp-resize-handle"></span>' . "\n";
1649 echo "</div>\n";
1650
1651 }
1652 }
1653 $breakpoint = apply_filters( 'mainwp_flexible_widgets_breakpoint', 1367 );
1654 ?>
1655 <script type="text/javascript">
1656 var is_mobile = false;
1657 if( jQuery( window ).width() < <?php echo intval( $breakpoint ); ?> ) {
1658 is_mobile = true;
1659 }
1660 if ( ! is_mobile ) {
1661 var page_sortablewidgets = '<?php echo esc_js( $page ); ?>';
1662 jQuery( document ).ready( function( $ ) {
1663 var wgIds = [];
1664 jQuery( ".mainwp-widget" ).each( function () {
1665 wgIds.push( jQuery( this ).attr('id') );
1666 } );
1667
1668 jQuery( '.gridster' ).gridster( {
1669 auto_init: true,
1670 autogenerate_stylesheet: true,
1671 shift_larger_widgets_down: false,
1672 shift_widgets_up: true,
1673 widget_selector: "div.mainwp-widget",
1674 widget_margins: [20, 20],
1675 widget_base_dimensions: ["auto", 20],
1676 min_cols: 1,
1677 max_cols: 12,
1678 max_size_x: 12,
1679 max_rows: 500,
1680 avoid_overlapped_widgets: true,
1681 collision: {
1682 wait_for_mouseup: true
1683 },
1684 draggable: {
1685 handle: '.handle-drag',
1686 stop: function (e, ui, $widget) {
1687 mainwp_overview_gridster_reorder(this);
1688 }
1689 },
1690 resize: {
1691 enabled: true,
1692 handle_append_to: ".mainwp-resize-handle",
1693 stop: function (e, ui, $widget) {
1694 mainwp_overview_gridster_reorder(this);
1695 }
1696 }
1697 } ).data('gridster');
1698
1699 mainwp_overview_gridster_reorder = function( $gridObj ){
1700 var orders = $gridObj.serialize();
1701 var postVars = {
1702 action:'mainwp_widgets_order',
1703 page: page_sortablewidgets,
1704 order:JSON.stringify(orders),
1705 wgids: JSON.stringify(wgIds),
1706 item_id: <?php echo intval( $client_id ); ?>
1707 };
1708 jQuery.post( ajaxurl, mainwp_secure_data( postVars ), function ( res ) {
1709 } );
1710 }
1711 });
1712 }
1713 </script>
1714 <?php
1715 }
1716
1717 /**
1718 * Method render_empty_bulk_actions()
1719 *
1720 * Render empty bulk actions when drop down is disabled.
1721 */
1722 public static function render_empty_bulk_actions() {
1723 ?>
1724 <select class="ui disabled dropdown" id="mainwp-bulk-actions">
1725 <option value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
1726 </select>
1727 <button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
1728 <?php
1729 }
1730
1731 /**
1732 * Method render_modal_install_plugin_theme()
1733 *
1734 * Render modal window for installing plugins & themes.
1735 *
1736 * @param string $what Which window to render, plugin|theme.
1737 */
1738 public static function render_modal_install_plugin_theme( $what = 'plugin' ) {
1739 ?>
1740 <div id="plugintheme-installation-progress-modal" class="ui modal">
1741 <i class="close icon"></i>
1742 <div class="header">
1743 <?php
1744 if ( 'plugin' === $what ) {
1745 esc_html_e( 'Plugin Installation', 'mainwp' );
1746 } elseif ( 'theme' === $what ) {
1747 esc_html_e( 'Theme Installation', 'mainwp' );
1748 }
1749 ?>
1750 </div>
1751 <div class="ui green progress mainwp-modal-progress">
1752 <div class="bar"><div class="progress"></div></div>
1753 <div class="label"></div>
1754 </div>
1755 <div class="scrolling content">
1756 <?php
1757 /**
1758 * Action: mainwp_before_plugin_theme_install_progress
1759 *
1760 * Fires before the progress list in the install modal element.
1761 *
1762 * @since 4.1
1763 */
1764 do_action( 'mainwp_before_plugin_theme_install_progress' );
1765 ?>
1766 <div id="plugintheme-installation-queue"></div>
1767 <?php
1768 /**
1769 * Action: mainwp_after_plugin_theme_install_progress
1770 *
1771 * Fires after the progress list in the install modal element.
1772 *
1773 * @since 4.1
1774 */
1775 do_action( 'mainwp_after_plugin_theme_install_progress' );
1776 ?>
1777 </div>
1778 <div class="actions" item-type="<?php echo esc_attr( $what ); ?>">
1779 <?php
1780 /**
1781 * Action: mainwp_after_plugin_theme_install_progress
1782 *
1783 * Fires after the progress list in the install modal element.
1784 *
1785 * @since 4.1
1786 */
1787 do_action( 'mainwp_install_plugin_theme_modal_action', $what );
1788 ?>
1789 <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1790 </div>
1791 </div>
1792 <?php
1793 }
1794
1795 /**
1796 * Method render_modal_upload_icon()
1797 *
1798 * Render modal window for upload plugins & themes icon.
1799 */
1800 public static function render_modal_upload_icon() {
1801
1802 ?>
1803 <div id="mainwp-upload-custom-icon-modal" class="ui modal">
1804 <i class="close icon"></i>
1805 <div class="header">
1806 <?php
1807 esc_html_e( 'Upload Icon', 'mainwp' );
1808 ?>
1809 </div>
1810 <div class="content" id="mainwp-upload-custom-icon-content">
1811 <form action="" method="post" enctype="multipart/form-data" name="uploadicon_form" id="uploadicon_form" class="">
1812 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1813 <div class="ui message" id="mainwp-message-zone-upload" style="display:none;"></div>
1814 <?php
1815 /**
1816 * Action: mainwp_after_upload_custom_icon
1817 *
1818 * Fires before the modal element.
1819 *
1820 * @since 4.3
1821 */
1822 do_action( 'mainwp_before_upload_custom_icon' );
1823 ?>
1824 <div class="ui form">
1825 <div class="ui grid field">
1826 <label class="six wide column middle aligned"><?php esc_html_e( 'Custom icon', 'mainwp' ); ?></label>
1827 <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1828 <div class="ui file input">
1829 <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' ); ?>" />
1830 </div>
1831 </div>
1832 </div>
1833 <div class="ui grid field" id="mainwp_delete_image_field">
1834 <label class="six wide column middle aligned"></label>
1835 <div class="six wide column">
1836 <img class="ui tiny image" src="" /><br/>
1837 <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, delete image.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1838 <input type="checkbox"id="mainwp_delete_image_chk" item-icon-id="" />
1839 <label for="mainwp_delete_image_chk"><?php esc_html_e( 'Delete Image', 'mainwp' ); ?></label>
1840 </div>
1841 </div>
1842 </div>
1843 </div>
1844 <?php
1845 /**
1846 * Action: mainwp_after_upload_custom_icon
1847 *
1848 * Fires after the modal element.
1849 *
1850 * @since 4.3
1851 */
1852 do_action( 'mainwp_after_upload_custom_icon' );
1853 ?>
1854 </form>
1855 </div>
1856 <div class="actions">
1857 <div class="ui green button" uploading-icon="default" id="update_custom_icon_btn"><?php esc_html_e( 'Update', 'mainwp' ); ?></div>
1858 </div>
1859 </div>
1860 <?php
1861 }
1862
1863 /**
1864 * Method render_show_all_updates_button()
1865 *
1866 * Render show all updates button.
1867 *
1868 * @return void Render Show All Updates button html.
1869 */
1870 public static function render_show_all_updates_button() {
1871 ?>
1872 <a href="javascript:void(0)" class="ui mini button trigger-all-accordion">
1873 <?php
1874 /**
1875 * Filter: mainwp_show_all_updates_button_text
1876 *
1877 * Filters the Show All Updates button text.
1878 *
1879 * @since 4.1
1880 */
1881 echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', esc_html__( 'Show All Updates', 'mainwp' ) ) );
1882 ?>
1883 </a>
1884 <?php
1885 }
1886
1887 /**
1888 * Method render_sorting_icons()
1889 *
1890 * Render sorting up & down icons.
1891 *
1892 * @return void Render Sort up & down incon html.
1893 */
1894 public static function render_sorting_icons() {
1895 ?>
1896 <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"></i>
1897 <?php
1898 }
1899
1900 /**
1901 * Method render_modal_edit_notes()
1902 *
1903 * Render modal window for edit notes.
1904 *
1905 * @param string $what What modal window to render. Default = site.
1906 *
1907 * @return void
1908 */
1909 public static function render_modal_edit_notes( $what = 'site' ) {
1910 ?>
1911 <div id="mainwp-notes-modal" class="ui modal">
1912 <div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div>
1913 <div class="content" id="mainwp-notes-content">
1914 <div id="mainwp-notes-status" class="ui message hidden"></div>
1915 <?php
1916 /**
1917 * Action: mainwp_before_edit_site_note
1918 *
1919 * Fires before the site note content in the Edit Note modal element.
1920 *
1921 * @since 4.1
1922 */
1923 do_action( 'mainwp_before_edit_site_note' );
1924 ?>
1925 <div id="mainwp-notes-html"></div>
1926 <div id="mainwp-notes-editor" class="ui form" style="display:none;">
1927 <div class="field">
1928 <label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label>
1929 <textarea id="mainwp-notes-note"></textarea>
1930 </div>
1931 <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>
1932 </div>
1933 <?php
1934 /**
1935 * Action: mainwp_after_edit_site_note
1936 *
1937 * Fires after the site note content in the Edit Note modal element.
1938 *
1939 * @since 4.1
1940 */
1941 do_action( 'mainwp_after_edit_site_note' );
1942 ?>
1943 </div>
1944 <div class="actions">
1945 <div class="ui grid">
1946 <div class="eight wide left aligned middle aligned column">
1947 <input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save Note', 'mainwp' ); ?>" style="display:none;"/>
1948 <input type="button" class="ui green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit Note', 'mainwp' ); ?>"/>
1949 </div>
1950 <div class="eight wide column">
1951 <input type="button" class="ui button" id="mainwp-notes-cancel" value="<?php esc_attr_e( 'Close', 'mainwp' ); ?>"/>
1952 <input type="hidden" id="mainwp-notes-websiteid" value=""/>
1953 <input type="hidden" id="mainwp-notes-slug" value=""/>
1954 <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
1955 <input type="hidden" id="mainwp-notes-itemid" value=""/>
1956 </div>
1957 </div>
1958 </div>
1959 </div>
1960
1961 <?php
1962 }
1963
1964 /**
1965 * No Sites Modal
1966 *
1967 * Renders modal window for notification when there are no connected sites.
1968 *
1969 * @return void
1970 */
1971 public static function render_modal_no_sites_note() {
1972 if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-no-sites-modal-notice' ) ) :
1973 ?>
1974 <div id="mainwp-no-sites-modal" class="ui small modal">
1975 <div class="content" id="mainwp-no-sites-modal-content" style="text-align:center">
1976 <div class="ui hidden divider"></div>
1977 <div class="ui hidden divider"></div>
1978 <h4><?php esc_html_e( 'Hi MainWP Manager, there is not anything to see here before connecting your first site.', 'mainwp' ); ?></h4>
1979 <div class="ui hidden divider"></div>
1980 <div class="ui hidden divider"></div>
1981 <a href="admin.php?page=managesites&do=new" class="ui big green button"><?php esc_html_e( 'Connect Your WordPress Site', 'mainwp' ); ?></a>
1982 <div class="ui hidden fitted divider"></div>
1983 <small><?php printf( esc_html__( 'or you can %1$sbulk import%2$s your sites.', 'mainwp' ), '<a href="admin.php?page=managesites&do=bulknew">', '</a>' ); ?></small>
1984 </div>
1985 <div class="actions">
1986 <div class="ui grid">
1987 <div class="eight wide left aligned middle aligned column">
1988 <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>
1989 </div>
1990 <div class="eight wide column">
1991 <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' ); ?>"/>
1992 </div>
1993 </div>
1994 </div>
1995 </div>
1996 <script type="text/javascript">
1997 jQuery( '#mainwp-no-sites-modal' ).modal( {
1998 blurring: true,
1999 inverted: true,
2000 closable: false
2001 } ).modal( 'show' );
2002 </script>
2003 <?php
2004 endif;
2005 }
2006
2007 /**
2008 * Method render_screen_options()
2009 *
2010 * Render modal window for Page Settings.
2011 *
2012 * @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Overview page.
2013 *
2014 * @return void Render modal window for Page Settings html.
2015 */
2016 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.
2017
2018 $default_widgets = array(
2019 'overview' => esc_html__( 'Updates Overview', 'mainwp' ),
2020 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
2021 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
2022 'plugins' => esc_html__( 'Plugins (Individual Site Overview page)', 'mainwp' ),
2023 'themes' => esc_html__( 'Themes (Individual Site Overview page)', 'mainwp' ),
2024 'connection_status' => esc_html__( 'Connection Status', 'mainwp' ),
2025 'security_issues' => esc_html__( 'Security Issues', 'mainwp' ),
2026 'notes' => esc_html__( 'Notes (Individual Site Overview page)', 'mainwp' ),
2027 'clients' => esc_html__( 'Clients', 'mainwp' ),
2028 'child_site_info' => esc_html__( 'Child site info (Individual Site Overview page)', 'mainwp' ),
2029 'client_info' => esc_html__( 'Client info (Individual Site Overview page)', 'mainwp' ),
2030 'non_mainwp_changes' => esc_html__( 'Non-MainWP Changes', 'mainwp' ),
2031 'get-started' => esc_html__( 'Get Started with MainWP', 'mainwp' ),
2032 );
2033
2034 $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.
2035
2036 /**
2037 * Filter: mainwp_widgets_screen_options
2038 *
2039 * Filters available widgets on the Overview page allowing users to unsent unwanted widgets.
2040 *
2041 * @since 4.0
2042 */
2043 $custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts );
2044
2045 if ( is_array( $custom_opts ) && 0 < count( $custom_opts ) ) {
2046 $default_widgets = array_merge( $default_widgets, $custom_opts );
2047 }
2048
2049 $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
2050
2051 if ( ! is_array( $show_widgets ) ) {
2052 $show_widgets = array();
2053 }
2054
2055 $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
2056 $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
2057 $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
2058
2059 /**
2060 * Action: mainwp_screen_options_modal_top
2061 *
2062 * Fires at the top of the Page Settings modal element.
2063 *
2064 * @since 4.1
2065 */
2066 do_action( 'mainwp_screen_options_modal_top' );
2067 $which_settings = 'overview_settings';
2068 ?>
2069 <?php if ( ! $setting_page ) : ?>
2070 <?php if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2071 <?php
2072 $which_settings = 'sidebar_settings';
2073 $sidebarPosition = (int) get_user_option( 'mainwp_sidebarPosition', 1 );
2074 $manageGroupsPage = false;
2075 if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2076 $manageGroupsPage = true;
2077 }
2078 ?>
2079 <div class="ui grid field">
2080 <label tabindex="0" class="six wide column middle aligned"><?php echo $manageGroupsPage ? esc_html__( 'Tags menu position', 'mainwp' ) : esc_html__( 'Sidebar position', 'mainwp' ); ?></label>
2081 <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">
2082 <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
2083 <option value="1" <?php echo ( 1 === $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Right', 'mainwp' ); ?></option>
2084 <option value="0" <?php echo ( 0 === $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
2085 </select>
2086 </div>
2087 </div>
2088 <?php endif; ?>
2089 <?php endif; ?>
2090 <?php
2091 if ( isset( $_GET['page'] ) && ! in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2092 $hide_up_everything = (int) get_option( 'mainwp_hide_update_everything' );
2093 ?>
2094 <div class="ui grid field">
2095 <label class="six wide column middle aligned">
2096 <?php
2097 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_hide_update_everything', $hide_up_everything );
2098 esc_html_e( 'Hide the Update Everything button', 'mainwp' );
2099 ?>
2100 </label>
2101 <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">
2102 <input type="checkbox" name="hide_update_everything" <?php echo ( ( 1 === $hide_up_everything ) ? 'checked="true"' : '' ); ?> />
2103 </div>
2104 </div>
2105 <?php
2106 $indi_val = 'all';
2107 foreach ( $default_widgets as $name => $title ) {
2108 $_selected = '';
2109 if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
2110 $_selected = 'checked';
2111 continue;
2112 }
2113 $indi_val = '';
2114 }
2115 ?>
2116 <div class="ui grid field">
2117 <label class="six wide column">
2118 <?php
2119 if ( $setting_page ) {
2120 MainWP_Settings_Indicator::render_not_default_indicator( 'show_default_widgets', $indi_val );
2121 }
2122 esc_html_e( 'Show widgets', 'mainwp' );
2123 ?>
2124 </label>
2125 <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">
2126 <ul class="mainwp_hide_wpmenu_checkboxes">
2127 <?php
2128 foreach ( $default_widgets as $name => $title ) {
2129 $_selected = '';
2130 if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
2131 $_selected = 'checked';
2132 }
2133 ?>
2134 <li>
2135 <div class="ui checkbox">
2136 <input type="checkbox" id="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" name="mainwp_show_widgets[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
2137 <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
2138 </div>
2139 <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
2140 </li>
2141 <?php
2142 }
2143 ?>
2144 </ul>
2145 </div>
2146 </div>
2147 <?php
2148 endif;
2149 ?>
2150 <input type="hidden" name="reset_overview_which_settings" value="<?php echo esc_html( $which_settings ); ?>" />
2151 <?php
2152 /**
2153 * Action: mainwp_screen_options_modal_bottom
2154 *
2155 * Fires at the bottom of the Page Settings modal element.
2156 *
2157 * @since 4.1
2158 */
2159 do_action( 'mainwp_screen_options_modal_bottom' );
2160 }
2161
2162 /**
2163 * Method render_select_mainwp_themes_modal()
2164 *
2165 * Render modal window for mainwp themes selection.
2166 *
2167 * @return void Render modal window for themes selection.
2168 */
2169 public static function render_select_mainwp_themes_modal() {
2170 ?>
2171 <div class="ui modal" id="mainwp-select-mainwp-themes-modal">
2172 <i class="close icon"></i>
2173 <div class="header"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></div>
2174 <div class="content ui form">
2175 <div class="ui blue message">
2176 <div class=""><?php printf( 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>
2177 </div>
2178 <form method="POST" action="" name="mainwp_select_mainwp_themes_form" id="mainwp_select_mainwp_themes_form">
2179 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2180 <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPSelectThemes' ) ); ?>" />
2181 <?php
2182 /**
2183 * Action: mainwp_select_themes_modal_top
2184 *
2185 * Fires at the top of the modal.
2186 *
2187 * @since 4.3
2188 */
2189 do_action( 'mainwp_select_themes_modal_top' );
2190
2191 MainWP_Settings::get_instance()->render_select_custom_themes();
2192
2193 /**
2194 * Action: mainwp_select_themes_modal_bottom
2195 *
2196 * Fires at the bottom of the modal.
2197 *
2198 * @since 4.3
2199 */
2200 do_action( 'mainwp_select_themes_modal_bottom' );
2201 ?>
2202 </div>
2203 <div class="actions">
2204 <div class="ui two columns grid">
2205 <div class="left aligned column">
2206
2207 </div>
2208 <div class="ui right aligned column">
2209 <input type="submit" class="ui green button" id="submit-select-mainwp-themes" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2210 </div>
2211 </div>
2212 </div>
2213 </form>
2214 </div>
2215 <?php
2216 }
2217
2218 /**
2219 * Method render_install_extensions_promo_modal()
2220 */
2221 public static function render_install_extensions_promo_modal() {
2222 $mainwp_api_key = MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key();
2223 ?>
2224 <div class="ui small modal" id="mainwp-install-extensions-promo-modal">
2225 <i class="close icon"></i>
2226 <?php if ( empty( $mainwp_api_key ) ) : ?>
2227 <div class="header"><?php esc_html_e( 'Get MainWP Pro', 'mainwp' ); ?></div>
2228 <div class="content">
2229 <div class="ui header"><?php esc_html_e( 'With your MainWP Pro subscription, you get access to:', 'mainwp' ); ?></div>
2230 <div class="ui bulleted list">
2231 <div class="item"><?php esc_html_e( 'All 30+ Existing Premium Extensions', 'mainwp' ); ?></div>
2232 <div class="item"><?php esc_html_e( 'All Future Extensions', 'mainwp' ); ?></div>
2233 <div class="item"><?php esc_html_e( 'Critical Security & Performance Updates', 'mainwp' ); ?></div>
2234 <div class="item"><?php esc_html_e( 'Priority Support with Subscription', 'mainwp' ); ?></div>
2235 <div class="item"><?php esc_html_e( 'Manage Unlimited Websites', 'mainwp' ); ?></div>
2236 </div>
2237 <a href="https://mainwp.com/signup/?utm_campaign=Dashboard%20-%20Upgrade%20to%20Pro&utm_source=Dashboard&utm_medium=grey%20link%20modal&utm_term=get%20mainwp%20pro" class="ui big green button" target="_blank">Get MainWP Pro</a>
2238 </div>
2239 <?php else : ?>
2240 <div class="header"><?php esc_html_e( 'Install Extensions', 'mainwp' ); ?></div>
2241 <div class="content">
2242 <div class="ui header"><?php esc_html_e( 'Extension not activated', 'mainwp' ); ?></div>
2243 <div><?php esc_html_e( 'Go to the ', 'mainwp' ); ?><a href="admin.php?page=Extensions">MainWP > Extensions</a><?php esc_html_e( ' page to install and activate extensions', 'mainwp' ); ?></div>
2244 </div>
2245 <?php endif; ?>
2246 </div>
2247 <?php
2248 }
2249
2250 /**
2251 * Method render_empty_element_placeholder()
2252 *
2253 * Renders the content for empty elements.
2254 *
2255 * @param string $placeholder Placelolder text.
2256 */
2257 public static function render_empty_element_placeholder( $placeholder = '' ) {
2258 ?>
2259 <div class="ui one column grid">
2260 <div class="middle aligned center aligned column">
2261 <img src="<?php echo esc_url( MAINWP_PLUGIN_URL ); ?>assets/images/mainwp-widget-placeholder.png" style="max-width:200px" class="mainwp-no-results-placeholder ui middle aligned image"/>
2262 <?php if ( '' !== $placeholder ) : ?>
2263 <p><?php echo $placeholder; //phpcs:ignore -- requires escaped. ?></p>
2264 <?php else : ?>
2265 <p><?php echo esc_html__( 'Nothing to show here, check back later!', 'mainwp' ); ?></p>
2266 <?php endif; ?>
2267 </div>
2268 </div>
2269 <?php
2270 }
2271
2272 /**
2273 * Method render_modal_save_segment()
2274 *
2275 * Render modal window.
2276 *
2277 * @return void
2278 */
2279 public static function render_modal_save_segment() {
2280 ?>
2281 <div id="mainwp-common-filter-segment-modal" class="ui tiny modal">
2282 <i class="close icon" id="mainwp-common-filter-segment-cancel"></i>
2283 <div class="header"><?php esc_html_e( 'Save Segment', 'mainwp' ); ?></div>
2284 <div class="content" id="mainwp-common-filter-segment-content">
2285 <div id="mainwp-common-filter-edit-segment-status" class="ui message hidden"></div>
2286 <div id="mainwp-common-filter-segment-edit-fields" class="ui form">
2287 <div class="field">
2288 <label><?php esc_html_e( 'Enter the segment name', 'mainwp' ); ?></label>
2289 </div>
2290 <div class="field">
2291 <input type="text" id="mainwp-common-filter-edit-segment-name" value=""/>
2292 </div>
2293 </div>
2294 <div id="mainwp-common-filter-segment-select-fields" style="display:none;">
2295 <div class="field">
2296 <label><?php esc_html_e( 'Select a segment', 'mainwp' ); ?></label>
2297 </div>
2298 <div class="field">
2299 <div id="mainwp-common-filter-segments-lists-wrapper"></div>
2300 </div>
2301 </div>
2302 </div>
2303 <div class="actions">
2304 <div class="ui grid">
2305 <div class="eight wide left aligned middle aligned column">
2306 <input type="button" class="ui green button" id="mainwp-common-filter-edit-segment-save" value="<?php esc_attr_e( 'Save', 'mainwp' ); ?>"/>
2307 <input type="button" class="ui green button" id="mainwp-common-filter-select-segment-choose-button" value="<?php esc_attr_e( 'Choose', 'mainwp' ); ?>" style="display:none;"/>
2308 <input type="button" class="ui basic button" id="mainwp-common-filter-select-segment-delete-button" value="<?php esc_attr_e( 'Delete', 'mainwp' ); ?>" style="display:none;"/>
2309 </div>
2310 <div class="eight wide column">
2311
2312 </div>
2313 </div>
2314 </div>
2315 </div>
2316
2317 <?php
2318 }
2319
2320
2321 /**
2322 * Method get_default_icons().
2323 *
2324 * @return array icons.
2325 */
2326 public static function get_default_icons() {
2327 $icons = array(
2328 'wordpress', //phpcs:ignore -- WP icon.
2329 'ambulance',
2330 'anchor',
2331 'archive',
2332 'award',
2333 'baby carriage',
2334 'balance scale',
2335 'balance scale left',
2336 'balance scale right',
2337 'bath',
2338 'bed',
2339 'beer',
2340 'bell',
2341 'bell outline',
2342 'bicycle',
2343 'binoculars',
2344 'birthday cake',
2345 'blender',
2346 'bomb',
2347 'book',
2348 'book dead',
2349 'bookmark',
2350 'bookmark outline',
2351 'briefcase',
2352 'broadcast tower',
2353 'bug',
2354 'building',
2355 'building outline',
2356 'bullhorn',
2357 'bullseye',
2358 'bus',
2359 'calculator',
2360 'calendar',
2361 'calendar alternate',
2362 'calendar alternate outline',
2363 'calendar outline',
2364 'camera',
2365 'camera retro',
2366 'candy cane',
2367 'car',
2368 'carrot',
2369 'church',
2370 'clipboard',
2371 'clipboard outline',
2372 'cloud',
2373 'coffee',
2374 'cog',
2375 'cogs',
2376 'compass',
2377 'compass outline',
2378 'cookie',
2379 'cookie bite',
2380 'copy',
2381 'copy outline',
2382 'cube',
2383 'cubes',
2384 'cut',
2385 'dice',
2386 'dice d20',
2387 'dice d6',
2388 'dice five',
2389 'dice four',
2390 'dice one',
2391 'dice six',
2392 'dice three',
2393 'dice two',
2394 'digital tachograph',
2395 'door closed',
2396 'door open',
2397 'drum',
2398 'drum steelpan',
2399 'envelope',
2400 'envelope open',
2401 'envelope open outline',
2402 'envelope outline',
2403 'eraser',
2404 'eye',
2405 'eye dropper',
2406 'eye outline',
2407 'fax',
2408 'feather',
2409 'feather alternate',
2410 'fighter jet',
2411 'file',
2412 'file alternate',
2413 'file alternate outline',
2414 'file outline',
2415 'file prescription',
2416 'film',
2417 'fire',
2418 'fire alternate',
2419 'fire extinguisher',
2420 'flag',
2421 'flag checkered',
2422 'flag outline',
2423 'flask',
2424 'futbol',
2425 'futbol outline',
2426 'gamepad',
2427 'gavel',
2428 'gem',
2429 'gem outline',
2430 'gift',
2431 'gifts',
2432 'glass cheers',
2433 'glass martini',
2434 'glass whiskey',
2435 'glasses',
2436 'globe',
2437 'graduation cap',
2438 'guitar',
2439 'hat wizard',
2440 'hdd',
2441 'hdd outline',
2442 'headphones',
2443 'headphones alternate',
2444 'headset',
2445 'heart',
2446 'heart broken',
2447 'heart outline',
2448 'helicopter',
2449 'highlighter',
2450 'holly berry',
2451 'home',
2452 'hospital',
2453 'hospital outline',
2454 'hourglass',
2455 'hourglass outline',
2456 'igloo',
2457 'image',
2458 'image outline',
2459 'images',
2460 'images outline',
2461 'industry',
2462 'key',
2463 'keyboard',
2464 'keyboard outline',
2465 'laptop',
2466 'leaf',
2467 'lemon',
2468 'lemon outline',
2469 'life ring',
2470 'life ring outline',
2471 'lightbulb',
2472 'lightbulb outline',
2473 'lock',
2474 'lock open',
2475 'magic',
2476 'magnet',
2477 'map',
2478 'map marker',
2479 'map marker alternate',
2480 'map outline',
2481 'map pin',
2482 'map signs',
2483 'marker',
2484 'medal',
2485 'medkit',
2486 'memory',
2487 'microchip',
2488 'microphone',
2489 'microphone alternate',
2490 'mitten',
2491 'mobile',
2492 'mobile alternate',
2493 'money bill',
2494 'money bill alternate',
2495 'money bill alternate outline',
2496 'money check',
2497 'money check alternate',
2498 'moon',
2499 'moon outline',
2500 'motorcycle',
2501 'mug hot',
2502 'newspaper',
2503 'newspaper outline',
2504 'paint brush',
2505 'paper plane',
2506 'paper plane outline',
2507 'paperclip',
2508 'paste',
2509 'paw',
2510 'pen',
2511 'pen alternate',
2512 'pen fancy',
2513 'pen nib',
2514 'pencil alternate',
2515 'phone',
2516 'phone alternate',
2517 'plane',
2518 'plug',
2519 'print',
2520 'puzzle piece',
2521 'ring',
2522 'road',
2523 'rocket',
2524 'ruler combined',
2525 'ruler horizontal',
2526 'ruler vertical',
2527 'satellite',
2528 'satellite dish',
2529 'save',
2530 'save outline',
2531 'school',
2532 'screwdriver',
2533 'scroll',
2534 'sd card',
2535 'search',
2536 'shield alternate',
2537 'shopping bag',
2538 'shopping basket',
2539 'shopping cart',
2540 'shower',
2541 'sim card',
2542 'skull crossbones',
2543 'sleigh',
2544 'snowflake',
2545 'snowflake outline',
2546 'snowplow',
2547 'space shuttle',
2548 'star',
2549 'star outline',
2550 'sticky note',
2551 'sticky note outline',
2552 'stopwatch',
2553 'stroopwafel',
2554 'subway',
2555 'suitcase',
2556 'sun',
2557 'sun outline',
2558 'tablet',
2559 'tablet alternate',
2560 'tachometer alternate',
2561 'tag',
2562 'tags',
2563 'taxi',
2564 'thumbtack',
2565 'ticket alternate',
2566 'toilet',
2567 'toolbox',
2568 'tools',
2569 'train',
2570 'tram',
2571 'trash',
2572 'trash alternate',
2573 'trash alternate outline',
2574 'tree',
2575 'trophy',
2576 'truck',
2577 'tv',
2578 'umbrella',
2579 'university',
2580 'unlock',
2581 'unlock alternate',
2582 'utensil spoon',
2583 'utensils',
2584 'wallet',
2585 'weight',
2586 'wheelchair',
2587 'wine glass',
2588 'wrench',
2589 'folder',
2590 'folder open',
2591 'palette',
2592 'server',
2593 'tint',
2594 );
2595 return $icons;
2596 }
2597 }
2598