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

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

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