PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.2.2
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.2.2, at class/class-mainwp-ui.php

2,575 lines 121.4 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">
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( '#mainwp-help-sidebar' ).on( 'click', function() {
1034 jQuery( '.ui.help.sidebar' ).sidebar( {
1035 transition: 'overlay'
1036 } );
1037 jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' );
1038 return false;
1039 } );
1040 jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() {
1041 jQuery( '.ui.sites.sidebar' ).sidebar( {
1042 transition: 'overlay',
1043 'onVisible': function() {
1044 jQuery( '#mainwp-sites-menu-filter' ).focus();
1045 }
1046 } );
1047 jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' );
1048 return false;
1049 } );
1050 jQuery( '#mainwp-sites-sidebar-menu' ).accordion();
1051 } );
1052 </script>
1053 <?php
1054 /**
1055 * Action: mainwp_after_header
1056 *
1057 * Fires after the MainWP header element.
1058 *
1059 * @param array $websites Array containing the child site data.
1060 *
1061 * @since 4.0
1062 */
1063 do_action( 'mainwp_after_header', $websites );
1064 ?>
1065 <?php
1066 }
1067
1068
1069 /**
1070 * Method render_showhide_columns_settings()
1071 *
1072 * Render show/hide columns settings.
1073 *
1074 * @param array $cols Columns.
1075 * @param array $show_columns Show Columns.
1076 * @param string $what what.
1077 */
1078 public static function render_showhide_columns_settings( $cols, $show_columns, $what ) {
1079 ?>
1080 <div class="ui grid field">
1081 <label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label>
1082 <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">
1083 <ul>
1084 <?php
1085 foreach ( $cols as $name => $title ) {
1086 $_selected = '';
1087 if ( ! isset( $show_columns[ $name ] ) || 1 === (int) $show_columns[ $name ] ) {
1088 $_selected = 'checked';
1089 }
1090 ?>
1091 <li>
1092 <div class="ui checkbox">
1093 <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 ); ?>">
1094 <label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
1095 </div>
1096 <input type="hidden" name="mainwp_columns_name[]" value="<?php echo esc_attr( $name ); ?>">
1097 </li>
1098 <?php
1099 }
1100 ?>
1101 </ul>
1102 </div>
1103
1104 </div>
1105 <?php
1106
1107 $input_name = '';
1108 if ( 'post' === $what ) {
1109 $input_name = 'mainwp_manageposts_show_columns_settings';
1110 } elseif ( 'page' === $what ) {
1111 $input_name = 'mainwp_managepages_show_columns_settings';
1112 } elseif ( 'user' === $what ) {
1113 $input_name = 'mainwp_manageusers_show_columns_settings';
1114 }
1115
1116 if ( ! empty( $input_name ) ) {
1117 ?>
1118 <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1119 <?php
1120 }
1121 }
1122
1123 /**
1124 * Method render_second_top_header()
1125 *
1126 * Render second top header.
1127 *
1128 * @param string $which Current page.
1129 *
1130 * @return void Render second top header html.
1131 */
1132 public static function render_second_top_header( $which = '' ) {
1133
1134 /**
1135 * Action: mainwp_before_subheader
1136 *
1137 * Fires before the MainWP sub-header element.
1138 *
1139 * @since 4.0
1140 */
1141 do_action( 'mainwp_before_subheader' );
1142 if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) {
1143 ?>
1144 <div class="mainwp-sub-header">
1145 <?php
1146 if ( 'overview' === $which ) {
1147 ?>
1148 <div class="ui stackable grid">
1149 <div class="column full">
1150 <?php static::gen_groups_sites_selection(); ?>
1151 </div>
1152 </div>
1153 <?php
1154 }
1155 ?>
1156 <?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?>
1157 <?php
1158 /**
1159 * Action: mainwp_managesites_tabletop
1160 *
1161 * Fires at the table top on the Manage Sites and Monitoring page.
1162 *
1163 * @since 4.0
1164 */
1165 do_action( 'mainwp_managesites_tabletop' );
1166 ?>
1167
1168 <?php else : ?>
1169 <?php
1170 /**
1171 * Action: mainwp_subheader_actions
1172 *
1173 * Fires at the subheader element to hook available actions.
1174 *
1175 * @since 4.0
1176 */
1177 do_action( 'mainwp_subheader_actions' );
1178 ?>
1179 <?php endif; ?>
1180 </div>
1181 <?php
1182 }
1183 /**
1184 * Action: mainwp_after_subheader
1185 *
1186 * Fires after the MainWP sub-header element.
1187 *
1188 * @since 4.0
1189 */
1190 do_action( 'mainwp_after_subheader' );
1191 }
1192
1193 /**
1194 * Method gen_groups_sites_selection()
1195 *
1196 * Generate group sites selection box.
1197 *
1198 * @return void Render group sites selection box.
1199 *
1200 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_manage_sites()
1201 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_not_empty_groups()
1202 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1203 * @uses \MainWP\Dashboard\MainWP_DB::query()
1204 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1205 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1206 */
1207 public static function gen_groups_sites_selection() {
1208 $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' ) );
1209 $websites = MainWP_DB::instance()->query( $sql );
1210 $g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1211 $s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1212 ?>
1213 <div class="column full wide">
1214 <select id="mainwp_top_quick_jump_group" class="ui dropdown">
1215 <option value="" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1216 <option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1217 <?php
1218 $groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites();
1219 foreach ( $groups as $group ) {
1220 ?>
1221 <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>
1222 <?php
1223 }
1224 ?>
1225 </select>
1226 <select class="ui dropdown" id="mainwp_top_quick_jump_page">
1227 <option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1228 <option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1229 <?php
1230 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1231 ?>
1232 <option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s === (int) $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo esc_html( stripslashes( $website->name ) ); ?></option>
1233 <?php
1234 }
1235 ?>
1236 </select>
1237 </div>
1238 <script type="text/javascript">
1239 jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () {
1240 let jumpid = jQuery( this ).val();
1241 window.location = 'admin.php?page=managesites&g=' + jumpid;
1242 } );
1243 jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () {
1244 let jumpid = jQuery( this ).val();
1245 if ( jumpid == -1 )
1246 window.location = 'admin.php?page=managesites&s=' + jumpid;
1247 else
1248 window.location = 'admin.php?page=managesites&dashboard=' + jumpid;
1249 } );
1250 </script>
1251 <?php
1252 MainWP_DB::free_result( $websites );
1253 }
1254
1255 /**
1256 * Method render_header_actions()
1257 *
1258 * Render header action buttons,
1259 * (Sync|Add|Options|Community|User|Updates).
1260 *
1261 * @return mixed $output Render header action buttons html.
1262 *
1263 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1264 */
1265 public static function render_header_actions() { //phpcs:ignore -- NOSONAR - complex method.
1266 $sites_count = MainWP_DB::instance()->get_websites_count();
1267 $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1268 $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1269 $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
1270
1271 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1272 $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
1273 ob_start();
1274 if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) :
1275 $id = 0;
1276 if ( isset( $_GET['dashboard'] ) ) {
1277 $id = intval( $_GET['dashboard'] );
1278 } elseif ( isset( $_GET['id'] ) ) {
1279 $id = intval( $_GET['id'] );
1280 } elseif ( isset( $_GET['updateid'] ) ) {
1281 $id = intval( $_GET['updateid'] );
1282 } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1283 $id = intval( $_GET['emailsettingsid'] );
1284 } elseif ( isset( $_GET['scanid'] ) ) {
1285 $id = intval( $_GET['scanid'] );
1286 }
1287
1288 $website = MainWP_DB::instance()->get_website_by_id( $id );
1289 ?>
1290 <?php if ( $id && $website && '' !== $website->sync_errors ) : ?>
1291 <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>
1292 <?php else : ?>
1293 <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' ); ?>" >
1294 <i class="sync icon"></i>
1295 </a>
1296 <?php endif; ?>
1297 <?php else : ?>
1298 <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' ); ?>">
1299 <i class="sync alternate icon"></i>
1300 </a>
1301 <?php endif; ?>
1302
1303 <div class="ui icon top left pointing dropdown <?php echo empty( $sites_count ) ? 'green' : ''; ?> button" id="mainwp-add-new-buttons" 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">
1304 <i class="plus icon"></i>
1305 <div class="menu">
1306 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Website to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Add Website', 'mainwp' ); ?></a>
1307 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Client to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=ClientAddNew' ) ); ?>"><?php esc_html_e( 'Add Client', 'mainwp' ); ?></a>
1308 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Cost to for tracking', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=CostTrackerAdd' ) ); ?>"><?php esc_html_e( 'Add Cost', 'mainwp' ); ?></a>
1309 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Post to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=PostBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Post', 'mainwp' ); ?></a>
1310 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Page to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Page', 'mainwp' ); ?></a>
1311 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Install a new Plugin to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsInstall' ) ); ?>"><?php esc_html_e( 'Install Plugin', 'mainwp' ); ?></a>
1312 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Install a new Theme to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=ThemesInstall' ) ); ?>"><?php esc_html_e( 'Install Theme', 'mainwp' ); ?></a>
1313 <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Create a new User to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=UserBulkAdd' ) ); ?>"><?php esc_html_e( ' Create User', 'mainwp' ); ?></a>
1314 </div>
1315 </div>
1316
1317 <?php if ( ( 'mainwp_tab' === $page ) || isset( $_GET['dashboard'] ) || in_array( $page, $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
1318 <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' ); ?>">
1319 <i class="cog icon"></i>
1320 </a>
1321 <?php endif; ?>
1322 <?php
1323 // phpcs:enable
1324 /**
1325 * Filter: mainwp_header_actions_right
1326 *
1327 * Filters the MainWP header element actions.
1328 *
1329 * @since 4.0
1330 */
1331 $actions = apply_filters( 'mainwp_header_actions_right', '' );
1332 if ( ! empty( $actions ) ) {
1333 echo $actions; // phpcs:ignore WordPress.Security.EscapeOutput
1334 }
1335 ?>
1336 <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' ); ?>">
1337 <i class="globe icon"></i>
1338 </a>
1339 <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' ); ?>">
1340 <i class="palette icon"></i>
1341 </div>
1342
1343 <?php
1344 /**
1345 * After select theme actions.
1346 *
1347 * @since 4.5.2
1348 */
1349 do_action( 'mainwp_header_actions_after_select_themes' );
1350 ?>
1351 <div class="ui icon top left pointing dropdown button" id="mainwp-help-menu-icon-button">
1352 <i class="ellipsis horizontal icon"></i>
1353 <div class="menu">
1354 <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' ); ?>">
1355 <i class="cog icon"></i> <?php esc_html_e( 'Settings', 'mainwp' ); ?></span>
1356 </a>
1357 <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' ); ?>">
1358 <i class="circle info icon"></i> <?php esc_html_e( 'Info', 'mainwp' ); ?></span>
1359 </a>
1360 <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' ); ?>">
1361 <i class="wordpress icon"></i> <?php //phpcs:ignore -- ignore wordpress icon. ?> <?php esc_html_e( 'WP Admin', 'mainwp' ); ?></span>
1362 </a>
1363 <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' ); ?>">
1364 <i class="sign out icon"></i> <?php esc_html_e( 'Log Out', 'mainwp' ); ?></span>
1365 </a>
1366 <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' ); ?>">
1367 <i class="life ring icon"></i> <?php esc_html_e( 'Get Support', 'mainwp' ); ?>
1368 </a>
1369 <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' ); ?>">
1370 <i class="discourse icon"></i> <?php esc_html_e( 'Managers Community', 'mainwp' ); ?>
1371 </a>
1372 <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. ?>
1373 <i class="user icon"></i> <?php esc_html_e( 'My MainWP Account', 'mainwp' ); ?>
1374 </a>
1375 </div>
1376 </div>
1377 <script>
1378 jQuery( document ).ready( function( $ ) {
1379 $( '#mainwp-help-menu-icon-button' ).dropdown();
1380 } );
1381 </script>
1382
1383 <?php
1384
1385 $all_updates = wp_get_update_data();
1386 if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) {
1387 ?>
1388 <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">
1389 <i class="exclamation triangle icon"></i>
1390 </a>
1391 <?php
1392 }
1393 return ob_get_clean();
1394 }
1395
1396 /**
1397 * Method render_page_navigation()
1398 *
1399 * Render page navigation.
1400 *
1401 * @param array $subitems [access, active, style].
1402 * @param null $name_caller Menu Name.
1403 */
1404 public static function render_page_navigation( $subitems = array(), $name_caller = null ) { //phpcs:ignore -- NOSONAR - complex.
1405
1406 /**
1407 * Filter: mainwp_page_navigation
1408 *
1409 * Filters MainWP page navigation menu items.
1410 *
1411 * @since 4.0
1412 */
1413 $subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller );
1414 ?>
1415 <div id="mainwp-page-navigation-wrapper">
1416
1417 <div class="ui vertical menu mainwp-page-navigation">
1418 <?php
1419
1420 if ( is_array( $subitems ) ) {
1421 foreach ( $subitems as $item ) {
1422
1423 if ( ! is_array( $item ) ) {
1424 continue;
1425 }
1426
1427 if ( isset( $item['access'] ) && ! $item['access'] ) {
1428 continue;
1429 }
1430
1431 $class = '';
1432 if ( isset( $item['active'] ) && $item['active'] ) {
1433 $class = 'active';
1434 }
1435
1436 if ( isset( $item['class'] ) ) {
1437 $class = $class . ' ' . $item['class'];
1438 }
1439
1440 $style = '';
1441 if ( isset( $item['style'] ) ) {
1442 $style = $item['style'];
1443 }
1444
1445 ?>
1446
1447 <a class="<?php echo esc_attr( $class ); ?> item" style="<?php echo esc_attr( $style ); ?>" href="<?php echo esc_url( $item['href'] ); ?>">
1448 <?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 ?>
1449 </a>
1450 <?php
1451 }
1452 }
1453
1454 do_action( 'mainwp_page_navigation_menu' );
1455 ?>
1456 </div>
1457
1458 </div>
1459 <?php
1460 $is_site = MainWP_System::is_mainwp_site_page();
1461 if ( $is_site ) {
1462 ?>
1463 <div id="mainwp-site-mode-wrap">
1464 <?php } ?>
1465
1466 <?php
1467 }
1468
1469 /**
1470 * Method render_header()
1471 *
1472 * Render page title.
1473 *
1474 * @param string $title Page title.
1475 *
1476 * @return void Render page title and hidden divider html.
1477 */
1478 public static function render_header( $title = '' ) {
1479 static::render_top_header( array( 'title' => $title ) );
1480 echo '<div class="ui hidden clearing fitted divider"></div>';
1481 echo '<div class="wrap">';
1482 }
1483
1484 /**
1485 * Method render_footer()
1486 *
1487 * Render page footer.
1488 *
1489 * @return void Render closing tags for page container.
1490 */
1491 public static function render_footer() {
1492 $is_site = MainWP_System::is_mainwp_site_page();
1493 if ( $is_site ) {
1494 echo '</div>';
1495 }
1496 echo '</div>';
1497 echo '</div>';
1498 }
1499
1500 /**
1501 * Method add_widget_box()
1502 *
1503 * Customize WordPress add_meta_box() function.
1504 *
1505 * @param mixed $id Widget ID parameter.
1506 * @param mixed $callback Callback function.
1507 * @param null $screen Current page.
1508 * @param array $layout widget layout.
1509 *
1510 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1511 */
1512 public static function add_widget_box( $id, $callback, $screen = null, $layout = array() ) {
1513 /**
1514 * MainWP widget boxes array.
1515 *
1516 * @global object
1517 */
1518 global $mainwp_widget_boxes;
1519
1520 $page = MainWP_System_Utility::get_page_id( $screen );
1521
1522 if ( empty( $page ) ) {
1523 return;
1524 }
1525
1526 if ( ! isset( $mainwp_widget_boxes ) ) {
1527 $mainwp_widget_boxes = array();
1528 }
1529 if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
1530 $mainwp_widget_boxes[ $page ] = array();
1531 }
1532
1533 $mainwp_widget_boxes[ $page ][ $id ] = array(
1534 'id' => $id,
1535 'callback' => $callback,
1536 'layout' => $layout,
1537 );
1538 }
1539
1540 /**
1541 * Method do_widget_boxes()
1542 *
1543 * Customize WordPress do_meta_boxes() function.
1544 *
1545 * @param mixed $screen_id Current page ID.
1546 * @param array ...$args Widget callback args.
1547 *
1548 * @return void Renders widget container box.
1549 *
1550 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1551 */
1552 public static function do_widget_boxes( $screen_id, ...$args ) { // phpcs:ignore -- NOSONAR - complex.
1553 global $mainwp_widget_boxes;
1554 $page = MainWP_System_Utility::get_page_id( $screen_id );
1555 if ( empty( $page ) ) {
1556 return;
1557 }
1558 $wgsorted = get_user_option( 'mainwp_widgets_sorted_' . strtolower( $page ) );
1559
1560 if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
1561 $wgsorted = json_decode( $wgsorted, true );
1562 }
1563
1564 $client_id = 0;
1565 if ( 'mainwp_page_manageclients' === $page ) {
1566 $sorted_array = is_array( $wgsorted ) ? $wgsorted : array();
1567 $wgsorted = array();
1568 $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1569 if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
1570 $wgsorted = $sorted_array[ $client_id ];
1571 }
1572 }
1573
1574 $wgsorted = apply_filters( 'mainwp_do_widget_boxes_sorted', $wgsorted, $page, $client_id );
1575
1576 if ( ! is_array( $wgsorted ) ) {
1577 $wgsorted = array();
1578 }
1579
1580 if ( 'mainwp_page_manageclients' === $page ) {
1581 $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
1582 } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1583 $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
1584 } else {
1585 $show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
1586 }
1587
1588 if ( ! is_array( $show_widgets ) ) {
1589 $show_widgets = array();
1590 }
1591
1592 if ( isset( $mainwp_widget_boxes[ $page ] ) ) {
1593 foreach ( (array) $mainwp_widget_boxes[ $page ] as $box ) {
1594 if ( false === $box || ! isset( $box['callback'] ) ) {
1595 continue;
1596 }
1597
1598 // to avoid hidden widgets.
1599 if ( isset( $show_widgets[ $box['id'] ] ) && 0 === (int) $show_widgets[ $box['id'] ] ) {
1600 continue;
1601 }
1602
1603 $layout = array();
1604 if ( isset( $wgsorted[ $box['id'] ] ) ) {
1605 $val = $wgsorted[ $box['id'] ];
1606 if ( is_array( $val ) && isset( $val['col'] ) ) {
1607 $layout = array(
1608 'col' => $val['col'],
1609 'row' => $val['row'],
1610 'size_x' => $val['size_x'],
1611 'size_y' => $val['size_y'],
1612 );
1613 }
1614 }
1615 if ( ! isset( $layout['col'] ) && isset( $box['layout'][0] ) ) {
1616 $layout = array(
1617 'col' => $box['layout'][0],
1618 'row' => $box['layout'][1],
1619 'size_x' => $box['layout'][2],
1620 'size_y' => $box['layout'][3],
1621 );
1622 }
1623 $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'] ) : '' ) . '" ';
1624 echo '<div id="widget-' . esc_html( $box['id'] ) . '" class="ui segment mainwp-widget" ' . $layout_attrs_escaped . '>' . "\n"; //phpcs:ignore -- escaped.
1625 call_user_func( $box['callback'], $screen_id, $args );
1626 echo '<span class="mainwp-resize-handle"></span>' . "\n";
1627 echo "</div>\n";
1628
1629 }
1630 }
1631 $breakpoint = apply_filters( 'mainwp_flexible_widgets_breakpoint', 1367 );
1632 ?>
1633 <script type="text/javascript">
1634 let is_mobile = false;
1635 if( jQuery( window ).width() < <?php echo intval( $breakpoint ); ?> ) {
1636 is_mobile = true;
1637 }
1638 console.log('mobile: ' + is_mobile);
1639
1640 if ( ! is_mobile ) {
1641 let page_sortablewidgets = '<?php echo esc_js( $page ); ?>';
1642 jQuery( document ).ready( function( $ ) {
1643 let wgIds = [];
1644 jQuery( ".mainwp-widget" ).each( function () {
1645 wgIds.push( jQuery( this ).attr('id') );
1646 } );
1647
1648 let $mainwp_gridster = jQuery( '.gridster' ).gridster( {
1649 auto_init: true,
1650 autogenerate_stylesheet: true,
1651 shift_larger_widgets_down: false,
1652 shift_widgets_up: true,
1653 widget_selector: "div.mainwp-widget",
1654 widget_margins: [20, 20],
1655 widget_base_dimensions: ["auto", 20],
1656 min_cols: 1,
1657 max_cols: 12,
1658 max_size_x: 12,
1659 max_rows: 500,
1660 avoid_overlapped_widgets: true,
1661 collision: {
1662 wait_for_mouseup: true
1663 },
1664 draggable: {
1665 handle: '.handle-drag',
1666 stop: function (e, ui, $widget) {
1667 mainwp_overview_gridster_reorder(this);
1668 }
1669 },
1670 resize: {
1671 enabled: true,
1672 handle_append_to: ".mainwp-resize-handle",
1673 stop: function (e, ui, $widget) {
1674 mainwp_overview_gridster_reorder(this);
1675 }
1676 }
1677 } ).data('gridster');
1678
1679 mainwp_overview_gridster_reorder = function( $gridObj ){
1680 let orders = $gridObj.serialize();
1681 let postVars = {
1682 action:'mainwp_widgets_order',
1683 page: page_sortablewidgets,
1684 order:JSON.stringify(orders),
1685 wgids: JSON.stringify(wgIds),
1686 item_id: <?php echo intval( $client_id ); ?>
1687 };
1688 jQuery.post( ajaxurl, mainwp_secure_data( postVars ), function ( res ) {
1689 } );
1690 }
1691 });
1692
1693 }
1694 </script>
1695 <?php
1696 }
1697
1698 /**
1699 * Method render_empty_bulk_actions()
1700 *
1701 * Render empty bulk actions when drop down is disabled.
1702 */
1703 public static function render_empty_bulk_actions() {
1704 ?>
1705 <select class="ui disabled dropdown" id="mainwp-bulk-actions">
1706 <option value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
1707 </select>
1708 <button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
1709 <?php
1710 }
1711
1712 /**
1713 * Method render_modal_install_plugin_theme()
1714 *
1715 * Render modal window for installing plugins & themes.
1716 *
1717 * @param string $what Which window to render, plugin|theme.
1718 */
1719 public static function render_modal_install_plugin_theme( $what = 'plugin' ) {
1720 ?>
1721 <div id="plugintheme-installation-progress-modal" class="ui modal">
1722 <i class="close icon"></i>
1723 <div class="header">
1724 <?php
1725 if ( 'plugin' === $what ) {
1726 esc_html_e( 'Plugin Installation', 'mainwp' );
1727 } elseif ( 'theme' === $what ) {
1728 esc_html_e( 'Theme Installation', 'mainwp' );
1729 }
1730 ?>
1731 </div>
1732 <div class="ui green progress mainwp-modal-progress">
1733 <div class="bar"><div class="progress"></div></div>
1734 <div class="label"></div>
1735 </div>
1736 <div class="scrolling content">
1737 <?php
1738 /**
1739 * Action: mainwp_before_plugin_theme_install_progress
1740 *
1741 * Fires before the progress list in the install modal element.
1742 *
1743 * @since 4.1
1744 */
1745 do_action( 'mainwp_before_plugin_theme_install_progress' );
1746 ?>
1747 <div id="plugintheme-installation-queue"></div>
1748 <?php
1749 /**
1750 * Action: mainwp_after_plugin_theme_install_progress
1751 *
1752 * Fires after the progress list in the install modal element.
1753 *
1754 * @since 4.1
1755 */
1756 do_action( 'mainwp_after_plugin_theme_install_progress' );
1757 ?>
1758 </div>
1759 <div class="actions" item-type="<?php echo esc_attr( $what ); ?>">
1760 <?php
1761 /**
1762 * Action: mainwp_after_plugin_theme_install_progress
1763 *
1764 * Fires after the progress list in the install modal element.
1765 *
1766 * @since 4.1
1767 */
1768 do_action( 'mainwp_install_plugin_theme_modal_action', $what );
1769 ?>
1770 <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1771 </div>
1772 </div>
1773 <?php
1774 }
1775
1776 /**
1777 * Method render_modal_upload_icon()
1778 *
1779 * Render modal window for upload plugins & themes icon.
1780 */
1781 public static function render_modal_upload_icon() {
1782
1783 ?>
1784 <div id="mainwp-upload-custom-icon-modal" class="ui modal">
1785 <i class="close icon"></i>
1786 <div class="header">
1787 <?php
1788 esc_html_e( 'Upload Icon', 'mainwp' );
1789 ?>
1790 </div>
1791 <div class="content" id="mainwp-upload-custom-icon-content">
1792 <form action="" method="post" enctype="multipart/form-data" name="uploadicon_form" id="uploadicon_form" class="">
1793 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1794 <div class="ui message" id="mainwp-message-zone-upload" style="display:none;"></div>
1795 <?php
1796 /**
1797 * Action: mainwp_after_upload_custom_icon
1798 *
1799 * Fires before the modal element.
1800 *
1801 * @since 4.3
1802 */
1803 do_action( 'mainwp_before_upload_custom_icon' );
1804 ?>
1805 <div class="ui form">
1806 <div class="ui grid field">
1807 <label class="six wide column middle aligned"><?php esc_html_e( 'Custom icon', 'mainwp' ); ?></label>
1808 <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1809 <div class="ui file input">
1810 <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' ); ?>" />
1811 </div>
1812 </div>
1813 </div>
1814 <div class="ui grid field" id="mainwp_delete_image_field">
1815 <label class="six wide column middle aligned"></label>
1816 <div class="six wide column">
1817 <img class="ui tiny image" src="" alt="<?php esc_attr_e( 'Icon to remove.', 'mainwp' ); ?>"/><br/>
1818 <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, delete image.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1819 <input type="checkbox"id="mainwp_delete_image_chk" item-icon-id="" />
1820 <label for="mainwp_delete_image_chk"><?php esc_html_e( 'Delete Image', 'mainwp' ); ?></label>
1821 </div>
1822 </div>
1823 </div>
1824 </div>
1825 <?php
1826 /**
1827 * Action: mainwp_after_upload_custom_icon
1828 *
1829 * Fires after the modal element.
1830 *
1831 * @since 4.3
1832 */
1833 do_action( 'mainwp_after_upload_custom_icon' );
1834 ?>
1835 </form>
1836 </div>
1837 <div class="actions">
1838 <div class="ui green button" uploading-icon="default" id="update_custom_icon_btn"><?php esc_html_e( 'Update', 'mainwp' ); ?></div>
1839 </div>
1840 </div>
1841 <?php
1842 }
1843
1844 /**
1845 * Method render_show_all_updates_button()
1846 *
1847 * Render show all updates button.
1848 *
1849 * @return void Render Show All Updates button html.
1850 */
1851 public static function render_show_all_updates_button() {
1852 ?>
1853 <a href="javascript:void(0)" class="ui mini button trigger-all-accordion">
1854 <?php
1855 /**
1856 * Filter: mainwp_show_all_updates_button_text
1857 *
1858 * Filters the Show All Updates button text.
1859 *
1860 * @since 4.1
1861 */
1862 echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', esc_html__( 'Show All Updates', 'mainwp' ) ) );
1863 ?>
1864 </a>
1865 <?php
1866 }
1867
1868 /**
1869 * Method render_sorting_icons()
1870 *
1871 * Render sorting up & down icons.
1872 *
1873 * @return void Render Sort up & down incon html.
1874 */
1875 public static function render_sorting_icons() {
1876 ?>
1877 <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"></i>
1878 <?php
1879 }
1880
1881 /**
1882 * Method render_modal_edit_notes()
1883 *
1884 * Render modal window for edit notes.
1885 *
1886 * @param string $what What modal window to render. Default = site.
1887 *
1888 * @return void
1889 */
1890 public static function render_modal_edit_notes( $what = 'site' ) {
1891 ?>
1892 <div id="mainwp-notes-modal" class="ui modal">
1893 <div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div>
1894 <div class="content" id="mainwp-notes-content">
1895 <div id="mainwp-notes-status" class="ui message hidden"></div>
1896 <?php
1897 /**
1898 * Action: mainwp_before_edit_site_note
1899 *
1900 * Fires before the site note content in the Edit Note modal element.
1901 *
1902 * @since 4.1
1903 */
1904 do_action( 'mainwp_before_edit_site_note' );
1905 ?>
1906 <div id="mainwp-notes-html"></div>
1907 <div id="mainwp-notes-editor" class="ui form" style="display:none;">
1908 <div class="field">
1909 <label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label>
1910 <textarea id="mainwp-notes-note"></textarea>
1911 </div>
1912 <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>
1913 </div>
1914 <?php
1915 /**
1916 * Action: mainwp_after_edit_site_note
1917 *
1918 * Fires after the site note content in the Edit Note modal element.
1919 *
1920 * @since 4.1
1921 */
1922 do_action( 'mainwp_after_edit_site_note' );
1923 ?>
1924 </div>
1925 <div class="actions">
1926 <div class="ui grid">
1927 <div class="eight wide left aligned middle aligned column">
1928 <input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save Note', 'mainwp' ); ?>" style="display:none;"/>
1929 <input type="button" class="ui green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit Note', 'mainwp' ); ?>"/>
1930 </div>
1931 <div class="eight wide column">
1932 <input type="button" class="ui button" id="mainwp-notes-cancel" value="<?php esc_attr_e( 'Close', 'mainwp' ); ?>"/>
1933 <input type="hidden" id="mainwp-notes-websiteid" value=""/>
1934 <input type="hidden" id="mainwp-notes-slug" value=""/>
1935 <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
1936 <input type="hidden" id="mainwp-notes-itemid" value=""/>
1937 </div>
1938 </div>
1939 </div>
1940 </div>
1941 <?php
1942 }
1943
1944 /**
1945 * No Sites Modal
1946 *
1947 * Renders modal window for notification when there are no connected sites.
1948 *
1949 * @return void
1950 */
1951 public static function render_modal_no_sites_note() {
1952 if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-no-sites-modal-notice' ) ) :
1953 ?>
1954 <div id="mainwp-no-sites-modal" class="ui small modal">
1955 <div class="content" id="mainwp-no-sites-modal-content" style="text-align:center">
1956 <div class="ui hidden divider"></div>
1957 <div class="ui hidden divider"></div>
1958 <h4><?php esc_html_e( 'Hi MainWP Manager, there is not anything to see here before connecting your first site.', 'mainwp' ); ?></h4>
1959 <div class="ui hidden divider"></div>
1960 <div class="ui hidden divider"></div>
1961 <a href="admin.php?page=managesites&do=new" class="ui big green button"><?php esc_html_e( 'Connect Your WordPress Site', 'mainwp' ); ?></a>
1962 <div class="ui hidden fitted divider"></div>
1963 <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>
1964 </div>
1965 <div class="actions">
1966 <div class="ui grid">
1967 <div class="eight wide left aligned middle aligned column">
1968 <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>
1969 </div>
1970 <div class="eight wide column">
1971 <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' ); ?>"/>
1972 </div>
1973 </div>
1974 </div>
1975 </div>
1976 <script type="text/javascript">
1977 jQuery( '#mainwp-no-sites-modal' ).modal( {
1978 blurring: true,
1979 inverted: true,
1980 closable: false
1981 } ).modal( 'show' );
1982 </script>
1983 <?php
1984 endif;
1985 }
1986
1987 /**
1988 * Method render_screen_options()
1989 *
1990 * Render modal window for Page Settings.
1991 *
1992 * @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Overview page.
1993 *
1994 * @return void Render modal window for Page Settings html.
1995 */
1996 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.
1997
1998 $default_widgets = array(
1999 'overview' => esc_html__( 'Updates Overview', 'mainwp' ),
2000 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
2001 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
2002 'plugins' => esc_html__( 'Plugins (Individual Site Overview page)', 'mainwp' ),
2003 'themes' => esc_html__( 'Themes (Individual Site Overview page)', 'mainwp' ),
2004 'connection_status' => esc_html__( 'Connection Status', 'mainwp' ),
2005 'security_issues' => esc_html__( 'Security Issues', 'mainwp' ),
2006 'notes' => esc_html__( 'Notes (Individual Site Overview page)', 'mainwp' ),
2007 'clients' => esc_html__( 'Clients', 'mainwp' ),
2008 'child_site_info' => esc_html__( 'Child site info (Individual Site Overview page)', 'mainwp' ),
2009 'client_info' => esc_html__( 'Client info (Individual Site Overview page)', 'mainwp' ),
2010 'non_mainwp_changes' => esc_html__( 'Non-MainWP Changes', 'mainwp' ),
2011 'get-started' => esc_html__( 'Get Started with MainWP', 'mainwp' ),
2012 );
2013
2014 $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.
2015
2016 /**
2017 * Filter: mainwp_widgets_screen_options
2018 *
2019 * Filters available widgets on the Overview page allowing users to unsent unwanted widgets.
2020 *
2021 * @since 4.0
2022 */
2023 $custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts );
2024
2025 if ( is_array( $custom_opts ) && ! empty( $custom_opts ) ) {
2026 $default_widgets = array_merge( $default_widgets, $custom_opts );
2027 }
2028
2029 $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
2030
2031 if ( ! is_array( $show_widgets ) ) {
2032 $show_widgets = array();
2033 }
2034
2035 $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
2036 $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
2037 $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
2038
2039 /**
2040 * Action: mainwp_screen_options_modal_top
2041 *
2042 * Fires at the top of the Page Settings modal element.
2043 *
2044 * @since 4.1
2045 */
2046 do_action( 'mainwp_screen_options_modal_top' );
2047 $which_settings = 'overview_settings';
2048 ?>
2049 <?php if ( ! $setting_page ) : ?>
2050 <?php if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2051 <?php
2052 $which_settings = 'sidebar_settings';
2053 $sidebarPosition = (int) get_user_option( 'mainwp_sidebarPosition', 1 );
2054 $manageGroupsPage = false;
2055 if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2056 $manageGroupsPage = true;
2057 }
2058 ?>
2059 <div class="ui grid field">
2060 <label tabindex="0" class="six wide column middle aligned"><?php echo $manageGroupsPage ? esc_html__( 'Tags menu position', 'mainwp' ) : esc_html__( 'Sidebar position', 'mainwp' ); ?></label>
2061 <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">
2062 <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
2063 <option value="1" <?php echo 1 === $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Right', 'mainwp' ); ?></option>
2064 <option value="0" <?php echo 0 === $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
2065 </select>
2066 </div>
2067 </div>
2068 <?php endif; ?>
2069 <?php endif; ?>
2070 <?php
2071 if ( isset( $_GET['page'] ) && ! in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2072 $hide_up_everything = (int) get_option( 'mainwp_hide_update_everything' );
2073 ?>
2074 <div class="ui grid field settings-field-indicator-wrapper">
2075 <label class="six wide column middle aligned">
2076 <?php
2077 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_hide_update_everything', $hide_up_everything );
2078 esc_html_e( 'Hide the Update Everything button', 'mainwp' );
2079 ?>
2080 </label>
2081 <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">
2082 <input type="checkbox" class="settings-field-value-change-handler" name="hide_update_everything" <?php echo 1 === $hide_up_everything ? 'checked="true"' : ''; ?> />
2083 </div>
2084 </div>
2085 <?php
2086 $indi_val = 'all';
2087 foreach ( $default_widgets as $name => $title ) {
2088 if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
2089 continue;
2090 }
2091 $indi_val = '';
2092 }
2093 ?>
2094 <div class="ui grid field settings-field-indicator-wrapper" default-indi-value="all">
2095 <label class="six wide column">
2096 <?php
2097 if ( $setting_page ) {
2098 MainWP_Settings_Indicator::render_not_default_indicator( 'show_default_widgets', $indi_val );
2099 }
2100 esc_html_e( 'Show widgets', 'mainwp' );
2101 ?>
2102 </label>
2103 <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">
2104 <ul class="mainwp_hide_wpmenu_checkboxes">
2105 <?php
2106 foreach ( $default_widgets as $name => $title ) {
2107 $_selected = '';
2108 if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
2109 $_selected = 'checked';
2110 }
2111 ?>
2112 <li>
2113 <div class="ui checkbox">
2114 <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 ); ?>">
2115 <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
2116 </div>
2117 <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
2118 </li>
2119 <?php
2120 }
2121 ?>
2122 </ul>
2123 </div>
2124 </div>
2125 <?php
2126 endif;
2127 ?>
2128 <input type="hidden" name="reset_overview_which_settings" value="<?php echo esc_html( $which_settings ); ?>" />
2129 <?php
2130 /**
2131 * Action: mainwp_screen_options_modal_bottom
2132 *
2133 * Fires at the bottom of the Page Settings modal element.
2134 *
2135 * @since 4.1
2136 */
2137 do_action( 'mainwp_screen_options_modal_bottom' );
2138 }
2139
2140 /**
2141 * Method render_select_mainwp_themes_modal()
2142 *
2143 * Render modal window for mainwp themes selection.
2144 *
2145 * @return void Render modal window for themes selection.
2146 */
2147 public static function render_select_mainwp_themes_modal() {
2148 ?>
2149 <div class="ui modal" id="mainwp-select-mainwp-themes-modal">
2150 <i class="close icon"></i>
2151 <div class="header"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></div>
2152 <div class="content ui form">
2153 <div class="ui blue message">
2154 <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>
2155 </div>
2156 <form method="POST" action="" name="mainwp_select_mainwp_themes_form" id="mainwp_select_mainwp_themes_form">
2157 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2158 <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPSelectThemes' ) ); ?>" />
2159 <?php
2160 /**
2161 * Action: mainwp_select_themes_modal_top
2162 *
2163 * Fires at the top of the modal.
2164 *
2165 * @since 4.3
2166 */
2167 do_action( 'mainwp_select_themes_modal_top' );
2168
2169 MainWP_Settings::get_instance()->render_select_custom_themes();
2170
2171 /**
2172 * Action: mainwp_select_themes_modal_bottom
2173 *
2174 * Fires at the bottom of the modal.
2175 *
2176 * @since 4.3
2177 */
2178 do_action( 'mainwp_select_themes_modal_bottom' );
2179 ?>
2180 </div>
2181 <div class="actions">
2182 <div class="ui two columns grid">
2183 <div class="left aligned column">
2184
2185 </div>
2186 <div class="ui right aligned column">
2187 <input type="submit" class="ui green button" id="submit-select-mainwp-themes" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2188 </div>
2189 </div>
2190 </div>
2191 </form>
2192 </div>
2193 <?php
2194 }
2195
2196 /**
2197 * Method render_install_extensions_promo_modal()
2198 */
2199 public static function render_install_extensions_promo_modal() {
2200 $mainwp_api_key = MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key();
2201 ?>
2202 <div class="ui small modal" id="mainwp-install-extensions-promo-modal">
2203 <i class="close icon"></i>
2204 <?php if ( empty( $mainwp_api_key ) ) : ?>
2205 <div class="header"><?php esc_html_e( 'Get MainWP Pro', 'mainwp' ); ?></div>
2206 <div class="content">
2207 <div class="ui header"><?php esc_html_e( 'With your MainWP Pro subscription, you get access to:', 'mainwp' ); ?></div>
2208 <div class="ui bulleted list">
2209 <div class="item"><?php esc_html_e( 'All 30+ Existing Premium Extensions', 'mainwp' ); ?></div>
2210 <div class="item"><?php esc_html_e( 'All Future Extensions', 'mainwp' ); ?></div>
2211 <div class="item"><?php esc_html_e( 'Critical Security & Performance Updates', 'mainwp' ); ?></div>
2212 <div class="item"><?php esc_html_e( 'Priority Support with Subscription', 'mainwp' ); ?></div>
2213 <div class="item"><?php esc_html_e( 'Manage Unlimited Websites', 'mainwp' ); ?></div>
2214 </div>
2215 <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. ?>
2216 </div>
2217 <?php else : ?>
2218 <div class="header"><?php esc_html_e( 'Install Extensions', 'mainwp' ); ?></div>
2219 <div class="content">
2220 <div class="ui header"><?php esc_html_e( 'Extension not activated', 'mainwp' ); ?></div>
2221 <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>
2222 </div>
2223 <?php endif; ?>
2224 </div>
2225 <?php
2226 }
2227
2228 /**
2229 * Method render_empty_element_placeholder()
2230 *
2231 * Renders the content for empty elements.
2232 *
2233 * @param string $placeholder Placelolder text.
2234 */
2235 public static function render_empty_element_placeholder( $placeholder = '' ) {
2236 ?>
2237 <div class="ui one column grid">
2238 <div class="middle aligned center aligned column">
2239 <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"/>
2240 <?php if ( '' !== $placeholder ) : ?>
2241 <p><?php echo $placeholder; //phpcs:ignore -- requires escaped. ?></p>
2242 <?php else : ?>
2243 <p><?php echo esc_html__( 'Nothing to show here, check back later!', 'mainwp' ); ?></p>
2244 <?php endif; ?>
2245 </div>
2246 </div>
2247 <?php
2248 }
2249
2250 /**
2251 * Method render_modal_save_segment()
2252 *
2253 * Render modal window.
2254 *
2255 * @return void
2256 */
2257 public static function render_modal_save_segment() {
2258 ?>
2259 <div id="mainwp-common-filter-segment-modal" class="ui tiny modal">
2260 <i class="close icon" id="mainwp-common-filter-segment-cancel"></i>
2261 <div class="header"><?php esc_html_e( 'Save Segment', 'mainwp' ); ?></div>
2262 <div class="content" id="mainwp-common-filter-segment-content">
2263 <div id="mainwp-common-filter-edit-segment-status" class="ui message hidden"></div>
2264 <div id="mainwp-common-filter-segment-edit-fields" class="ui form">
2265 <div class="field">
2266 <label><?php esc_html_e( 'Enter the segment name', 'mainwp' ); ?></label>
2267 </div>
2268 <div class="field">
2269 <input type="text" id="mainwp-common-filter-edit-segment-name" value=""/>
2270 </div>
2271 </div>
2272 <div id="mainwp-common-filter-segment-select-fields" style="display:none;">
2273 <div class="field">
2274 <label><?php esc_html_e( 'Select a segment', 'mainwp' ); ?></label>
2275 </div>
2276 <div class="field">
2277 <div id="mainwp-common-filter-segments-lists-wrapper"></div>
2278 </div>
2279 </div>
2280 </div>
2281 <div class="actions">
2282 <div class="ui grid">
2283 <div class="eight wide left aligned middle aligned column">
2284 <input type="button" class="ui green button" id="mainwp-common-filter-edit-segment-save" value="<?php esc_attr_e( 'Save', 'mainwp' ); ?>"/>
2285 <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;"/>
2286 <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;"/>
2287 </div>
2288 <div class="eight wide column">
2289
2290 </div>
2291 </div>
2292 </div>
2293 </div>
2294
2295 <?php
2296 }
2297
2298
2299 /**
2300 * Method get_default_icons().
2301 *
2302 * @return array icons.
2303 */
2304 public static function get_default_icons() { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR - compatible phpcs's line breaks.
2305 return array(
2306 'wordpress', //phpcs:ignore -- WP icon.
2307 'ambulance',
2308 'anchor',
2309 'archive',
2310 'award',
2311 'baby carriage',
2312 'balance scale',
2313 'balance scale left',
2314 'balance scale right',
2315 'bath',
2316 'bed',
2317 'beer',
2318 'bell',
2319 'bell outline',
2320 'bicycle',
2321 'binoculars',
2322 'birthday cake',
2323 'blender',
2324 'bomb',
2325 'book',
2326 'book dead',
2327 'bookmark',
2328 'bookmark outline',
2329 'briefcase',
2330 'broadcast tower',
2331 'bug',
2332 'building',
2333 'building outline',
2334 'bullhorn',
2335 'bullseye',
2336 'bus',
2337 'calculator',
2338 'calendar',
2339 'calendar alternate',
2340 'calendar alternate outline',
2341 'calendar outline',
2342 'camera',
2343 'camera retro',
2344 'candy cane',
2345 'car',
2346 'carrot',
2347 'church',
2348 'clipboard',
2349 'clipboard outline',
2350 'cloud',
2351 'coffee',
2352 'cog',
2353 'cogs',
2354 'compass',
2355 'compass outline',
2356 'cookie',
2357 'cookie bite',
2358 'copy',
2359 'copy outline',
2360 'cube',
2361 'cubes',
2362 'cut',
2363 'dice',
2364 'dice d20',
2365 'dice d6',
2366 'dice five',
2367 'dice four',
2368 'dice one',
2369 'dice six',
2370 'dice three',
2371 'dice two',
2372 'digital tachograph',
2373 'door closed',
2374 'door open',
2375 'drum',
2376 'drum steelpan',
2377 'envelope',
2378 'envelope open',
2379 'envelope open outline',
2380 'envelope outline',
2381 'eraser',
2382 'eye',
2383 'eye dropper',
2384 'eye outline',
2385 'fax',
2386 'feather',
2387 'feather alternate',
2388 'fighter jet',
2389 'file',
2390 'file alternate',
2391 'file alternate outline',
2392 'file outline',
2393 'file prescription',
2394 'film',
2395 'fire',
2396 'fire alternate',
2397 'fire extinguisher',
2398 'flag',
2399 'flag checkered',
2400 'flag outline',
2401 'flask',
2402 'futbol',
2403 'futbol outline',
2404 'gamepad',
2405 'gavel',
2406 'gem',
2407 'gem outline',
2408 'gift',
2409 'gifts',
2410 'glass cheers',
2411 'glass martini',
2412 'glass whiskey',
2413 'glasses',
2414 'globe',
2415 'graduation cap',
2416 'guitar',
2417 'hat wizard',
2418 'hdd',
2419 'hdd outline',
2420 'headphones',
2421 'headphones alternate',
2422 'headset',
2423 'heart',
2424 'heart broken',
2425 'heart outline',
2426 'helicopter',
2427 'highlighter',
2428 'holly berry',
2429 'home',
2430 'hospital',
2431 'hospital outline',
2432 'hourglass',
2433 'hourglass outline',
2434 'igloo',
2435 'image',
2436 'image outline',
2437 'images',
2438 'images outline',
2439 'industry',
2440 'key',
2441 'keyboard',
2442 'keyboard outline',
2443 'laptop',
2444 'leaf',
2445 'lemon',
2446 'lemon outline',
2447 'life ring',
2448 'life ring outline',
2449 'lightbulb',
2450 'lightbulb outline',
2451 'lock',
2452 'lock open',
2453 'magic',
2454 'magnet',
2455 'map',
2456 'map marker',
2457 'map marker alternate',
2458 'map outline',
2459 'map pin',
2460 'map signs',
2461 'marker',
2462 'medal',
2463 'medkit',
2464 'memory',
2465 'microchip',
2466 'microphone',
2467 'microphone alternate',
2468 'mitten',
2469 'mobile',
2470 'mobile alternate',
2471 'money bill',
2472 'money bill alternate',
2473 'money bill alternate outline',
2474 'money check',
2475 'money check alternate',
2476 'moon',
2477 'moon outline',
2478 'motorcycle',
2479 'mug hot',
2480 'newspaper',
2481 'newspaper outline',
2482 'paint brush',
2483 'paper plane',
2484 'paper plane outline',
2485 'paperclip',
2486 'paste',
2487 'paw',
2488 'pen',
2489 'pen alternate',
2490 'pen fancy',
2491 'pen nib',
2492 'pencil alternate',
2493 'phone',
2494 'phone alternate',
2495 'plane',
2496 'plug',
2497 'print',
2498 'puzzle piece',
2499 'ring',
2500 'road',
2501 'rocket',
2502 'ruler combined',
2503 'ruler horizontal',
2504 'ruler vertical',
2505 'satellite',
2506 'satellite dish',
2507 'save',
2508 'save outline',
2509 'school',
2510 'screwdriver',
2511 'scroll',
2512 'sd card',
2513 'search',
2514 'shield alternate',
2515 'shopping bag',
2516 'shopping basket',
2517 'shopping cart',
2518 'shower',
2519 'sim card',
2520 'skull crossbones',
2521 'sleigh',
2522 'snowflake',
2523 'snowflake outline',
2524 'snowplow',
2525 'space shuttle',
2526 'star',
2527 'star outline',
2528 'sticky note',
2529 'sticky note outline',
2530 'stopwatch',
2531 'stroopwafel',
2532 'subway',
2533 'suitcase',
2534 'sun',
2535 'sun outline',
2536 'tablet',
2537 'tablet alternate',
2538 'tachometer alternate',
2539 'tag',
2540 'tags',
2541 'taxi',
2542 'thumbtack',
2543 'ticket alternate',
2544 'toilet',
2545 'toolbox',
2546 'tools',
2547 'train',
2548 'tram',
2549 'trash',
2550 'trash alternate',
2551 'trash alternate outline',
2552 'tree',
2553 'trophy',
2554 'truck',
2555 'tv',
2556 'umbrella',
2557 'university',
2558 'unlock',
2559 'unlock alternate',
2560 'utensil spoon',
2561 'utensils',
2562 'wallet',
2563 'weight',
2564 'wheelchair',
2565 'wine glass',
2566 'wrench',
2567 'folder',
2568 'folder open',
2569 'palette',
2570 'server',
2571 'tint',
2572 );
2573 }
2574 }
2575