PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | class/class-mainwp-ui.php +3482 -2099 5.0 → 6.2.2 View file →
@@ -6,2234 +6,3617 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_UI
12 17 *
13 18 * @package MainWP\Dashboard
14 19 */
15 -class MainWP_UI {
20 +class MainWP_UI { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16 21
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 - }
22 + /**
23 + * Method get_class_name()
24 + *
25 + * Get Class Name.
26 + *
27 + * @return object
28 + */
29 + public static function get_class_name() {
30 + return __CLASS__;
31 + }
27 32
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 ) {
33 + /**
34 + * Normalize a site URL before building an mShots request.
35 + *
36 + * @param string $url Child site URL.
37 + *
38 + * @return string Normalized site URL.
39 + */
40 + public static function get_normalized_mshots_target_url( $url ) {
41 + if ( ! is_string( $url ) ) {
42 + return '';
43 + }
48 44
49 - if ( $postId ) {
45 + return esc_url_raw( trim( $url ) );
46 + }
50 47
51 - $sites_val = get_post_meta( $postId, '_selected_sites', true );
52 - $selected_websites = MainWP_System_Utility::maybe_unserialyze( $sites_val );
48 + /**
49 + * Build an mShots image URL for a site.
50 + *
51 + * @param string $url Child site URL.
52 + * @param int $width Requested thumbnail width.
53 + * @param bool $requeue Whether to force a requeue request.
54 + *
55 + * @return string mShots URL.
56 + */
57 + public static function get_mshots_image_url( $url, $width = 0, $requeue = false ) {
58 + $site_url = static::get_normalized_mshots_target_url( $url );
53 59
54 - if ( empty( $selected_websites ) ) {
55 - $selected_websites = array();
56 - }
60 + if ( empty( $site_url ) ) {
61 + return '';
62 + }
57 63
58 - $groups_val = get_post_meta( $postId, '_selected_groups', true );
59 - $selected_groups = MainWP_System_Utility::maybe_unserialyze( $groups_val );
64 + $mshots_url = '//s0.wp.com/mshots/v1/' . rawurlencode( $site_url );
65 + $query_args = array();
66 + $width = intval( $width );
60 67
61 - if ( empty( $selected_groups ) ) {
62 - $selected_groups = array();
63 - }
64 - }
68 + if ( 0 < $width ) {
69 + $query_args['w'] = $width;
70 + }
65 71
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 - }
72 + if ( $requeue ) {
73 + $query_args['requeue'] = 'true';
74 + }
71 75
72 - /**
73 - * Action: mainwp_before_seclect_sites
74 - *
75 - * Fires before the Select Sites box.
76 - *
77 - * @since 4.1
78 - */
79 - do_action( 'mainwp_before_seclect_sites' );
80 - ?>
81 - <div id="mainwp-select-sites" class="mainwp_select_sites_wrapper">
82 - <?php self::select_sites_box_body( $selected_websites, $selected_groups, $type, $show_group, $show_select_all, false, $enableOfflineSites, $postId ); ?>
83 - </div>
84 - <?php
85 - /**
86 - * Action: mainwp_after_seclect_sites
87 - *
88 - * Fires after the Select Sites box.
89 - *
90 - * @since 4.1
91 - */
92 - do_action( 'mainwp_after_seclect_sites' );
93 - }
76 + if ( ! empty( $query_args ) ) {
77 + $mshots_url .= '?' . http_build_query( $query_args, '', '&', PHP_QUERY_RFC3986 );
78 + }
94 79
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 ) {
80 + return $mshots_url;
81 + }
115 82
116 - if ( 'all' !== $selected_websites && ! is_array( $selected_websites ) ) {
117 - $selected_websites = array();
118 - }
83 + /**
84 + * Build the primary and requeue mShots URLs for a site.
85 + *
86 + * @param string $url Child site URL.
87 + * @param int $width Requested thumbnail width.
88 + *
89 + * @return array mShots source URLs.
90 + */
91 + public static function get_mshots_image_sources( $url, $width = 0 ) {
92 + return array(
93 + 'src' => static::get_mshots_image_url( $url, $width ),
94 + 'requeue_src' => static::get_mshots_image_url( $url, $width, true ),
95 + );
96 + }
119 97
120 - if ( ! is_array( $selected_groups ) ) {
121 - $selected_groups = array();
122 - }
98 + /**
99 + * Method select_sites_box()
100 + *
101 + * Select sites box.
102 + *
103 + * @deprecated 4.3 Use MainWP_UI_Select_Sites::select_sites_box().
104 + *
105 + * @param string $type Input type, radio.
106 + * @param bool $show_group Whether or not to show group, Default: true.
107 + * @param bool $show_select_all Whether to show select all.
108 + * @param string $class_style Default = ''.
109 + * @param string $style Default = ''.
110 + * @param array $selected_websites Selected Child Sites.
111 + * @param array $selected_groups Selected Groups.
112 + * @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not.
113 + * @param integer $postId Post Meta ID.
114 + *
115 + * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze()
116 + */
117 + 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.
123 118
124 - $selectedby = 'site';
125 - if ( ! empty( $selected_groups ) ) {
126 - $selectedby = 'group';
127 - }
119 + if ( $postId ) {
128 120
129 - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
130 - $groups = MainWP_DB_Common::instance()->get_not_empty_groups( null, $enableOfflineSites );
121 + $sites_val = get_post_meta( $postId, '_selected_sites', true );
122 + $selected_websites = MainWP_System_Utility::maybe_unserialyze( $sites_val );
131 123
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' );
124 + if ( empty( $selected_websites ) ) {
125 + $selected_websites = array();
126 + }
134 127
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 - }
128 + $groups_val = get_post_meta( $postId, '_selected_groups', true );
129 + $selected_groups = MainWP_System_Utility::maybe_unserialyze( $groups_val );
140 130
141 - if ( $edit_site_id ) {
142 - $show_group = false;
143 - }
144 - // to fix layout with multi sites selector.
145 - $tab_id = wp_rand();
131 + if ( empty( $selected_groups ) ) {
132 + $selected_groups = array();
133 + }
134 + }
146 135
147 - self::render_select_sites_header( $tab_id, $staging_enabled, $selectedby, $show_group );
148 - ?>
149 - <div class="ui tab <?php echo 'site' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-sites-<?php echo esc_attr( $tab_id ); ?>" id="mainwp-select-sites">
150 - <?php
151 - self::render_select_sites( $websites, $type, $selected_websites, $enableOfflineSites, $edit_site_id, $show_select_all );
152 - ?>
153 - </div>
154 - <?php if ( $staging_enabled ) { ?>
155 - <div class="ui tab <?php echo 'staging' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-staging-sites-<?php echo esc_attr( $tab_id ); ?>">
156 - <?php
157 - self::render_select_sites_staging( $selected_websites, $edit_site_id, $type );
158 - ?>
159 - </div>
160 - <?php
161 - }
162 - if ( $show_group ) {
163 - ?>
164 - <div class="ui tab <?php echo 'group' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-groups-<?php echo esc_attr( $tab_id ); ?>" id="mainwp-select-groups">
165 - <?php
166 - self::render_select_sites_group( $groups, $selected_groups, $type );
167 - ?>
168 - </div>
169 - <?php
170 - }
171 - ?>
172 - <script type="text/javascript">
173 - jQuery( function () {
174 - jQuery('#mainwp-select-sites-header .ui.menu .item').tab( {'onVisible': function() { mainwp_sites_selection_onvisible_callback( this ); } } );
175 - } );
176 - </script>
177 - <?php
178 - }
136 + if ( empty( $selected_websites ) && isset( $_GET['selected_sites'] ) && ! empty( $_GET['selected_sites'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
137 + $selected_sites = explode( '-', sanitize_text_field( wp_unslash( $_GET['selected_sites'] ) ) );// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
138 + $selected_sites = array_map( 'intval', $selected_sites );
139 + $selected_websites = array_filter( $selected_sites );
140 + }
179 141
180 - /**
181 - * Method render_select_sites_header()
182 - *
183 - * Render selected sites header.
184 - *
185 - * @param int $tab_id Datatab ID.
186 - * @param bool $staging_enabled True, if in the active plugins list. False, not in the list.
187 - * @param array $selectedby Selected by.
188 - * @param bool $show_group Whether or not to show group, Default: true.
189 - * @param bool $show_client Whether or not to show client, Default: true.
190 - *
191 - * @todo Move to view folder.
192 - */
193 - public static function render_select_sites_header( $tab_id, $staging_enabled, $selectedby, $show_group = true, $show_client = false ) {
142 + /**
143 + * Action: mainwp_before_seclect_sites
144 + *
145 + * Fires before the Select Sites box.
146 + *
147 + * @since 4.1
148 + */
149 + do_action( 'mainwp_before_seclect_sites' );
150 + ?>
151 + <div id="mainwp-select-sites" class="mainwp_select_sites_wrapper">
152 + <?php static::select_sites_box_body( $selected_websites, $selected_groups, $type, $show_group, $show_select_all, false, $enableOfflineSites, $postId ); ?>
153 + </div>
154 + <?php
155 + /**
156 + * Action: mainwp_after_seclect_sites
157 + *
158 + * Fires after the Select Sites box.
159 + *
160 + * @since 4.1
161 + */
162 + do_action( 'mainwp_after_seclect_sites' );
163 + }
194 164
195 - /**
196 - * Action: mainwp_before_select_sites_filters
197 - *
198 - * Fires before the Select Sites box filters.
199 - *
200 - * @since 4.1
201 - */
202 - do_action( 'mainwp_before_select_sites_filters' );
203 - ?>
204 - <div id="mainwp-select-sites-filters">
205 - <div class="ui mini fluid icon input">
206 - <input type="text" id="mainwp-select-sites-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" <?php echo 'site' === $selectedby ? '' : 'style="display: none;"'; ?> />
207 - <i class="filter icon"></i>
208 - </div>
209 - </div>
210 - <?php
211 - /**
212 - * Action: mainwp_after_select_sites_filters
213 - *
214 - * Fires after the Select Sites box filters.
215 - *
216 - * @since 4.1
217 - */
218 - do_action( 'mainwp_after_select_sites_filters' );
219 - ?>
220 - <input type="hidden" name="select_by" id="select_by" value="<?php echo esc_attr( $selectedby ); ?>"/>
221 - <input type="hidden" id="select_sites_tab" value="<?php echo esc_attr( $selectedby ); ?>"/>
222 - <div id="mainwp-select-sites-header">
223 - <div class="ui pointing green secondary menu">
224 - <a class="item ui tab <?php echo ( 'site' === $selectedby ) ? 'active' : ''; ?>" data-tab="mainwp-select-sites-<?php echo esc_attr( $tab_id ); ?>" select-by="site"><?php esc_html_e( 'Sites', 'mainwp' ); ?></a>
225 - <?php if ( $show_group ) : ?>
226 - <a class="item ui tab <?php echo ( 'group' === $selectedby ) ? 'active' : ''; ?>" data-tab="mainwp-select-groups-<?php echo esc_attr( $tab_id ); ?>" select-by="group"><?php esc_html_e( 'Tags', 'mainwp' ); ?></a>
227 - <?php endif; ?>
228 - <?php if ( $show_client ) : ?>
229 - <a class="item ui tab <?php echo ( 'client' === $selectedby ) ? 'active' : ''; ?>" data-tab="mainwp-select-clients-<?php echo esc_attr( $tab_id ); ?>" select-by="client"><?php esc_html_e( 'Clients', 'mainwp' ); ?></a>
230 - <?php endif; ?>
231 - <?php if ( $staging_enabled ) : ?>
232 - <a class="item ui tab" data-tab="mainwp-select-staging-sites-<?php echo esc_attr( $tab_id ); ?>" select-by="staging"><?php esc_html_e( 'Staging', 'mainwp' ); ?></a>
233 - <?php endif; ?>
234 - </div>
235 - </div>
236 - <?php
237 - }
165 + /**
166 + * Method select_sites_box_body()
167 + *
168 + * Select sites box Body.
169 + *
170 + * @deprecated 4.3 Use MainWP_UI_Select_Sites::select_sites_box_body().
171 + *
172 + * @param array $selected_websites Child Site that are selected.
173 + * @param array $selected_groups Group that are selected.
174 + * @param string $type Selector type.
175 + * @param bool $show_group Whether or not to show group, Default: true.
176 + * @param bool $show_select_all Whether or not to show select all, Default: true.
177 + * @param bool $updateQty Whether or not to update quantity, Default = false.
178 + * @param bool $enableOfflineSites Whether or not to enable offline sites, Default: true.
179 + * @param int $postId Post ID.
180 + *
181 + * @uses \MainWP\Dashboard\MainWP_DB::query()
182 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
183 + */
184 + 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.
185 + unset( $updateQty );
186 + if ( 'all' !== $selected_websites && ! is_array( $selected_websites ) ) {
187 + $selected_websites = array();
188 + }
238 189
239 - /**
240 - * Method render_select_sites()
241 - *
242 - * @param object $websites Object containing child sites info.
243 - * @param string $type Selector type.
244 - * @param mixed $selected_websites Selected Child Sites.
245 - * @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not.
246 - * @param mixed $edit_site_id Child Site ID to edit.
247 - * @param bool $show_select_all Whether or not to show select all, Default: true.
248 - * @param mixed $add_edit_client_id Show enable sites for client. Default: false, 0: add new client, 0 <: edit client.
249 - * @param bool $show_select_all_disc Whether or not to show select all disconnect sites, Default: false.
250 - *
251 - * @return void Render Select Sites html.
252 - *
253 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
254 - * @uses \MainWP\Dashboard\MainWP_DB::free_result()
255 - */
256 - public static function render_select_sites( $websites, $type, $selected_websites, $enableOfflineSites, $edit_site_id, $show_select_all, $add_edit_client_id = false, $show_select_all_disc = false ) { // phpcs:ignore
257 - /**
258 - * Action: mainwp_before_select_sites_list
259 - *
260 - * Fires before the Select Sites list.
261 - *
262 - * @param object $websites Object containing child sites info.
263 - *
264 - * @since 4.1
265 - */
266 - do_action( 'mainwp_before_select_sites_list', $websites );
267 - $count_disc = 0;
268 - ?>
269 - <div id="mainwp-select-sites-body">
270 - <div class="ui relaxed divided list" id="mainwp-select-sites-list">
271 - <?php if ( ! $websites ) : ?>
272 - <h2 class="ui icon header">
273 - <i class="folder open outline icon"></i>
274 - <div class="content"><?php esc_html_e( 'No Sites connected!', 'mainwp' ); ?></div>
275 - <div class="ui divider hidden"></div>
276 - <a href="admin.php?page=managesites&do=new" class="ui green button basic"><?php esc_html_e( 'Add Site', 'mainwp' ); ?></a>
277 - </h2>
278 - <?php
279 - else :
280 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
281 - $enable_site = true;
282 - if ( false === $add_edit_client_id ) {
283 - $enable_site = true;
284 - } elseif ( 0 === intval( $add_edit_client_id ) && false !== $add_edit_client_id ) {
285 - if ( 0 < intval( $website->client_id ) ) {
286 - $enable_site = false;
287 - }
288 - } elseif ( is_numeric( $add_edit_client_id ) && intval( $add_edit_client_id ) > 0 ) {
289 - if ( 0 < intval( $website->client_id ) && intval( $website->client_id ) !== intval( $add_edit_client_id ) ) {
290 - $enable_site = false;
291 - }
292 - }
190 + if ( ! is_array( $selected_groups ) ) {
191 + $selected_groups = array();
192 + }
293 193
294 - $site_client_editing = ( $add_edit_client_id && $website->client_id && $add_edit_client_id === $website->client_id ) ? true : false;
194 + $selectedby = 'site';
195 + if ( ! empty( $selected_groups ) ) {
196 + $selectedby = 'group';
197 + }
295 198
296 - $selected = false;
297 - $disconnected = false;
298 - if ( ( empty( $website->sync_errors ) || $enableOfflineSites ) && ( ! MainWP_System_Utility::is_suspended_site( $website ) || $site_client_editing ) && $enable_site ) {
299 - $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
300 - $disabled = '';
301 - if ( $edit_site_id ) {
302 - if ( (int) $website->id === $edit_site_id ) {
303 - $selected = true;
304 - } else {
305 - $disabled = 'disabled="disabled"';
306 - }
307 - }
199 + $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.name' ) );
200 + $groups = MainWP_DB_Common::instance()->get_not_empty_groups( null, $enableOfflineSites );
308 201
309 - if ( '' !== $website->sync_errors ) {
310 - $disconnected = true;
311 - ++$count_disc;
312 - }
313 - ?>
314 - <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' : '' ); ?>">
315 - <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"' : '' ); ?> />
316 - <label for="selected_sites_<?php echo intval( $website->id ); ?>">
317 - <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
318 - </label>
319 - </div>
320 - <?php
321 - } else {
322 - ?>
323 - <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' : '' ); ?>">
324 - <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
325 - <label for="selected_sites_<?php echo intval( $website->id ); ?>">
326 - <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
327 - </label>
328 - </div>
329 - <?php
330 - }
331 - }
332 - MainWP_DB::free_result( $websites );
333 - endif;
334 - ?>
335 - </div>
336 - </div>
337 - <?php
338 - /**
339 - * Action: mainwp_after_select_sites_list
340 - *
341 - * Fires after the Select Sites list.
342 - *
343 - * @param object $websites Object containing child sites info.
344 - *
345 - * @since 4.1
346 - */
347 - do_action( 'mainwp_after_select_sites_list', $websites );
348 - ?>
349 - <?php
350 - }
202 + // support staging extension.
203 + $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
351 204
352 - /**
353 - * Method render_select_sites_staging()
354 - *
355 - * Render selected staging sites.
356 - *
357 - * @param mixed $selected_websites Selected Child Sites.
358 - * @param mixed $edit_site_id Child Site ID to edit.
359 - * @param string $type Selector type.
360 - *
361 - * @return void Render selected staging sites html.
362 - *
363 - * @uses \MainWP\Dashboard\MainWP_DB::query()
364 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
365 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
366 - * @uses \MainWP\Dashboard\MainWP_DB::free_result()
367 - */
368 - public static function render_select_sites_staging( $selected_websites, $edit_site_id, $type = 'checkbox' ) {
369 - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'favi_icon' ), $is_staging = 'yes' ) );
370 - ?>
371 - <div id="mainwp-select-sites-body">
372 - <div class="ui relaxed divided list" id="mainwp-select-staging-sites-list">
373 - <?php if ( ! $websites ) : ?>
374 - <h2 class="ui icon header">
375 - <i class="folder open outline icon"></i>
376 - <div class="content"><?php esc_html_e( 'No staging websites have been found!', 'mainwp' ); ?></div>
377 - </h2>
378 - <?php
379 - else :
380 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
381 - $selected = false;
382 - if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
383 - $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
384 - $disabled = '';
385 - if ( $edit_site_id ) {
386 - if ( $website->id !== $edit_site_id ) {
387 - $disabled = 'disabled="disabled"';
388 - }
389 - }
390 - ?>
391 - <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' : '' ); ?>">
392 - <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"' : '' ); ?> />
393 - <label for="selected_sites_<?php echo intval( $website->id ); ?>">
394 - <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
395 - </label>
396 - </div>
397 - <?php
398 - } else {
399 - ?>
400 - <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' : '' ); ?>">
401 - <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
402 - <label for="selected_sites_<?php echo intval( $website->id ); ?>">
403 - <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
404 - </label>
405 - </div>
406 - <?php
407 - }
408 - }
409 - MainWP_DB::free_result( $websites );
410 - endif;
411 - ?>
412 - </div>
413 - </div>
414 - <?php
415 - }
205 + $edit_site_id = false;
206 + if ( $postId ) {
207 + $edit_site_id = get_post_meta( $postId, '_mainwp_edit_post_site_id', true );
208 + $edit_site_id = intval( $edit_site_id );
209 + }
416 210
417 - /**
418 - * Method render_select_sites_group()
419 - *
420 - * Render selected sites group.
421 - *
422 - * @param array $groups Array of groups.
423 - * @param mixed $selected_groups Selected groups.
424 - * @param string $type Selector type.
425 - *
426 - * @return void Render selected sites group html.
427 - */
428 - public static function render_select_sites_group( $groups, $selected_groups, $type = 'checkbox' ) {
429 - /**
430 - * Action: mainwp_before_select_groups_list
431 - *
432 - * Fires before the Select Groups list.
433 - *
434 - * @param object $groups Object containing groups info.
435 - *
436 - * @since 4.1
437 - */
438 - do_action( 'mainwp_before_select_groups_list', $groups );
439 - ?>
440 - <div id="mainwp-select-sites-body">
441 - <div class="ui relaxed divided list" id="mainwp-select-groups-list">
442 - <?php
443 - if ( 0 === count( $groups ) ) {
444 - ?>
445 - <h2 class="ui icon header">
446 - <i class="folder open outline icon"></i>
447 - <div class="content"><?php esc_html_e( 'No Tags created!', 'mainwp' ); ?></div>
448 - <div class="ui divider hidden"></div>
449 - <a href="admin.php?page=ManageGroups" class="ui green button basic"><?php esc_html_e( 'Create Tags', 'mainwp' ); ?></a>
450 - </h2>
451 - <?php
452 - }
453 - foreach ( $groups as $group ) {
454 - $selected = in_array( $group->id, $selected_groups );
455 - ?>
456 - <div class="mainwp_selected_groups_item ui item <?php echo esc_html( $type ); ?> <?php echo ( $selected ? 'selected_groups_item_checked' : '' ); ?>">
457 - <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"' : '' ); ?> />
458 - <label for="selected_groups_<?php echo esc_attr( $group->id ); ?>">
459 - <?php echo esc_html( stripslashes( $group->name ) ); ?>
460 - </label>
461 - </div>
462 - <?php
463 - }
464 - ?>
465 - </div>
466 - </div>
467 - <?php
468 - /**
469 - * Action: mainwp_after_select_groups_list
470 - *
471 - * Fires after the Select Groups list.
472 - *
473 - * @param object $groups Object containing groups info.
474 - *
475 - * @since 4.1
476 - */
477 - do_action( 'mainwp_after_select_groups_list', $groups );
478 - }
211 + if ( $edit_site_id ) {
212 + $show_group = false;
213 + }
214 + // to fix layout with multi sites selector.
215 + $tab_id = wp_rand();
479 216
480 - /**
481 - * Method render_top_header()
482 - *
483 - * Render top header.
484 - *
485 - * @param array $params Page parameters.
486 - *
487 - * @uses \MainWP\Dashboard\MainWP_DB::query()
488 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
489 - * @uses \MainWP\Dashboard\MainWP_Menu::render_left_menu()
490 - */
491 - public static function render_top_header( $params = array() ) { // phpcs:ignore -- complex.
217 + static::render_select_sites_header( $tab_id, $staging_enabled, $selectedby, $show_group );
218 + ?>
219 + <div class="ui tab <?php echo 'site' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-sites-<?php echo esc_attr( $tab_id ); ?>" id="mainwp-select-sites">
220 + <?php
221 + static::render_select_sites( $websites, $type, $selected_websites, $enableOfflineSites, $edit_site_id, $show_select_all );
222 + ?>
223 + </div>
224 + <?php if ( $staging_enabled ) { ?>
225 + <div class="ui tab <?php echo 'staging' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-staging-sites-<?php echo esc_attr( $tab_id ); ?>">
226 + <?php
227 + static::render_select_sites_staging( $selected_websites, $edit_site_id, $type );
228 + ?>
229 + </div>
230 + <?php
231 + }
232 + if ( $show_group ) {
233 + ?>
234 + <div class="ui tab <?php echo 'group' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-groups-<?php echo esc_attr( $tab_id ); ?>" id="mainwp-select-groups">
235 + <?php
236 + static::render_select_sites_group( $groups, $selected_groups, $type );
237 + ?>
238 + </div>
239 + <?php
240 + }
241 + ?>
242 + <?php
243 + }
492 244
493 - $title = isset( $params['title'] ) ? $params['title'] : '';
494 - $which = isset( $params['which'] ) ? $params['which'] : '';
245 + /**
246 + * Method render_select_sites_header()
247 + *
248 + * Render selected sites header.
249 + *
250 + * @param int $tab_id Datatab ID.
251 + * @param bool $staging_enabled True, if in the active plugins list. False, not in the list.
252 + * @param array $selectedby Selected by.
253 + * @param bool $show_group Whether or not to show group, Default: true.
254 + * @param bool $show_client Whether or not to show client, Default: true.
255 + *
256 + * @devtodo Move to view folder.
257 + */
258 + public static function render_select_sites_header( $tab_id, $staging_enabled, $selectedby, $show_group = true, $show_client = false ) {
495 259
496 - /**
497 - * Filter: mainwp_header_title
498 - *
499 - * Filter the MainWP page title in the header element.
500 - *
501 - * @since 4.0
502 - */
503 - $title = apply_filters( 'mainwp_header_title', $title );
260 + static $rendered_count = 0;
504 261
505 - $show_menu = true;
506 - $show_new_items = true;
262 + $rand_id_prefix = '';
507 263
508 - if ( isset( $params['show_menu'] ) ) {
509 - $show_menu = $params['show_menu'];
510 - }
264 + if ( ! empty( $rendered_count ) ) {
265 + $rand_id_prefix = '-' . MainWP_Utility::gen_rand_id();
266 + }
511 267
512 - $more_tags = array(
513 - 'img' => array(
514 - 'src' => array(),
515 - 'width' => array(),
516 - 'height' => array(),
517 - 'class' => array(),
518 - ),
519 - 'div' => array(
520 - 'class' => array(),
521 - ),
522 - 'a' => array(
523 - 'href' => array(),
524 - 'class' => array(),
525 - 'target' => array(),
526 - 'style' => array(),
527 - 'site-id' => array(),
528 - 'siteid' => array(),
529 - ),
530 - 'i' => array(
531 - 'class' => array(),
532 - 'target' => array(),
533 - 'style' => array(),
534 - ),
535 - );
536 - $title = MainWP_Utility::esc_content( $title, 'note', $more_tags );
268 + ++$rendered_count;
537 269
538 - /**
539 - * Filter: mainwp_header_left
540 - *
541 - * Filter the MainWP header element left side content.
542 - *
543 - * @since 4.0
544 - */
545 - $left = apply_filters( 'mainwp_header_left', $title );
270 + ?>
271 + <input type="hidden" name="select_by" value="<?php echo esc_attr( $selectedby ); ?>" id="select_by<?php echo esc_attr( $rand_id_prefix ); // empty prefix to ensure compatibility with extensions. ?>"/>
272 + <input type="hidden" name="select_sites_tab" id="select_sites_tab<?php echo esc_attr( $rand_id_prefix ); // empty prefix to ensure compatibility with extensions. ?>" value="<?php echo esc_attr( $selectedby ); ?>"/>
546 273
547 - $right = self::render_header_actions();
274 + <div class="mainwp-select-sites-header" id="mainwp-select-sites-header<?php echo esc_attr( $rand_id_prefix ); // empty prefix to ensure compatibility with extensions. ?>" >
275 + <div class="ui secondary mini horizontal menu" id="mainwp-select-sites-menu">
276 + <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>
277 + <?php if ( $show_group ) : ?>
278 + <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>
279 + <?php endif; ?>
280 + <?php if ( $show_client ) : ?>
281 + <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>
282 + <?php endif; ?>
283 + <?php if ( $staging_enabled ) : ?>
284 + <a class="item ui text tab" data-tab="mainwp-select-staging-sites-<?php echo esc_attr( $tab_id ); ?>" select-by="staging"><?php esc_html_e( 'Staging', 'mainwp' ); ?></a>
285 + <?php endif; ?>
286 + </div>
287 + </div>
548 288
549 - /**
550 - * Filter: mainwp_header_right
551 - *
552 - * Filter the MainWP header element right side content.
553 - *
554 - * @since 4.0
555 - */
556 - $right = apply_filters( 'mainwp_header_right', $right );
557 289
558 - if ( $show_menu ) {
559 - MainWP_Menu::render_left_menu();
560 - MainWP_Menu::render_mobile_menu();
561 - }
290 + <?php
291 + /**
292 + * Action: mainwp_before_select_sites_filters
293 + *
294 + * Fires before the Select Sites box filters.
295 + *
296 + * @since 4.1
297 + */
298 + do_action( 'mainwp_before_select_sites_filters' );
299 + ?>
300 + <div id="mainwp-select-sites-filters">
301 + <div class="ui mini fluid icon input">
302 + <input type="text" id="mainwp-select-sites-filter" value="" placeholder="<?php esc_attr_e( 'Search...', 'mainwp' ); ?>" />
303 + <i class="filter icon"></i>
304 + </div>
305 + </div>
306 + <?php
307 + /**
308 + * Action: mainwp_after_select_sites_filters
309 + *
310 + * Fires after the Select Sites box filters.
311 + *
312 + * @since 4.1
313 + */
314 + do_action( 'mainwp_after_select_sites_filters' );
315 + }
562 316
563 - $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
564 - if ( false === $sidebarPosition ) {
565 - $sidebarPosition = 1;
566 - }
317 + /**
318 + * Method render_select_sites()
319 + *
320 + * @param object $websites Object containing child sites info.
321 + * @param string $type Selector type.
322 + * @param mixed $selected_websites Selected Child Sites.
323 + * @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not.
324 + * @param mixed $edit_site_id Child Site ID to edit.
325 + * @param bool $show_select_all Whether or not to show select all, Default: true.
326 + * @param mixed $add_edit_client_id Show enable sites for client. Default: false, 0: add new client, 0 <: edit client.
327 + * @param bool $show_select_all_disc Whether or not to show select all disconnect sites, Default: false.
328 + *
329 + * @return void Render Select Sites html.
330 + *
331 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
332 + * @uses \MainWP\Dashboard\MainWP_DB::free_result()
333 + */
334 + 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.
335 + /**
336 + * Action: mainwp_before_select_sites_list
337 + *
338 + * Fires before the Select Sites list.
339 + *
340 + * @param object $websites Object containing child sites info.
341 + *
342 + * @since 4.1
343 + */
344 + do_action( 'mainwp_before_select_sites_list', $websites );
345 + $count_disc = 0;
567 346
568 - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
347 + static $rendered_count = 0;
569 348
570 - $count_sites = MainWP_DB::instance()->get_websites_count();
349 + $rand_id_prefix = '';
571 350
572 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
573 - if ( empty( $count_sites ) ) {
574 - if ( ! isset( $_GET['do'] ) ) {
575 - self::render_modal_no_sites_note();
576 - }
577 - }
351 + if ( ! empty( $rendered_count ) ) {
352 + $rand_id_prefix = '-' . MainWP_Utility::gen_rand_id();
353 + }
578 354
579 - $siteViewMode = MainWP_Utility::get_siteview_mode();
355 + ++$rendered_count;
580 356
581 - $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
357 + ?>
358 + <div id="mainwp-select-sites-body<?php echo esc_attr( $rand_id_prefix ); ?>" class="mainwp-select-sites-items-body">
359 + <div class="ui relaxed selection list mainwp-select-sites-list" id="mainwp-select-sites-list">
360 + <?php if ( ! $websites ) : ?>
361 + <div id="mainwp-select-sites-placeholder" class="ui segment">
362 + <?php static::render_empty_element_placeholder( __( 'No sites yet', 'mainwp' ), __( 'Connect your first WordPress site to start managing it from MainWP.', 'mainwp' ), '<em data-emoji=":link:" class="medium"></em>' ); ?>
363 + <div class="ui center aligned segment">
364 + <a href="admin.php?page=managesites&do=new" class="ui mini green button"><?php esc_html_e( 'Connect a Site', 'mainwp' ); ?></a> <a href="https://docs.mainwp.com/getting-started/get-started-with-mainwp#add-a-site-to-your-dashboard" class="ui mini grey basic button" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Learn How', 'mainwp' ); ?></a>
365 + </div>
366 + </div>
367 + <?php
368 + else :
369 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
370 + $enable_site = true;
371 + if ( false === $add_edit_client_id ) {
372 + $enable_site = true;
373 + } elseif ( 0 === intval( $add_edit_client_id ) && false !== $add_edit_client_id ) {
374 + if ( 0 < intval( $website->client_id ) ) {
375 + $enable_site = false;
376 + }
377 + } elseif ( is_numeric( $add_edit_client_id ) && intval( $add_edit_client_id ) > 0 ) {
378 + if ( 0 < intval( $website->client_id ) && intval( $website->client_id ) !== intval( $add_edit_client_id ) ) {
379 + $enable_site = false;
380 + }
381 + }
582 382
583 - $tour_id = '';
584 - if ( 'mainwp_tab' === $page ) {
585 - $tour_id = '13112';
586 - } elseif ( 'managesites' === $page ) {
587 - if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) {
588 - $tour_id = '13210';
589 - } elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) {
590 - $tour_id = '27274';
591 - } elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
592 - if ( 'grid' === $siteViewMode ) {
593 - $tour_id = '27217';
594 - } else {
595 - $tour_id = '29331';
596 - }
597 - }
598 - } elseif ( 'MonitoringSites' === $page ) {
599 - $tour_id = '29003';
600 - } elseif ( 'ManageClients' === $page ) {
601 - if ( isset( $_GET['client_id'] ) ) {
602 - $tour_id = '28258';
603 - } else {
604 - $tour_id = '28240';
605 - }
606 - } elseif ( 'ClientAddNew' === $page ) {
607 - if ( isset( $_GET['client_id'] ) ) {
608 - $tour_id = '28962';
609 - } else {
610 - $tour_id = '28256';
611 - }
612 - } elseif ( 'ClientAddField' === $page ) {
613 - $tour_id = '28257';
614 - } elseif ( 'PluginsManage' === $page ) {
615 - $tour_id = '28510';
616 - } elseif ( 'ManageGroups' === $page ) {
617 - $tour_id = '27275';
618 - } elseif ( 'UpdatesManage' === $page ) {
619 - $tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
620 - if ( 'plugins-updates' === $tab ) {
621 - $tour_id = '28259';
622 - } elseif ( 'themes-updates' === $tab ) {
623 - $tour_id = '28447';
624 - } elseif ( 'wordpress-updates' === $tab ) {
625 - $tour_id = '29005';
626 - } elseif ( 'translations-updates' === $tab ) {
627 - $tour_id = '29007';
628 - } elseif ( 'abandoned-plugins' === $tab ) {
629 - $tour_id = '29008';
630 - } elseif ( 'abandoned-themes' === $tab ) {
631 - $tour_id = '29009';
632 - } elseif ( 'plugin-db-updates' === $tab ) {
633 - $tour_id = '33161';
634 - } else {
635 - $tour_id = '28259';
636 - }
637 - } elseif ( 'PluginsInstall' === $page ) {
638 - $tour_id = '29011';
639 - } elseif ( 'PluginsAutoUpdate' === $page ) {
640 - $tour_id = '29015';
641 - } elseif ( 'PluginsIgnore' === $page ) {
642 - $tour_id = '29018';
643 - } elseif ( 'PluginsIgnoredAbandoned' === $page ) {
644 - $tour_id = '29329';
645 - } elseif ( 'ThemesManage' === $page ) {
646 - $tour_id = '28511';
647 - } elseif ( 'ThemesInstall' === $page ) {
648 - $tour_id = '29010';
649 - } elseif ( 'ThemesAutoUpdate' === $page ) {
650 - $tour_id = '29016';
651 - } elseif ( 'ThemesIgnore' === $page ) {
652 - $tour_id = '29019';
653 - } elseif ( 'ThemesIgnoredAbandoned' === $page ) {
654 - $tour_id = '29330';
655 - } elseif ( 'UserBulkManage' === $page ) {
656 - $tour_id = '28574';
657 - } elseif ( 'UserBulkAdd' === $page ) {
658 - $tour_id = '28575';
659 - } elseif ( 'BulkImportUsers' === $page ) {
660 - $tour_id = '28736';
661 - } elseif ( 'UpdateAdminPasswords' === $page ) {
662 - $tour_id = '28737';
663 - } elseif ( 'PostBulkManage' === $page ) {
664 - $tour_id = '28796';
665 - } elseif ( 'PostBulkAdd' === $page ) {
666 - $tour_id = '28799';
667 - } elseif ( 'PageBulkManage' === $page ) {
668 - $tour_id = '29045';
669 - } elseif ( 'PageBulkAdd' === $page ) {
670 - $tour_id = '29048';
671 - } elseif ( 'Extensions' === $page ) {
672 - $tour_id = '28800';
673 - } elseif ( 'Settings' === $page ) {
674 - $tour_id = '28883';
675 - } elseif ( 'SettingsAdvanced' === $page ) {
676 - $tour_id = '28886';
677 - } elseif ( 'SettingsEmail' === $page ) {
678 - $tour_id = '29054';
679 - } elseif ( 'MainWPTools' === $page ) {
680 - $tour_id = '29272';
681 - } elseif ( 'RESTAPI' === $page ) {
682 - $tour_id = '29273';
683 - } elseif ( 'ServerInformation' === $page ) {
684 - $tour_id = '28873';
685 - } elseif ( 'ServerInformationCron' === $page ) {
686 - $tour_id = '28874';
687 - } elseif ( 'ErrorLog' === $page ) {
688 - $tour_id = '28876';
689 - } elseif ( 'ActionLogs' === $page ) {
690 - $tour_id = '28877';
691 - } elseif ( 'Extensions-Mainwp-Jetpack-Protect-Extension' === $page ) {
692 - $tour_id = '31700';
693 - } elseif ( 'Extensions-Mainwp-Jetpack-Scan-Extension' === $page ) {
694 - $tour_id = '31694';
695 - } elseif ( 'Extensions-Termageddon-For-Mainwp' === $page ) {
696 - $tour_id = '32104';
697 - } elseif ( 'Extensions-Advanced-Uptime-Monitor-Extension' === $page ) {
698 - $tour_id = '32149';
699 - } elseif ( 'Extensions-Mainwp-Custom-Dashboard-Extension' === $page ) {
700 - $tour_id = '32150';
701 - } elseif ( 'Extensions-Mainwp-Updraftplus-Extension' === $page ) {
702 - $tour_id = '32151';
703 - } elseif ( 'Extensions-Mainwp-Sucuri-Extension' === $page ) {
704 - $tour_id = '32152';
705 - } elseif ( 'Extensions-Mainwp-Clean-And-Lock-Extension' === $page ) {
706 - $tour_id = '32153';
707 - } elseif ( 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' === $page ) {
708 - $tour_id = '32851';
709 - } elseif ( 'Extensions-Mainwp-Buddy-Extension' === $page ) {
710 - $tour_id = '33064';
711 - } elseif ( 'Extensions-Mainwp-Backwpup-Extension' === $page ) {
712 - $tour_id = '32923';
713 - } elseif ( 'Extensions-Mainwp-Ssl-Monitor-Extension' === $page ) {
714 - $tour_id = '33164';
715 - } elseif ( 'Extensions-Mainwp-Cache-Control-Extension' === $page ) {
716 - $tour_id = '33167';
717 - } elseif ( 'Extensions-Mainwp-Maintenance-Extension' === $page ) {
718 - $tour_id = '33301';
719 - } elseif ( 'Extensions-Mainwp-Domain-Monitor-Extension' === $page ) {
720 - $tour_id = '33300';
721 - }
722 - // phpcs:enable
723 - ?>
724 - <div class="ui segment right sites sidebar" style="padding:0px" id="mainwp-sites-menu-sidebar">
725 - <div class="ui segment" style="margin-bottom:0px">
726 - <div class="ui header"><?php esc_html_e( 'Quick Site Shortcuts', 'mainwp' ); ?></div>
727 - </div>
728 - <div class="ui fitted divider"></div>
729 - <div class="ui segment" style="margin-bottom:0px">
730 - <div class="ui mini fluid icon input" <?php echo $websites ? '' : 'style="display: none;"'; ?> >
731 - <input type="text" id="mainwp-sites-menu-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" />
732 - <i class="filter icon"></i>
733 - </div>
734 - </div>
735 - <div class="ui fluid vertical accordion menu" id="mainwp-sites-sidebar-menu" style="margin-top:0px;border-radius:0px;box-shadow:none;">
736 - <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
737 - <div class="item mainwp-site-menu-item">
738 - <div class="title">
739 - <i class="dropdown icon"></i>
740 - <label><?php echo esc_html( $website->name ); ?></label>
741 - </div>
742 - <div class="content">
743 - <div class="ui hiden divider"></div>
744 - <div class="ui fluid relaxed list">
745 - <div class="item" >
746 - <i class="grid layout icon"></i>
747 - <a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website->id ); ?>"><?php esc_html_e( 'Overview', 'mainwp' ); ?></a>
748 - </div>
749 - <div class="item" >
750 - <i class="redo icon"></i>
751 - <a href="<?php echo 'admin.php?page=managesites&updateid=' . intval( $website->id ); ?>"><?php esc_html_e( 'Updates', 'mainwp' ); ?></a>
752 - </div>
753 - <div class="item">
754 - <i class="edit icon"></i>
755 - <a href="<?php echo 'admin.php?page=managesites&id=' . intval( $website->id ); ?>"><?php esc_html_e( 'Edit Site', 'mainwp' ); ?></a>
756 - </div>
757 - <div class="item">
758 - <i class="sync alt icon"></i>
759 - <a href="#" siteid="<?php echo intval( $website->id ); ?>" onClick="updatesoverview_wp_sync( '<?php echo intval( $website->id ); ?>' )"><?php esc_html_e( 'Sync Site', 'mainwp' ); ?></a>
760 - </div>
761 - <div class="item">
762 - <i class="shield icon"></i>
763 - <a href="<?php echo 'admin.php?page=managesites&scanid=' . intval( $website->id ); ?>"><?php esc_html_e( 'Site Hardening', 'mainwp' ); ?></a>
764 - </div>
765 - <div class="item">
766 - <i class="sign in icon"></i>
767 - <a target="_blank" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . intval( $website->id ); ?>&_opennonce=<?php echo esc_attr( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a>
768 - </div>
769 - <div class="item">
770 - <i class="globe icon"></i>
771 - <a target="_blank" href="<?php echo esc_url( $website->url ); ?>"><?php esc_html_e( 'Visit Site', 'mainwp' ); ?></a>
772 - </div>
773 - <?php
774 - /**
775 - * Action: mainwp_quick_sites_shortcut
776 - *
777 - * Adds a new shortcut item in the Quick Sites Shortcuts sidebar menu.
778 - *
779 - * @param array $website Array containing the child site data.
780 - *
781 - * Suggested HTML markup:
782 - *
783 - * <a class="item" href="your custom URL">
784 - * <i class="your custom icon"></i>
785 - * Your custom label text
786 - * </a>
787 - *
788 - * @since 4.1
789 - */
790 - do_action( 'mainwp_quick_sites_shortcut', $website );
791 - ?>
792 - </div>
793 - </div>
794 - </div>
795 - <?php } ?>
796 - </div>
797 - </div>
798 - <div class="ui segment right wide help sidebar" id="mainwp-documentation-sidebar">
799 - <div class="ui header"><?php esc_html_e( 'MainWP Guided Tours', 'mainwp' ); ?> <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></div>
800 - <div class="ui hidden divider"></div>
801 - <div class="ui info message" style="display:block!important;">
802 - <?php printf( esc_html__( 'This feature is implemented using Javascript provided by Usetiful and is subject to the %1$sUsetiful Privacy Policy%2$s.', 'mainwp' ), '<a href="https://www.usetiful.com/privacy-policy" target="_blank">', '</a>' ); ?>
803 - </div>
804 - <div class="ui hidden divider"></div>
805 - <div class="ui toggle checkbox">
806 - <input type="checkbox" id="mainwp-select-guided-tours-option" onchange="mainwp_guidedtours_onchange(this);"<?php echo ( ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) ? 'checked="true"' : '' ); ?> /> <label><?php esc_html_e( 'Switch to enable or disable tours.', 'mainwp' ); ?></label>
807 - </div>
808 - <div class="ui hidden divider"></div>
809 - <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
810 - <p><?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?></p>
811 - <p><?php esc_html_e( 'Click the Start Page Tour button to start the guided tour for the current page.', 'mainwp' ); ?></p>
812 - <div class="ui hidden divider"></div>
813 - <a href="javacscript:void(0);" id="mainwp-start-page-tour-button" class="ui big green fluid basic button" tour-id="<?php esc_attr_e( $tour_id ); ?>"><?php esc_html_e( 'Start Page Tour', 'mainwp' ); ?></a>
814 - <?php if ( 'mainwp_tab' === $page ) : ?>
815 - <div class="ui hidden divider"></div>
816 - <a href="javacscript:void(0);" id="mainwp-interface-tour-button" class="ui big green fluid basic button"><?php esc_html_e( 'MainWP Interface Basics Tour', 'mainwp' ); ?></a>
817 - <?php endif; ?>
818 - <?php endif; ?>
819 - <div class="ui header"><?php esc_html_e( 'MainWP Knowledge Base', 'mainwp' ); ?></div>
820 - <div class="ui hidden divider"></div>
821 - <?php
822 - /**
823 - * Action: mainwp_help_sidebar_content
824 - *
825 - * Fires Help sidebar content
826 - *
827 - * @since 4.0
828 - */
829 - do_action( 'mainwp_help_sidebar_content' );
830 - ?>
831 - <div class="ui hidden divider"></div>
832 - <a href="https://kb.mainwp.com/" class="ui big green fluid button"><?php esc_html_e( 'Help Documentation', 'mainwp' ); ?></a>
833 - <div class="ui hidden divider"></div>
834 - <div id="mainwp-sticky-help-button" class="" style="position: absolute; bottom: 1em; left: 1em; right: 1em;">
835 - <a href="https://managers.mainwp.com/" target="_blank" class="ui fluid button"><?php esc_html_e( 'Still Need Help?', 'mainwp' ); ?></a>
836 - </div>
837 - </div>
838 - <?php
839 - /**
840 - * Action: mainwp_before_mainwp_content_wrap
841 - *
842 - * Fires before the #mainwp-content-wrap element.
843 - *
844 - * @param array $websites Array containing the child site data.
845 - *
846 - * @since 4.1
847 - */
848 - do_action( 'mainwp_before_mainwp_content_wrap', $websites );
849 - global $wp_version;
850 - $fix_menu_overflow = 1;
851 - if ( version_compare( $wp_version, '5.5.3', '>' ) ) {
852 - $fix_menu_overflow = 2;
853 - }
383 + $site_client_editing = ( $add_edit_client_id && $website->client_id && $add_edit_client_id === $website->client_id ) ? true : false;
854 384
855 - if ( 'page_clients_overview' !== $which ) {
856 - ?>
385 + $selected = false;
386 + $disconnected = false;
387 + if ( ( empty( $website->sync_errors ) || $enableOfflineSites ) && ( ! MainWP_System_Utility::is_suspended_site( $website ) || $site_client_editing ) && $enable_site ) {
388 + $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
389 + $disabled = '';
390 + if ( $edit_site_id ) {
391 + if ( (int) $website->id === $edit_site_id ) {
392 + $selected = true;
393 + } else {
394 + $disabled = 'disabled="disabled"';
395 + }
396 + }
857 397
858 - <div class="ui modal" id="mainwp-overview-screen-options-modal">
859 - <i class="close icon"></i>
860 - <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
861 - <div class="content ui form">
862 - <?php
863 - /**
864 - * Action: mainwp_overview_screen_options_top
865 - *
866 - * Fires at the top of the Sceen Options modal on the Overview page.
867 - *
868 - * @since 4.1
869 - */
870 - do_action( 'mainwp_overview_screen_options_top' );
871 - ?>
872 - <form method="POST" action="" name="mainwp_overview_screen_options_form" id="mainwp-overview-screen-options-form">
873 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
874 - <input type="hidden" name="wp_nonce" value="<?php echo esc_html( wp_create_nonce( 'MainWPScrOptions' ) ); ?>" />
875 - <?php self::render_screen_options( false ); ?>
876 - <?php
877 - /**
878 - * Action: mainwp_overview_screen_options_bottom
879 - *
880 - * Fires at the bottom of the Sceen Options modal on the Overview page.
881 - *
882 - * @since 4.1
883 - */
884 - do_action( 'mainwp_overview_screen_options_bottom' );
885 - ?>
886 - </div>
887 - <div class="actions">
888 - <div class="ui two columns grid">
889 - <div class="left aligned column">
890 - <span data-tooltip="<?php esc_attr_e( 'Resets the page to its original layout and reinstates relocated widgets.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><input type="button" class="ui button" name="reset" id="reset-overview-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span>
891 - </div>
892 - <div class="ui right aligned column">
893 - <input type="submit" class="ui green button" id="submit-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
894 - </div>
895 - </div>
896 - </div>
398 + if ( '' !== $website->sync_errors ) {
399 + $disconnected = true;
400 + ++$count_disc;
401 + }
402 + $sel_id_prefix = MainWP_Utility::gen_rand_id( $website->id, true );
403 + ?>
404 + <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' : '' ); ?>">
405 + <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 esc_attr( $sel_id_prefix ); ?>" <?php echo $selected ? 'checked="true"' : ''; ?> />
406 + <label for="selected_sites_<?php echo esc_attr( $sel_id_prefix ); ?>">
407 + <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
408 + </label>
409 + </div>
410 + <?php
411 + } else {
412 + $sel_id_prefix2 = MainWP_Utility::gen_rand_id( $website->id, true );
413 + ?>
414 + <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' : ''; ?>">
415 + <input type="<?php echo esc_html( $type ); ?>" disabled="disabled" id="selected_sites_<?php echo esc_attr( $sel_id_prefix2 ); ?>"/>
416 + <label for="selected_sites_<?php echo esc_attr( $sel_id_prefix2 ); ?>">
417 + <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
418 + </label>
419 + </div>
420 + <?php
421 + }
422 + }
423 + MainWP_DB::free_result( $websites );
424 + endif;
425 + ?>
426 + </div>
427 + </div>
428 + <?php
429 + /**
430 + * Action: mainwp_after_select_sites_list
431 + *
432 + * Fires after the Select Sites list.
433 + *
434 + * @param object $websites Object containing child sites info.
435 + *
436 + * @since 4.1
437 + */
438 + do_action( 'mainwp_after_select_sites_list', $websites );
439 + ?>
440 + <?php
441 + }
897 442
898 - <input type="hidden" name="reset_overview_settings" value="" />
899 - </form>
900 - </div>
901 - <?php } ?>
902 - <?php
903 - $wrap_class = isset( $params['wrap_class'] ) ? $params['wrap_class'] : '';
904 - ?>
905 - <div class="mainwp-content-wrap <?php echo esc_attr( $wrap_class ); ?> <?php echo empty( $sidebarPosition ) ? 'mainwp-sidebar-left' : ''; ?>" menu-overflow="<?php echo intval( $fix_menu_overflow ); ?>">
906 - <?php if ( MainWP_Demo_Handle::is_demo_mode() ) : ?>
907 - <div class="ui segment" style="background-color:#1c1d1b!important;margin-bottom:0px;">
908 - <div class="ui inverted accordion" id="mainwp_demo_mode_accordion" style="background-color:#1c1d1b;">
909 - <div class="title">
910 - <i class="dropdown icon"></i>
911 - <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
912 - <strong style="color:#fff;font-size:16px;"><?php esc_html_e( 'You are in Demo Mode. Click here for more info or to disable it', 'mainwp' ); ?></strong>
913 - <?php } else { ?>
914 - <strong style="color:#fff;font-size:16px;"><?php esc_html_e( 'You are in Demo Mode. Click here for more info', 'mainwp' ); ?></strong>
915 - <?php } ?>
916 - </div>
917 - <div class="content">
918 - <br/>
919 - <div class="ui stackable grid">
920 - <div class="eleven wide middle aligned column">
921 - <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
922 - <p style="color:#fff;font-size:16px;"><?php esc_html_e( 'Once you are ready to get started with MainWP, click the Disable Demo Mode & Remove Demo Content button to remove the demo content and start adding your own. ', 'mainwp' ); ?></p>
923 - <?php } ?>
924 - <p style="color:#fff;font-size:16px;"><strong><?php esc_html_e( 'The demo content serves as placeholder data to give you a feel for the MainWP Dashboard. Please note that because no real websites are connected in this demo, some functionality will be restricted. Features that require a connection to actual websites will be disabled for the duration of the demo.', 'mainwp' ); ?></strong></p>
925 - </div>
926 - <div class="five wide middle aligned column">
927 - <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
928 - <div data-tooltip="<?php esc_attr_e( 'Delete the Demo content from your MainWP Dashboard and disable the Demo mode.', 'mainwp' ); ?>" data-inverted="" data-position="left center"><button class="ui big fluid button mainwp-remove-demo-data-button"><?php esc_html_e( 'Disable Demo Mode & Remove Demo Content', 'mainwp' ); ?></button></div>
929 - <?php } else { ?>
930 - <div data-tooltip="<?php esc_attr_e( 'Get started with MainWP.', 'mainwp' ); ?>" data-inverted="" data-position="left center"><a class="ui big fluid button" target="_blank" href="https://mainwp.com/install-mainwp/?utm_source=instawp-demo&utm_medium=banner&utm_campaign=download_black_banner&utm_id=instawp"><?php esc_html_e( 'Download MainWP', 'mainwp' ); ?></a></div>
931 - <?php } ?>
932 - </div>
933 - </div>
934 - <br/>
935 - </div>
936 - </div>
937 - </div>
938 - <script type="text/javascript">
939 - jQuery( '#mainwp_demo_mode_accordion' ).accordion();
940 - </script>
941 - <?php endif; ?>
942 - <?php
943 - /**
944 - * Action: mainwp_before_header
945 - *
946 - * Fires before the MainWP header element.
947 - *
948 - * @param array $websites Array containing the child site data.
949 - *
950 - * @since 4.0
951 - */
952 - do_action( 'mainwp_before_header', $websites );
953 - ?>
954 - <div id="mainwp-top-header" class="ui native sticky">
955 - <div class="ui middle aligned stackable grid">
956 - <div class="six wide left aligned middle aligned column">
957 - <h4 class="mainwp-page-title ui header">
958 - <?php echo $left; // phpcs:ignore WordPress.Security.EscapeOutput ?>
959 - </h4>
960 - </div>
961 -
962 - <div class="ten wide right aligned column"><?php echo $right; ?></div> <?php // phpcs:ignore WordPress.Security.EscapeOutput ?>
443 + /**
444 + * Method render_select_sites_staging()
445 + *
446 + * Render selected staging sites.
447 + *
448 + * @param mixed $selected_websites Selected Child Sites.
449 + * @param mixed $edit_site_id Child Site ID to edit.
450 + * @param string $type Selector type.
451 + *
452 + * @return void Render selected staging sites html.
453 + *
454 + * @uses \MainWP\Dashboard\MainWP_DB::query()
455 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
456 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
457 + * @uses \MainWP\Dashboard\MainWP_DB::free_result()
458 + */
459 + public static function render_select_sites_staging( $selected_websites, $edit_site_id, $type = 'checkbox' ) { //phpcs:ignore -- NOSONAR - complex.
460 + $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' ) );
963 461
964 - </div>
965 - </div>
462 + static $rendered_count = 0;
966 463
967 - <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
968 - <script type="text/javascript">
969 - jQuery( document ).ready( function() {
970 - jQuery( '#mainwp-start-page-tour-button' ).on( 'click', function() {
971 - var tourId = jQuery( this ).attr( 'tour-id' );
972 - jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
973 - window.USETIFUL.tour.start( parseInt( tourId ) );
974 - } );
975 - jQuery( '#mainwp-interface-tour-button' ).on( 'click', function() {
976 - jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
977 - window.USETIFUL.tour.start( 13282 );
978 - } );
979 - } );
980 - </script>
981 - <?php endif; ?>
464 + $rand_id_prefix2 = '';
982 465
983 - <?php
984 - if ( isset( $_GET['message'] ) && ( 'qsw-import' === $_GET['message'] || 'enable-demo-mode' === $_GET['message'] ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
985 - ?>
986 - <script type= 'text/javascript'>
987 - var _count_retry = 0;
988 - _try_start_usetiful_tour = function () {
989 - setTimeout(
990 - function () {
991 - try {
992 - window.USETIFUL.tour.start( parseInt( 40279 ) );
993 - } catch ( e ) {
994 - if ( _count_retry < 10 ) {
995 - _count_retry++;
996 - console.log('retry:' + _count_retry);
997 - _try_start_usetiful_tour();
998 - }
999 - }
1000 - },
1001 - 1000
1002 - );
466 + if ( ! empty( $rendered_count ) ) {
467 + $rand_id_prefix2 = '-' . MainWP_Utility::gen_rand_id();
468 + }
469 +
470 + ++$rendered_count;
471 + ?>
472 + <div id="mainwp-select-sites-body<?php echo esc_attr( $rand_id_prefix2 ); ?>" class="mainwp-select-sites-items-body">
473 + <div class="ui relaxed selection list" id="mainwp-select-staging-sites-list">
474 + <?php if ( ! $websites ) : ?>
475 + <h2 class="ui icon header">
476 + <i class="folder open outline icon"></i>
477 + <div class="content"><?php esc_html_e( 'No staging websites have been found!', 'mainwp' ); ?></div>
478 + </h2>
479 + <?php
480 + else :
481 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
482 + $selected = false;
483 + if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) {
484 + $selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) );
485 + $disabled = '';
486 + if ( $edit_site_id && $website->id !== $edit_site_id ) {
487 + $disabled = 'disabled="disabled"';
488 + }
489 + $sel_id_prefix3 = MainWP_Utility::gen_rand_id( $website->id, true );
490 + ?>
491 + <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' : ''; ?>">
492 + <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 esc_attr( $sel_id_prefix3 ); ?>" <?php echo $selected ? 'checked="true"' : ''; ?> />
493 + <label for="selected_sites_<?php echo esc_attr( $sel_id_prefix3 ); ?>">
494 + <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
495 + </label>
496 + </div>
497 + <?php
498 + } else {
499 + ?>
500 + <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' : ''; ?>">
501 + <input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/>
502 + <label>
503 + <?php echo esc_html( stripslashes( $website->name ) ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span>
504 + </label>
505 + </div>
506 + <?php
507 + }
508 + }
509 + MainWP_DB::free_result( $websites );
510 + endif;
511 + ?>
512 + </div>
513 + </div>
514 + <?php
515 + }
516 +
517 + /**
518 + * Method render_select_sites_group()
519 + *
520 + * Render selected sites group.
521 + *
522 + * @param array $groups Array of groups.
523 + * @param mixed $selected_groups Selected groups.
524 + * @param string $type Selector type.
525 + *
526 + * @return void Render selected sites group html.
527 + */
528 + public static function render_select_sites_group( $groups, $selected_groups, $type = 'checkbox' ) {
529 + /**
530 + * Action: mainwp_before_select_groups_list
531 + *
532 + * Fires before the Select Groups list.
533 + *
534 + * @param object $groups Object containing groups info.
535 + *
536 + * @since 4.1
537 + */
538 + do_action( 'mainwp_before_select_groups_list', $groups );
539 +
540 + static $rendered_count = 0;
541 +
542 + $rand_id_prefix3 = '';
543 +
544 + if ( ! empty( $rendered_count ) ) {
545 + $rand_id_prefix3 = '-' . MainWP_Utility::gen_rand_id();
546 + }
547 +
548 + ++$rendered_count;
549 +
550 + ?>
551 + <div id="mainwp-select-sites-body<?php echo esc_attr( $rand_id_prefix3 ); ?>" class="mainwp-select-sites-items-body">
552 + <div class="ui relaxed selection list mainwp-select-groups-list" id="mainwp-select-groups-list<?php echo esc_attr( $rand_id_prefix3 ); // empty prefix to ensure compatibility with extensions. ?>">
553 + <?php
554 + if ( empty( $groups ) ) {
555 + ?>
556 + <h2 class="ui icon header">
557 + <i class="folder open outline icon"></i>
558 + <div class="content"><?php esc_html_e( 'No Tags created!', 'mainwp' ); ?></div>
559 + <div class="ui divider hidden"></div>
560 + <a href="admin.php?page=ManageGroups" class="ui green button basic"><?php esc_html_e( 'Create Tags', 'mainwp' ); ?></a>
561 + </h2>
562 + <?php
563 + }
564 + foreach ( $groups as $group ) {
565 + $selected = in_array( $group->id, $selected_groups );
566 + ?>
567 + <div class="mainwp_selected_groups_item ui item <?php echo esc_html( $type ); ?> <?php echo $selected ? 'selected_groups_item_checked' : ''; ?>">
568 + <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"' : ''; ?> />
569 + <label for="selected_groups_<?php echo esc_attr( $group->id ); ?>">
570 + <?php echo esc_html( stripslashes( $group->name ) ); ?>
571 + </label>
572 + </div>
573 + <?php
574 + }
575 + ?>
576 + </div>
577 + </div>
578 + <?php
579 + /**
580 + * Action: mainwp_after_select_groups_list
581 + *
582 + * Fires after the Select Groups list.
583 + *
584 + * @param object $groups Object containing groups info.
585 + *
586 + * @since 4.1
587 + */
588 + do_action( 'mainwp_after_select_groups_list', $groups );
589 + }
590 +
591 + /**
592 + * Method render_top_header()
593 + *
594 + * Render top header.
595 + *
596 + * @param array $params Page parameters.
597 + *
598 + * @uses \MainWP\Dashboard\MainWP_DB::query()
599 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
600 + * @uses \MainWP\Dashboard\MainWP_Menu::render_left_menu()
601 + */
602 + public static function render_top_header( $params = array() ) { // phpcs:ignore -- NOSONAR - complex.
603 +
604 + $before_title = isset( $params['before_title'] ) ? $params['before_title'] . ' ' : '';
605 + $title = isset( $params['title'] ) ? $params['title'] : '';
606 +
607 + $which = isset( $params['which'] ) ? $params['which'] : '';
608 +
609 + /**
610 + * Filter: mainwp_header_title
611 + *
612 + * Filter the MainWP page title in the header element.
613 + *
614 + * @since 4.0
615 + */
616 + $title = apply_filters( 'mainwp_header_title', $title );
617 +
618 + $show_menu = true;
619 +
620 + if ( isset( $params['show_menu'] ) ) {
621 + $show_menu = $params['show_menu'];
622 + }
623 +
624 + $title = $before_title . $title;
625 +
626 + /**
627 + * Filter: mainwp_header_left
628 + *
629 + * Filter the MainWP header element left side content.
630 + *
631 + * @since 4.0
632 + */
633 + $left = apply_filters( 'mainwp_header_left', $title, $params );
634 +
635 + $right = static::render_header_actions();
636 +
637 + /**
638 + * Filter: mainwp_header_right
639 + *
640 + * Filter the MainWP header element right side content.
641 + *
642 + * @since 4.0
643 + */
644 + $right = apply_filters( 'mainwp_header_right', $right );
645 +
646 + $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
647 + if ( false === $sidebarPosition ) {
648 + $sidebarPosition = 1;
649 + }
650 +
651 + $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.name' ) );
652 +
653 + $count_sites = MainWP_DB::instance()->get_websites_count();
654 +
655 + // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
656 + if ( empty( $count_sites ) && ! isset( $_GET['do'] ) ) {
657 + static::render_modal_no_sites_note();
658 + }
659 +
660 + $siteViewMode = MainWP_Utility::get_siteview_mode();
661 +
662 + $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
663 +
664 + $tour_id = '';
665 + if ( 'mainwp_tab' === $page ) {
666 + $tour_id = '30496';
667 + } elseif ( 'managesites' === $page ) {
668 + if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) {
669 + $tour_id = '13210';
670 + } elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) {
671 + $tour_id = '60206';
672 + } elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
673 + if ( 'grid' === $siteViewMode ) {
674 + $tour_id = '27217';
675 + } else {
676 + $tour_id = '29331';
677 + }
678 + }
679 + } elseif ( 'MonitoringSites' === $page ) {
680 + $tour_id = '29003';
681 + } elseif ( 'ManageClients' === $page ) {
682 + if ( isset( $_GET['client_id'] ) ) {
683 + $tour_id = '28258';
684 + } else {
685 + $tour_id = '28240';
686 + }
687 + } elseif ( 'ClientAddNew' === $page ) {
688 + if ( isset( $_GET['client_id'] ) ) {
689 + $tour_id = '28962';
690 + } else {
691 + $tour_id = '28256';
692 + }
693 + } elseif ( 'ClientAddField' === $page ) {
694 + $tour_id = '28257';
695 + } elseif ( 'PluginsManage' === $page ) {
696 + $tour_id = '28510';
697 + } elseif ( 'ManageGroups' === $page ) {
698 + $tour_id = '27275';
699 + } elseif ( 'UpdatesManage' === $page ) {
700 + $tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
701 + if ( 'plugins-updates' === $tab ) {
702 + $tour_id = '28259';
703 + } elseif ( 'themes-updates' === $tab ) {
704 + $tour_id = '28447';
705 + } elseif ( 'wordpress-updates' === $tab ) {
706 + $tour_id = '29005';
707 + } elseif ( 'translations-updates' === $tab ) {
708 + $tour_id = '29007';
709 + } elseif ( 'abandoned-plugins' === $tab ) {
710 + $tour_id = '29008';
711 + } elseif ( 'abandoned-themes' === $tab ) {
712 + $tour_id = '29009';
713 + } elseif ( 'plugin-db-updates' === $tab ) {
714 + $tour_id = '33161';
715 + } else {
716 + $tour_id = '28259';
717 + }
718 + } elseif ( 'PluginsInstall' === $page ) {
719 + $tour_id = '29011';
720 + } elseif ( 'PluginsAutoUpdate' === $page ) {
721 + $tour_id = '29015';
722 + } elseif ( 'PluginsIgnore' === $page ) {
723 + $tour_id = '29018';
724 + } elseif ( 'PluginsIgnoredAbandoned' === $page ) {
725 + $tour_id = '29329';
726 + } elseif ( 'ThemesManage' === $page ) {
727 + $tour_id = '28511';
728 + } elseif ( 'ThemesInstall' === $page ) {
729 + $tour_id = '29010';
730 + } elseif ( 'ThemesAutoUpdate' === $page ) {
731 + $tour_id = '29016';
732 + } elseif ( 'ThemesIgnore' === $page ) {
733 + $tour_id = '29019';
734 + } elseif ( 'ThemesIgnoredAbandoned' === $page ) {
735 + $tour_id = '29330';
736 + } elseif ( 'UserBulkManage' === $page ) {
737 + $tour_id = '28574';
738 + } elseif ( 'UserBulkAdd' === $page ) {
739 + $tour_id = '28575';
740 + } elseif ( 'PasswordPolicy' === $page ) {
741 + $tour_id = '80725';
742 + } elseif ( 'BulkImportUsers' === $page ) {
743 + $tour_id = '28736';
744 + } elseif ( 'UpdateAdminPasswords' === $page ) {
745 + $tour_id = '28737';
746 + } elseif ( 'PostBulkManage' === $page ) {
747 + $tour_id = '28796';
748 + } elseif ( 'PostBulkAdd' === $page ) {
749 + $tour_id = '28799';
750 + } elseif ( 'PageBulkManage' === $page ) {
751 + $tour_id = '29045';
752 + } elseif ( 'PageBulkAdd' === $page ) {
753 + $tour_id = '29048';
754 + } elseif ( 'Extensions' === $page ) {
755 + $tour_id = '28800';
756 + } elseif ( 'Settings' === $page ) {
757 + $tour_id = '28883';
758 + } elseif ( 'SettingsAdvanced' === $page ) {
759 + $tour_id = '28886';
760 + } elseif ( 'SettingsEmail' === $page ) {
761 + $tour_id = '29054';
762 + } elseif ( 'MonitoringSettings' === $page ) {
763 + $tour_id = '80726';
764 + } elseif ( 'MainWPTools' === $page ) {
765 + $tour_id = '29272';
766 + } elseif ( 'RESTAPI' === $page ) {
767 + $tour_id = '29273';
768 + } elseif ( 'ApplicationPasswords' === $page ) {
769 + $tour_id = '80727';
770 + } elseif ( 'ServerInformation' === $page ) {
771 + $tour_id = '28873';
772 + } elseif ( 'ServerInformationCron' === $page ) {
773 + $tour_id = '28874';
774 + } elseif ( 'ErrorLog' === $page ) {
775 + $tour_id = '28876';
776 + } elseif ( 'ActionLogs' === $page ) {
777 + $tour_id = '28877';
778 + } elseif ( 'Extensions-Mainwp-Jetpack-Protect-Extension' === $page ) {
779 + $tour_id = '31700';
780 + } elseif ( 'Extensions-Mainwp-Jetpack-Scan-Extension' === $page ) {
781 + $tour_id = '31694';
782 + } elseif ( 'Extensions-Termageddon-For-Mainwp' === $page ) {
783 + $tour_id = '32104';
784 + } elseif ( 'Extensions-Advanced-Uptime-Monitor-Extension' === $page ) {
785 + $tour_id = '32149';
786 + } elseif ( 'Extensions-Mainwp-Custom-Dashboard-Extension' === $page ) {
787 + $tour_id = '32150';
788 + } elseif ( 'Extensions-Mainwp-Updraftplus-Extension' === $page ) {
789 + $tour_id = '32151';
790 + } elseif ( 'Extensions-Mainwp-Sucuri-Extension' === $page ) {
791 + $tour_id = '32152';
792 + } elseif ( 'Extensions-Mainwp-Clean-And-Lock-Extension' === $page ) {
793 + $tour_id = '32153';
794 + } elseif ( 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' === $page ) {
795 + $tour_id = '32851';
796 + } elseif ( 'Extensions-Mainwp-Buddy-Extension' === $page ) {
797 + $tour_id = '33064';
798 + } elseif ( 'Extensions-Mainwp-Backwpup-Extension' === $page ) {
799 + $tour_id = '32923';
800 + } elseif ( 'Extensions-Mainwp-Ssl-Monitor-Extension' === $page ) {
801 + $tour_id = '33164';
802 + } elseif ( 'Extensions-Mainwp-Cache-Control-Extension' === $page ) {
803 + $tour_id = '33167';
804 + } elseif ( 'Extensions-Mainwp-Maintenance-Extension' === $page ) {
805 + $tour_id = '33301';
806 + } elseif ( 'Extensions-Mainwp-Domain-Monitor-Extension' === $page ) {
807 + $tour_id = '66031';
808 + } elseif ( 'Extensions-Mainwp-Favorites-Extension' === $page ) {
809 + $tour_id = '66035';
810 + } elseif ( 'Extensions-Mainwp-Regression-Testing-Extension' === $page ) {
811 + $tour_id = '66037';
812 + }
813 + // phpcs:enable
814 + ?>
815 + <div class="ui segment right sites sidebar" style="padding:0px" id="mainwp-sites-menu-sidebar">
816 + <div class="ui segment" style="margin-bottom:0px">
817 + <div class="ui header"><?php esc_html_e( 'Quick Site Shortcuts', 'mainwp' ); ?></div>
818 + </div>
819 + <div class="ui fitted divider"></div>
820 + <div class="ui segment" style="margin-bottom:0px">
821 + <div class="ui mini fluid icon input" <?php echo $websites ? '' : 'style="display: none;"'; ?> >
822 + <input type="text" id="mainwp-sites-menu-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" />
823 + <i class="filter icon"></i>
824 + </div>
825 + </div>
826 + <div class="ui fluid vertical accordion menu" id="mainwp-sites-sidebar-menu" style="margin-top:0px;border-radius:0px;box-shadow:none;">
827 + <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
828 + <div class="item mainwp-site-menu-item">
829 + <div class="title">
830 + <i class="dropdown icon"></i>
831 + <label><?php echo esc_html( $website->name ); ?></label>
832 + </div>
833 + <div class="content">
834 + <div class="ui hiden divider"></div>
835 + <div class="ui fluid relaxed list">
836 + <div class="item" >
837 + <i class="grid layout icon"></i>
838 + <a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website->id ); ?>"><?php esc_html_e( 'Operations', 'mainwp' ); ?></a>
839 + </div>
840 + <div class="item" >
841 + <i class="redo icon"></i>
842 + <a href="<?php echo 'admin.php?page=managesites&updateid=' . intval( $website->id ); ?>"><?php esc_html_e( 'Updates', 'mainwp' ); ?></a>
843 + </div>
844 + <div class="item">
845 + <i class="edit icon"></i>
846 + <a href="<?php echo 'admin.php?page=managesites&id=' . intval( $website->id ); ?>"><?php esc_html_e( 'Settings', 'mainwp' ); ?></a>
847 + </div>
848 + <div class="item">
849 + <i class="sync alternate icon"></i>
850 + <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>
851 + </div>
852 + <div class="item">
853 + <i class="shield icon"></i>
854 + <a href="<?php echo 'admin.php?page=managesites&scanid=' . intval( $website->id ); ?>"><?php esc_html_e( 'Site Hardening', 'mainwp' ); ?></a>
855 + </div>
856 + <div class="item">
857 + <i class="sign in icon"></i>
858 + <a target="_blank" href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); //phpcs:ignore -- ok. ?>"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a>
859 + </div>
860 + <div class="item">
861 + <i class="globe icon"></i>
862 + <a target="_blank" href="<?php echo esc_url( $website->url ); ?>"><?php esc_html_e( 'Visit Site', 'mainwp' ); ?></a>
863 + </div>
864 +
865 + <?php
866 + /**
867 + * Action: mainwp_quick_sites_shortcut
868 + *
869 + * Adds a new shortcut item in the Quick Sites Shortcuts sidebar menu.
870 + *
871 + * @param array $website Array containing the child site data.
872 + *
873 + * Suggested HTML markup:
874 + *
875 + * <a class="item" href="your custom URL">
876 + * <i class="your custom icon"></i>
877 + * Your custom label text
878 + * </a>
879 + *
880 + * @since 4.1
881 + */
882 + do_action( 'mainwp_quick_sites_shortcut', $website );
883 + ?>
884 + </div>
885 + </div>
886 + </div>
887 + <?php } ?>
888 + </div>
889 + </div>
890 + <div class="ui segment right wide help sidebar" id="mainwp-documentation-sidebar">
891 + <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>
892 + <div class="ui hidden divider"></div>
893 + <div class="ui info message" style="display:block!important;">
894 + <?php /* translators: 1: Opening anchor tag for privacy policy link, 2: Closing anchor tag. */ 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>' ); ?>
895 + </div>
896 + <div class="ui hidden divider"></div>
897 + <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
898 + <p><?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?></p>
899 + <p><?php esc_html_e( 'Click the Start Page Tour button to start the guided tour for the current page.', 'mainwp' ); ?></p>
900 + <div class="ui hidden divider"></div>
901 + <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>
902 +
903 + <?php endif; ?>
904 + <div class="ui header"><?php esc_html_e( 'MainWP Knowledge Base', 'mainwp' ); ?></div>
905 + <div class="ui hidden divider"></div>
906 + <?php
907 + /**
908 + * Action: mainwp_help_sidebar_content
909 + *
910 + * Fires Help sidebar content
911 + *
912 + * @since 4.0
913 + */
914 + do_action( 'mainwp_help_sidebar_content' );
915 + ?>
916 + <div class="ui hidden divider"></div>
917 + <a href="https://docs.mainwp.com/" class="ui big green fluid button"><?php esc_html_e( 'Help Documentation', 'mainwp' ); // NOSONAR - noopener - open safe. ?></a>
918 + <div class="ui hidden divider"></div>
919 + <div id="mainwp-sticky-help-button" class="" style="position: absolute; bottom: 1em; left: 1em; right: 1em;">
920 + <a href="https://community.mainwp.com/" target="_blank" class="ui fluid button"><?php esc_html_e( 'Still Need Help?', 'mainwp' ); ?></a>
921 + </div>
922 + </div>
923 + <?php
924 + /**
925 + * Action: mainwp_before_mainwp_content_wrap
926 + *
927 + * Fires before the #mainwp-content-wrap element.
928 + *
929 + * @param array $websites Array containing the child site data.
930 + *
931 + * @since 4.1
932 + */
933 + do_action( 'mainwp_before_mainwp_content_wrap', $websites );
934 + global $wp_version;
935 + $fix_menu_overflow = 1;
936 + if ( version_compare( $wp_version, '5.5.3', '>' ) ) {
937 + $fix_menu_overflow = 2;
938 + }
939 +
940 + if ( 'page_clients_overview' !== $which ) {
941 + ?>
942 +
943 + <div class="ui modal" id="mainwp-overview-screen-options-modal">
944 + <i class="close icon"></i>
945 + <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
946 + <div class="content ui form">
947 + <?php
948 + /**
949 + * Action: mainwp_overview_screen_options_top
950 + *
951 + * Fires at the top of the Sceen Options modal on the Operations page.
952 + *
953 + * @since 4.1
954 + */
955 + do_action( 'mainwp_overview_screen_options_top' );
956 + ?>
957 + <form method="POST" action="" name="mainwp_overview_screen_options_form" id="mainwp-overview-screen-options-form">
958 + <?php self::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
959 + <input type="hidden" name="wp_nonce" value="<?php echo esc_html( wp_create_nonce( 'MainWPScrOptions' ) ); ?>" />
960 + <?php static::render_screen_options( false ); ?>
961 + <?php
962 + /**
963 + * Action: mainwp_overview_screen_options_bottom
964 + *
965 + * Fires at the bottom of the Sceen Options modal on the Operations page.
966 + *
967 + * @since 4.1
968 + */
969 + do_action( 'mainwp_overview_screen_options_bottom' );
970 + ?>
971 + </div>
972 + <div class="actions">
973 + <div class="ui two columns grid">
974 + <div class="left aligned column">
975 + <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>
976 + </div>
977 + <div class="ui right aligned column">
978 + <input type="submit" class="ui green button" id="submit-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
979 + </div>
980 + </div>
981 + </div>
982 +
983 + <input type="hidden" name="reset_overview_settings" value="" />
984 + </form>
985 + </div>
986 + <?php } ?>
987 + <?php
988 + $wrap_class = isset( $params['wrap_class'] ) ? $params['wrap_class'] : '';
989 + ?>
990 + <?php
991 + /**
992 + * Action: mainwp_before_header
993 + *
994 + * Fires before the MainWP header element.
995 + *
996 + * @param array $websites Array containing the child site data.
997 + *
998 + * @since 4.0
999 + */
1000 + do_action( 'mainwp_before_header', $websites );
1001 + ?>
1002 + <div id="mainwp-top-header">
1003 + <div class="ui grid">
1004 + <div class="center aligned middle aligned column" style="width:72px!important;padding:0!important;">
1005 + <a href="
1006 + <?php
1007 + /**
1008 + * Filter: mainwp_menu_logo_href
1009 + *
1010 + * Filters the Logo link.
1011 + *
1012 + * @since 4.1.4
1013 + */
1014 + echo esc_url( apply_filters( 'mainwp_menu_logo_href', admin_url( 'admin.php?page=mainwp_tab' ) ) );
1015 + ?>
1016 + ">
1017 + <img src="
1018 + <?php
1019 + /**
1020 + * Filter: mainwp_menu_logo_src
1021 + *
1022 + * Filters the Logo src attribute.
1023 + *
1024 + * @since 4.1
1025 + */
1026 + echo esc_url( apply_filters( 'mainwp_menu_logo_src', MAINWP_PLUGIN_URL . 'assets/images/mainwp-icon.svg' ) );
1027 + ?>
1028 + " alt="
1029 + <?php
1030 + /**
1031 + * Filter: mainwp_menu_logo_alt
1032 + *
1033 + * Filters the Logo alt attribute.
1034 + *
1035 + * @since 4.1
1036 + */
1037 + echo esc_html( apply_filters( 'mainwp_menu_logo_alt', 'MainWP' ) );
1038 + ?>
1039 + " id="mainwp-navigation-icon" />
1040 + </a>
1041 + </div>
1042 + <div class="left aligned middle aligned column" style="width:calc( 50% - 72px )!important">
1043 + <h1 class="mainwp-page-title ui small header"><?php echo $left; // phpcs:ignore WordPress.Security.EscapeOutput ?></h1>
1044 + </div>
1045 + <div class="right aligned middle aligned column" style="width:50%!important">
1046 + <?php echo $right; // phpcs:ignore WordPress.Security.EscapeOutput ?>
1047 + </div>
1048 + </div>
1049 + </div>
1050 + <script type="text/javascript">
1051 + jQuery( document ).ready( function($) {
1052 + $('#mainwp-top-header').prevAll().each(function () {
1053 + let strId=$(this).attr('id');
1054 + if(strId?.includes('mainwp')){
1055 + return;
1056 + }
1057 + let strCls=$(this).attr('class');
1058 + if(strCls?.includes('mainwp')){
1059 + return;
1060 + }
1061 + if($(this).is(':visible')){
1062 + $(this).prependTo('.mainwp-content-wrap'); // to fix display.
1063 + $(this).css( 'margin-left', '0px' );
1064 + }
1065 + });
1066 + });
1067 + </script>
1068 +
1069 + <?php
1070 + if ( $show_menu ) {
1071 + MainWP_Menu::render_left_menu();
1072 + MainWP_Menu::render_mobile_menu();
1073 + }
1074 + ?>
1075 + <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 ); ?>">
1076 + <?php if ( MainWP_Demo_Handle::is_demo_mode() ) : ?>
1077 + <div class="ui segment" style="background-color:#1c1d1b!important;margin-bottom:0px;">
1078 + <div class="ui inverted accordion" id="mainwp_demo_mode_accordion" style="background-color:#1c1d1b;">
1079 + <div class="title">
1080 + <i class="dropdown icon"></i>
1081 + <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
1082 + <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>
1083 + <?php } else { ?>
1084 + <strong style="color:#fff;font-size:16px;"><?php esc_html_e( 'You are in Demo Mode. Click here for more info', 'mainwp' ); ?></strong>
1085 + <?php } ?>
1086 + </div>
1087 + <div class="content">
1088 + <br/>
1089 + <div class="ui stackable grid">
1090 + <div class="eleven wide middle aligned column">
1091 + <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
1092 + <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>
1093 + <?php } ?>
1094 + <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>
1095 + </div>
1096 + <div class="five wide middle aligned column">
1097 + <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
1098 + <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>
1099 + <?php } else { ?>
1100 + <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>
1101 + <?php } ?>
1102 + </div>
1103 + </div>
1104 + <br/>
1105 + </div>
1106 + </div>
1107 + </div>
1108 + <script type="text/javascript">
1109 + jQuery( '#mainwp_demo_mode_accordion' ).accordion();
1110 + </script>
1111 + <?php endif; ?>
1112 +
1113 +
1114 + <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
1115 + <script type="text/javascript">
1116 + jQuery( document ).ready( function() {
1117 + jQuery( '#mainwp-start-page-tour-button' ).on( 'click', function() {
1118 + let tourId = jQuery( this ).attr( 'tour-id' );
1119 + jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
1120 + if(tourId){
1121 + window.USETIFUL.tour.start( Number.parseInt( tourId ) );
1122 + } else {
1123 + console.warn('Error: empty tour ID. Please set valid tour ID.');
1124 + }
1125 + } );
1126 + jQuery( '#mainwp-interface-tour-button' ).on( 'click', function() {
1127 + jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
1128 + window.USETIFUL.tour.start( 13282 );
1129 + } );
1130 + } );
1131 + </script>
1132 + <?php endif; ?>
1133 +
1134 + <?php
1135 + if ( isset( $_GET['message'] ) && ( 'qsw-import' === $_GET['message'] || 'enable-demo-mode' === $_GET['message'] ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1136 + ?>
1137 + <script type= 'text/javascript'>
1138 + let _count_retry = 0;
1139 + _try_start_usetiful_tour = function () {
1140 + setTimeout(
1141 + function () {
1142 + try {
1143 + window.USETIFUL.tour.start( Number.parseInt( 40279 ) );
1144 + } catch ( e ) {
1145 + if ( _count_retry < 10 ) {
1146 + _count_retry++;
1147 + _try_start_usetiful_tour();
1148 + }
1149 + }
1150 + },
1151 + 1000
1152 + );
1153 + }
1154 + jQuery(document).ready(
1155 + function () {
1156 + _try_start_usetiful_tour();
1157 + }
1158 + );
1159 + </script>
1160 + <?php
1161 + endif;
1162 +
1163 + $fix_dom_issue_for_wp_editor = isset( $_GET['page'] ) && 'Extensions-Mainwp-Pro-Reports-Extension' === $_GET['page'] && isset( $_GET['tab'] ) && 'report' === $_GET['tab'] ? true : false; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended --NOSONAR - ok.
1164 +
1165 + if ( $fix_dom_issue_for_wp_editor ) {
1166 + ?>
1167 + <style type="text/css">
1168 + .mainwp-overlay-open #mainwp-main-mobile-navigation-container{
1169 + top: 58px !important;
1170 + }
1171 + </style>
1172 + <script type="text/javascript">
1173 + jQuery(function ($) {
1174 + const $body = $('body');
1175 + const $flyout = $('#mainwp-main-mobile-navigation-container');
1176 + const $overlay = $('#mainwp-overlay');
1177 +
1178 + // Ensure elements are in body (safe move).
1179 + if ($flyout.parent()[0] !== document.body) {
1180 + $flyout.appendTo('body');
1181 + $body.addClass('pushable');
1182 + }
1183 + if ($overlay.parent()[0] !== document.body) {
1184 + $overlay.appendTo('body');
1185 + $body.addClass('pushable');
1186 + }
1187 +
1188 + // Toggle
1189 + $('#mainwp-mobile-menu-trigger').on('click', function () {
1190 + $body.toggleClass('mainwp-overlay-open');
1191 +
1192 + $(this).find('i.icon')
1193 + .toggleClass('bars times');
1194 + $flyout.toggleClass('overlay visible');
1195 + $overlay.toggleClass('pusher dimmed');
1196 + });
1197 +
1198 + // Close on overlay click
1199 + $overlay.on('click', function () {
1200 + $body.removeClass('mainwp-overlay-open');
1201 + $flyout.removeClass('overlay visible');
1202 + $overlay.removeClass('pusher dimmed');
1203 +
1204 + $('#mainwp-mobile-menu-trigger i.icon')
1205 + .removeClass('times')
1206 + .addClass('bars');
1207 + });
1208 +
1209 + $(document).on('keydown', function (e) {
1210 + if (e.key === 'Escape') {
1211 + $('body').removeClass('mainwp-overlay-open');
1212 + $flyout.removeClass('overlay visible');
1213 + $overlay.removeClass('pusher dimmed');
1214 + $('#mainwp-mobile-menu-trigger i.icon')
1215 + .removeClass('times')
1216 + .addClass('bars');
1217 + }
1218 + });
1219 + });
1220 + </script>
1221 + <?php
1222 + }
1223 + ?>
1224 +
1225 + <script type="text/javascript">
1226 + jQuery( document ).ready( function ($) {
1227 +
1228 + let pulse = jQuery( '#mainwp-screen-options-pulse-control' ).val();
1229 +
1230 + if (pulse == 1) {
1231 + jQuery('#mainwp-top-header .cog.icon').parent('.button').transition({
1232 + animation: 'pulse',
1233 + duration: 1000,
1234 + interval: 5500,
1235 + onStart: function () {
1236 + jQuery(this).removeClass('basic').addClass('green');
1237 + },
1238 + onComplete: function () {
1239 + jQuery(this).addClass('basic').removeClass('green');
1240 + }
1241 + });
1242 + }
1243 +
1244 + jQuery( '#mainwp-sites-menu-sidebar' ).prependTo( 'body' );
1245 + jQuery( '#mainwp-documentation-sidebar' ).prependTo( 'body' );
1246 +
1247 + jQuery( '#mainwp-help-sidebar' ).on( 'click', function() {
1248 + jQuery( '.ui.help.sidebar' ).sidebar( {
1249 + transition: 'overlay'
1250 + } );
1251 + jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' );
1252 + return false;
1253 + } );
1254 + jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() {
1255 + jQuery( '.ui.sites.sidebar' ).sidebar( {
1256 + transition: 'overlay',
1257 + 'onVisible': function() {
1258 + jQuery( '#mainwp-sites-menu-filter' ).focus();
1259 + }
1260 + } );
1261 + jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' );
1262 + return false;
1263 + } );
1264 + jQuery( '#mainwp-sites-sidebar-menu' ).accordion();
1265 + jQuery( '#mainwp-sites-sidebar-menu' ).on( 'click', '.mainwp-site-menu-item', function ( e ) {
1266 + if ( ! jQuery( e.target ).closest( '.content' ).length && ! jQuery( e.target ).closest( '.title' ).length ) {
1267 + jQuery( this ).find( '.title' ).first().trigger( 'click' );
1003 1268 }
1004 - jQuery(document).ready(
1005 - function () {
1006 - _try_start_usetiful_tour();
1007 - }
1008 - );
1009 - </script>
1010 - <?php
1011 - endif;
1012 - ?>
1269 + } );
1013 1270
1014 - <script type="text/javascript">
1015 - jQuery( document ).ready( function () {
1271 + <?php if ( ! $fix_dom_issue_for_wp_editor ) { ?>
1016 1272
1017 - jQuery( '#mainwp-jump-to-site-overview-dropdown' ).on( 'change', function() {
1018 - var site_id = jQuery( this ).val();
1019 - window.location.href = 'admin.php?page=managesites&dashboard=' + site_id;
1020 - } );
1273 + if( jQuery( '#mainwp-main-mobile-navigation-container' ).length ){
1274 + jQuery('<div class="pusher"></div>')
1275 + .append($('#wpwrap'))
1276 + .prependTo('body');
1277 + jQuery( '#mainwp-main-mobile-navigation-container' ).prependTo( 'body' );
1278 + setTimeout(function () {
1279 + // Initialize flyout
1280 + $('#mainwp-main-mobile-navigation-container.ui.flyout')
1281 + .flyout({
1282 + dimPage: true,
1283 + onShow: function() {
1284 + $(this).css({
1285 + 'top': '58px',
1286 + });
1287 + $('#mainwp-mobile-menu-trigger').find('i.icon').removeClass('bars').addClass('times');
1288 + },
1289 + onHide: function() {
1290 + $('#mainwp-mobile-menu-trigger').find('i.icon').removeClass('times').addClass('bars');
1291 + }
1292 + });
1293 + }, 2000);
1021 1294
1022 - jQuery( '#mainwp-sites-menu-sidebar' ).prependTo( 'body' );
1023 - jQuery( '#mainwp-documentation-sidebar' ).prependTo( 'body' );
1024 - jQuery( 'body > div#wpwrap' ).addClass( 'pusher' );
1295 + // Trigger button
1296 + $('#mainwp-mobile-menu-trigger').on('click', function() {
1297 + $('#mainwp-main-mobile-navigation-container.ui.flyout').flyout('toggle');
1298 + });
1299 + }
1300 + <?php } ?>
1301 + } );
1302 + </script>
1025 1303
1026 - jQuery( '.ui.sticky' ).sticky( {
1027 - pushing: false,
1028 - } ).sticky();
1304 + <?php static::render_help_modal(); ?>
1305 + <?php static::render_loader_element(); ?>
1306 + <?php
1307 + ob_start();
1308 + /**
1309 + * Action: mainwp_after_header
1310 + *
1311 + * Fires after the MainWP header element.
1312 + *
1313 + * @param array $websites Array containing the child site data.
1314 + *
1315 + * @since 4.0
1316 + */
1317 + do_action( 'mainwp_after_header', $websites );
1318 + $after_header_content = ob_get_clean();
1319 + if ( ! empty( trim( $after_header_content ) ) ) {
1320 + $has_extension_update_failure_notice = false !== strpos( $after_header_content, 'mainwp-extension-update-failure-notice' );
1321 + $admin_notices_style = $has_extension_update_failure_notice ? 'padding-bottom:0 !important;' : '';
1322 + $admin_notices_class = $has_extension_update_failure_notice ? ' mainwp-extension-update-failure-notice-segment' : '';
1323 + ?>
1324 + <div class="ui padded segment<?php echo esc_attr( $admin_notices_class ); ?>" id="mainwp-admin-notices-segment" style="<?php echo esc_attr( $admin_notices_style ); ?>">
1325 + <?php echo $after_header_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1326 + </div>
1327 + <?php
1328 + }
1329 + ?>
1330 + <?php
1331 + }
1029 1332
1030 - jQuery( '#mainwp-help-sidebar' ).on( 'click', function() {
1031 - jQuery( '.ui.help.sidebar' ).sidebar( {
1032 - transition: 'overlay'
1033 - } );
1034 - jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' );
1035 - return false;
1036 - } );
1037 - jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() {
1038 - jQuery( '.ui.sites.sidebar' ).sidebar( {
1039 - transition: 'overlay',
1040 - 'onVisible': function() {
1041 - jQuery( '#mainwp-sites-menu-filter' ).focus();
1042 - }
1043 - } );
1044 - jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' );
1045 - return false;
1046 - } );
1047 - jQuery( '#mainwp-sites-sidebar-menu' ).accordion();
1048 - } );
1049 - </script>
1050 - <?php
1051 - /**
1052 - * Action: mainwp_after_header
1053 - *
1054 - * Fires after the MainWP header element.
1055 - *
1056 - * @param array $websites Array containing the child site data.
1057 - *
1058 - * @since 4.0
1059 - */
1060 - do_action( 'mainwp_after_header', $websites );
1061 - ?>
1062 - <?php
1063 - }
1064 1333
1334 + /**
1335 + * Method render_showhide_columns_settings()
1336 + *
1337 + * Render show/hide columns settings.
1338 + *
1339 + * @param array $cols Columns.
1340 + * @param array $show_columns Show Columns.
1341 + * @param string $what what.
1342 + */
1343 + public static function render_showhide_columns_settings( $cols, $show_columns, $what ) {
1344 + ?>
1345 + <div class="ui grid field">
1346 + <label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label>
1347 + <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">
1348 + <ul>
1349 + <?php
1350 + foreach ( $cols as $name => $title ) {
1351 + $_selected = '';
1352 + if ( ! isset( $show_columns[ $name ] ) || 1 === (int) $show_columns[ $name ] ) {
1353 + $_selected = 'checked';
1354 + }
1355 + ?>
1356 + <li>
1357 + <div class="ui checkbox">
1358 + <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 ); ?>">
1359 + <label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
1360 + </div>
1361 + <input type="hidden" name="mainwp_columns_name[]" value="<?php echo esc_attr( $name ); ?>">
1362 + </li>
1363 + <?php
1364 + }
1365 + ?>
1366 + </ul>
1367 + </div>
1065 1368
1066 - /**
1067 - * Method render_showhide_columns_settings()
1068 - *
1069 - * Render show/hide columns settings.
1070 - *
1071 - * @param array $cols Columns.
1072 - * @param array $show_columns Show Columns.
1073 - * @param string $what what.
1074 - */
1075 - public static function render_showhide_columns_settings( $cols, $show_columns, $what ) {
1076 - ?>
1077 - <div class="ui grid field">
1078 - <label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label>
1079 - <div class="ten wide column" data-tooltip="<?php echo esc_attr_e( 'Select columns that you want to hide.', 'mainwp' ); ?> data-inverted="" data-position="top left">
1080 - <ul>
1081 - <?php
1082 - foreach ( $cols as $name => $title ) {
1083 - $_selected = '';
1084 - if ( ! isset( $show_columns[ $name ] ) || 1 === (int) $show_columns[ $name ] ) {
1085 - $_selected = 'checked';
1086 - }
1087 - ?>
1088 - <li>
1089 - <div class="ui checkbox">
1090 - <input type="checkbox" id="mainwp_show_column_<?php echo esc_attr( $name ); ?>" name="mainwp_show_columns[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
1091 - <label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
1092 - </div>
1093 - <input type="hidden" name="mainwp_columns_name[]" value="<?php echo esc_attr( $name ); ?>">
1094 - </li>
1095 - <?php
1096 - }
1097 - ?>
1098 - </ul>
1099 - </div>
1369 + </div>
1370 + <?php
1100 1371
1101 - </div>
1102 - <?php
1372 + $input_name = '';
1373 + if ( 'post' === $what ) {
1374 + $input_name = 'mainwp_manageposts_show_columns_settings';
1375 + } elseif ( 'page' === $what ) {
1376 + $input_name = 'mainwp_managepages_show_columns_settings';
1377 + } elseif ( 'user' === $what ) {
1378 + $input_name = 'mainwp_manageusers_show_columns_settings';
1379 + }
1103 1380
1104 - $input_name = '';
1105 - if ( 'post' === $what ) {
1106 - $input_name = 'mainwp_manageposts_show_columns_settings';
1107 - } elseif ( 'page' === $what ) {
1108 - $input_name = 'mainwp_managepages_show_columns_settings';
1109 - } elseif ( 'user' === $what ) {
1110 - $input_name = 'mainwp_manageusers_show_columns_settings';
1111 - }
1381 + if ( ! empty( $input_name ) ) {
1382 + ?>
1383 + <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1384 + <?php
1385 + }
1386 + }
1112 1387
1113 - if ( ! empty( $input_name ) ) {
1114 - ?>
1115 - <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1116 - <?php
1117 - }
1118 - }
1388 + /**
1389 + * Method render_second_top_header()
1390 + *
1391 + * Render second top header.
1392 + *
1393 + * @param string $which Current page.
1394 + *
1395 + * @return void Render second top header html.
1396 + */
1397 + public static function render_second_top_header( $which = '' ) {
1119 1398
1120 - /**
1121 - * Method render_second_top_header()
1122 - *
1123 - * Render second top header.
1124 - *
1125 - * @param string $which Current page.
1126 - *
1127 - * @return void Render second top header html.
1128 - */
1129 - public static function render_second_top_header( $which = '' ) {
1399 + /**
1400 + * Action: mainwp_before_subheader
1401 + *
1402 + * Fires before the MainWP sub-header element.
1403 + *
1404 + * @since 4.0
1405 + */
1406 + do_action( 'mainwp_before_subheader' );
1407 + if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) {
1408 + ?>
1409 + <div class="mainwp-sub-header">
1410 + <?php
1411 + if ( 'overview' === $which ) {
1412 + ?>
1413 + <div class="ui stackable grid">
1414 + <div class="column full">
1415 + <?php static::gen_groups_sites_selection(); ?>
1416 + </div>
1417 + </div>
1418 + <?php
1419 + }
1420 + ?>
1421 + <?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?>
1422 + <?php
1423 + /**
1424 + * Action: mainwp_managesites_tabletop
1425 + *
1426 + * Fires at the table top on the Manage Sites and Monitoring page.
1427 + *
1428 + * @since 4.0
1429 + */
1430 + do_action( 'mainwp_managesites_tabletop' );
1431 + ?>
1130 1432
1131 - /**
1132 - * Action: mainwp_before_subheader
1133 - *
1134 - * Fires before the MainWP sub-header element.
1135 - *
1136 - * @since 4.0
1137 - */
1138 - do_action( 'mainwp_before_subheader' );
1139 - if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) {
1140 - ?>
1141 - <div class="mainwp-sub-header">
1142 - <?php
1143 - if ( 'overview' === $which ) {
1144 - ?>
1145 - <div class="ui stackable grid">
1146 - <div class="column full">
1147 - <?php self::gen_groups_sites_selection(); ?>
1148 - </div>
1149 - </div>
1150 - <?php
1151 - }
1152 - ?>
1153 - <?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?>
1154 - <?php
1155 - /**
1156 - * Action: mainwp_managesites_tabletop
1157 - *
1158 - * Fires at the table top on the Manage Sites and Monitoring page.
1159 - *
1160 - * @since 4.0
1161 - */
1162 - do_action( 'mainwp_managesites_tabletop' );
1163 - ?>
1433 + <?php else : ?>
1434 + <?php
1435 + /**
1436 + * Action: mainwp_subheader_actions
1437 + *
1438 + * Fires at the subheader element to hook available actions.
1439 + *
1440 + * @since 4.0
1441 + */
1442 + do_action( 'mainwp_subheader_actions' );
1443 + ?>
1444 + <?php endif; ?>
1445 + </div>
1446 + <?php
1447 + }
1448 + /**
1449 + * Action: mainwp_after_subheader
1450 + *
1451 + * Fires after the MainWP sub-header element.
1452 + *
1453 + * @since 4.0
1454 + */
1455 + do_action( 'mainwp_after_subheader' );
1456 + }
1164 1457
1165 - <?php else : ?>
1166 - <?php
1167 - /**
1168 - * Action: mainwp_subheader_actions
1169 - *
1170 - * Fires at the subheader element to hook available actions.
1171 - *
1172 - * @since 4.0
1173 - */
1174 - do_action( 'mainwp_subheader_actions' );
1175 - ?>
1176 - <?php endif; ?>
1177 - </div>
1178 - <?php
1179 - }
1180 - /**
1181 - * Action: mainwp_after_subheader
1182 - *
1183 - * Fires after the MainWP sub-header element.
1184 - *
1185 - * @since 4.0
1186 - */
1187 - do_action( 'mainwp_after_subheader' );
1188 - }
1458 + /**
1459 + * Method gen_groups_sites_selection()
1460 + *
1461 + * Generate group sites selection box.
1462 + *
1463 + * @return void Render group sites selection box.
1464 + *
1465 + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_manage_sites()
1466 + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_not_empty_groups()
1467 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1468 + * @uses \MainWP\Dashboard\MainWP_DB::query()
1469 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1470 + * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1471 + */
1472 + public static function gen_groups_sites_selection() {
1473 + $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' ) );
1474 + $websites = MainWP_DB::instance()->query( $sql );
1475 + $g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1476 + $s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1477 + ?>
1478 + <div class="column full wide">
1479 + <select id="mainwp_top_quick_jump_group" class="ui dropdown">
1480 + <option value="" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1481 + <option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1482 + <?php
1483 + $groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites();
1484 + foreach ( $groups as $group ) {
1485 + ?>
1486 + <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>
1487 + <?php
1488 + }
1489 + ?>
1490 + </select>
1491 + <select class="ui dropdown" id="mainwp_top_quick_jump_page">
1492 + <option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1493 + <option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1494 + <?php
1495 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1496 + ?>
1497 + <option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s === (int) $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo esc_html( stripslashes( $website->name ) ); ?></option>
1498 + <?php
1499 + }
1500 + ?>
1501 + </select>
1502 + </div>
1503 + <script type="text/javascript">
1504 + jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () {
1505 + let jumpid = jQuery( this ).val();
1506 + window.location = 'admin.php?page=managesites&g=' + jumpid;
1507 + } );
1508 + jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () {
1509 + let jumpid = jQuery( this ).val();
1510 + if ( jumpid == -1 )
1511 + window.location = 'admin.php?page=managesites&s=' + jumpid;
1512 + else
1513 + window.location = 'admin.php?page=managesites&dashboard=' + jumpid;
1514 + } );
1515 + </script>
1516 + <?php
1517 + MainWP_DB::free_result( $websites );
1518 + }
1189 1519
1190 - /**
1191 - * Method gen_groups_sites_selection()
1192 - *
1193 - * Generate group sites selection box.
1194 - *
1195 - * @return void Render group sites selection box.
1196 - *
1197 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_manage_sites()
1198 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_not_empty_groups()
1199 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1200 - * @uses \MainWP\Dashboard\MainWP_DB::query()
1201 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1202 - * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1203 - */
1204 - public static function gen_groups_sites_selection() {
1205 - $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
1206 - $websites = MainWP_DB::instance()->query( $sql );
1207 - $g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1208 - $s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1209 - ?>
1210 - <div class="column full wide">
1211 - <select id="mainwp_top_quick_jump_group" class="ui dropdown">
1212 - <option value="" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1213 - <option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1214 - <?php
1215 - $groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites();
1216 - foreach ( $groups as $group ) {
1217 - ?>
1218 - <option class="item" <?php echo ( $g === (int) $group->id ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $group->id ); ?>"><?php echo esc_html( stripslashes( $group->name ) ); ?></option>
1219 - <?php
1220 - }
1221 - ?>
1222 - </select>
1223 - <select class="ui dropdown" id="mainwp_top_quick_jump_page">
1224 - <option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1225 - <option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1226 - <?php
1227 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1228 - ?>
1229 - <option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s === (int) $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo esc_html( stripslashes( $website->name ) ); ?></option>
1230 - <?php
1231 - }
1232 - ?>
1233 - </select>
1234 - </div>
1235 - <script type="text/javascript">
1236 - jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () {
1237 - var jumpid = jQuery( this ).val();
1238 - window.location = 'admin.php?page=managesites&g=' + jumpid;
1239 - } );
1240 - jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () {
1241 - var jumpid = jQuery( this ).val();
1242 - if ( jumpid == -1 )
1243 - window.location = 'admin.php?page=managesites&s=' + jumpid;
1244 - else
1245 - window.location = 'admin.php?page=managesites&dashboard=' + jumpid;
1246 - } );
1247 - </script>
1248 - <?php
1249 - MainWP_DB::free_result( $websites );
1250 - }
1520 + /**
1521 + * Method render_header_actions()
1522 + *
1523 + * Render header action buttons,
1524 + * (Sync|Add|Options|Community|User|Updates).
1525 + *
1526 + * @return mixed $output Render header action buttons html.
1527 + *
1528 + * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1529 + */
1530 + public static function render_header_actions() { // phpcs:ignore -- NOSONAR - complex method.
1531 + $sites_count = MainWP_DB::instance()->get_websites_count();
1532 + $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1533 + $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1534 + $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
1535 + $current_user = get_current_user_id();
1536 + $custom_theme = MainWP_Settings::get_instance()->get_current_user_theme();
1537 + $screen = get_current_screen();
1538 + $show_command_palette_trigger = wp_script_is( 'wp-core-commands', 'enqueued' );
1539 + $command_palette_shortcut = '';
1540 + $command_palette_label = '';
1251 1541
1252 - /**
1253 - * Method render_header_actions()
1254 - *
1255 - * Render header action buttons,
1256 - * (Sync|Add|Options|Community|User|Updates).
1257 - *
1258 - * @return mixed $output Render header action buttons html.
1259 - *
1260 - * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1261 - */
1262 - public static function render_header_actions() { //phpcs:ignore -- complex method.
1263 - $sites_count = MainWP_DB::instance()->get_websites_count();
1264 - $website_id = '';
1265 - $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1266 - $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1267 - $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
1542 + if ( $show_command_palette_trigger ) {
1543 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Used only to mirror WordPress core shortcut labels.
1544 + $is_apple_os = (bool) preg_match( '/Macintosh|Mac OS X|Mac_PowerPC/i', $_SERVER['HTTP_USER_AGENT'] ?? '' );
1268 1545
1269 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1270 - $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
1271 - ob_start();
1272 - if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) :
1273 - $id = 0;
1274 - if ( isset( $_GET['dashboard'] ) ) {
1275 - $id = intval( $_GET['dashboard'] );
1276 - } elseif ( isset( $_GET['id'] ) ) {
1277 - $id = intval( $_GET['id'] );
1278 - } elseif ( isset( $_GET['updateid'] ) ) {
1279 - $id = intval( $_GET['updateid'] );
1280 - } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1281 - $id = intval( $_GET['emailsettingsid'] );
1282 - } elseif ( isset( $_GET['scanid'] ) ) {
1283 - $id = intval( $_GET['scanid'] );
1284 - }
1546 + $command_palette_shortcut = $is_apple_os
1547 + ? _x( '⌘K', 'keyboard shortcut to open the command palette', 'mainwp' )
1548 + : _x( 'Ctrl+K', 'keyboard shortcut to open the command palette', 'mainwp' );
1285 1549
1286 - $website = MainWP_DB::instance()->get_website_by_id( $id );
1287 - ?>
1288 - <?php if ( $id && $website && '' !== $website->sync_errors ) : ?>
1289 - <a href="#" class="mainwp-updates-overview-reconnect-site ui green icon button" siteid="<?php echo intval( $website->id ); ?>" data-position="bottom right" data-tooltip="Reconnect <?php echo esc_html( stripslashes( $website->name ) ); ?>" data-inverted=""><i class="undo alternate"></i></a>
1290 - <?php else : ?>
1291 - <a class="ui icon button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?>" id="mainwp-sync-sites" data-tooltip="<?php esc_attr_e( 'Get fresh data from your child sites.', 'mainwp' ); ?> data-inverted="" data-position="bottom right">
1292 - <i class="sync icon"></i>
1293 - </a>
1294 - <?php endif; ?>
1295 - <?php else : ?>
1296 - <span data-tooltip="<?php esc_attr_e( 'Click here to sync data now.', 'mainwp' ); ?>" data-inverted="" data-position="left center">
1297 - <a class="ui icon button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?> " id="mainwp-sync-sites">
1298 - <i class="sync alternate icon"></i>
1299 - </a>
1300 - </span>
1301 - <?php endif; ?>
1550 + /* translators: %s: Keyboard shortcut label. */
1551 + $command_palette_label = sprintf( esc_attr__( 'Open command palette (%s)', 'mainwp' ), $command_palette_shortcut );
1552 + }
1302 1553
1303 - <div class="ui icon top left pointing dropdown <?php echo ( empty( $sites_count ) ? 'green' : '' ); ?> button" id="mainwp-add-new-buttons">
1304 - <i class="plus icon"></i>
1305 - <div class="menu">
1306 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Website to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Add Website', 'mainwp' ); ?></a>
1307 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Client to your MainWP Dashboard', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=ClientAddNew' ) ); ?>"><?php esc_html_e( 'Add Client', 'mainwp' ); ?></a>
1308 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Cost to for tracking', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=CostTrackerAdd' ) ); ?>"><?php esc_html_e( 'Add Cost', 'mainwp' ); ?></a>
1309 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Post to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=PostBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Post', 'mainwp' ); ?></a>
1310 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Add a new Page to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Page', 'mainwp' ); ?></a>
1311 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Install a new Plugin to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsInstall' ) ); ?>"><?php esc_html_e( 'Install Plugin', 'mainwp' ); ?></a>
1312 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Install a new Theme to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=ThemesInstall' ) ); ?>"><?php esc_html_e( 'Install Theme', 'mainwp' ); ?></a>
1313 - <a class="item" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Create a new User to your child sites', 'mainwp' ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=UserBulkAdd' ) ); ?>"><?php esc_html_e( ' Create User', 'mainwp' ); ?></a>
1314 - </div>
1315 - </div>
1554 + if ( false === $custom_theme ) {
1555 + $compat_theme = null;
1556 + // to compatible with Custom Dashboard extension settings.
1557 + $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1558 + if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1559 + $compat_theme = $compat_settings['theme'];
1560 + }
1561 + if ( null !== $compat_theme ) {
1562 + $custom_theme = $compat_theme;
1563 + }
1564 + }
1565 + $themes_files = MainWP_Settings::get_instance()->get_custom_themes_files();
1566 + if ( empty( $themes_files ) ) {
1567 + $themes_files = array();
1568 + }
1316 1569
1317 - <?php if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) || isset( $_GET['cacheControlId'] ) ) : ?>
1318 - <?php if ( isset( $_GET['dashboard'] ) ) : ?>
1319 - <?php $website_id = intval( $_GET['dashboard'] ); ?>
1320 - <?php elseif ( isset( $_GET['updateid'] ) ) : ?>
1321 - <?php $website_id = intval( $_GET['updateid'] ); ?>
1322 - <?php elseif ( isset( $_GET['emailsettingsid'] ) ) : ?>
1323 - <?php $website_id = intval( $_GET['emailsettingsid'] ); ?>
1324 - <?php elseif ( isset( $_GET['scanid'] ) ) : ?>
1325 - <?php $website_id = intval( $_GET['scanid'] ); ?>
1326 - <?php elseif ( isset( $_GET['cacheControlId'] ) ) : ?>
1327 - <?php $website_id = intval( $_GET['cacheControlId'] ); ?>
1328 - <?php else : ?>
1329 - <?php $website_id = intval( $_GET['id'] ); ?>
1330 - <?php endif; ?>
1331 -
1332 - <?php endif; ?>
1333 - <?php if ( ( 'mainwp_tab' === $page ) || isset( $_GET['dashboard'] ) || in_array( $page, $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
1334 - <a id="mainwp-screen-options-button" class="ui button basic icon" onclick="jQuery( '#mainwp-overview-screen-options-modal' ).modal({allowMultiple:true}).modal( 'show' ); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_html_e( 'Page Settings', 'mainwp' ); ?>">
1335 - <i class="cog icon"></i>
1336 - </a>
1337 - <?php endif; ?>
1338 - <?php
1339 - // phpcs:enable
1340 - /**
1341 - * Filter: mainwp_header_actions_right
1342 - *
1343 - * Filters the MainWP header element actions.
1344 - *
1345 - * @since 4.0
1346 - */
1347 - $actions = apply_filters( 'mainwp_header_actions_right', '' );
1348 - if ( ! empty( $actions ) ) {
1349 - echo $actions; // phpcs:ignore WordPress.Security.EscapeOutput
1350 - }
1351 - ?>
1352 - <a class="ui button basic icon" id="mainwp-sites-sidebar" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Quick sites shortcuts', 'mainwp' ); ?>">
1353 - <i class="globe icon"></i>
1354 - </a>
1570 + // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1571 + $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
1572 + $id = 0;
1573 + $website = null;
1574 + if ( isset( $_GET['dashboard'] ) || ( isset( $_GET['id'] ) && 'CostTrackerAdd' !== $page ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) {
1575 + if ( isset( $_GET['dashboard'] ) ) {
1576 + $id = intval( $_GET['dashboard'] );
1577 + } elseif ( isset( $_GET['id'] ) ) {
1578 + $id = intval( $_GET['id'] );
1579 + } elseif ( isset( $_GET['updateid'] ) ) {
1580 + $id = intval( $_GET['updateid'] );
1581 + } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1582 + $id = intval( $_GET['emailsettingsid'] );
1583 + } elseif ( isset( $_GET['scanid'] ) ) {
1584 + $id = intval( $_GET['scanid'] );
1585 + } elseif ( isset( $_GET['monitor_wpid'] ) ) {
1586 + $id = intval( $_GET['monitor_wpid'] );
1587 + }
1588 + if ( $id ) {
1589 + $website = MainWP_DB::instance()->get_website_by_id( $id );
1590 + }
1591 + }
1592 + ob_start();
1593 + if ( $show_command_palette_trigger ) :
1594 + ?>
1595 + <span id="mainwp-header-command-palette-actions" class="mainwp-768-hide">
1596 + <a href="#" class="ui button hide-if-no-js" id="mainwp-command-palette-trigger" data-tooltip="<?php echo esc_attr( $command_palette_label ); ?>" data-inverted="" data-position="left center" aria-label="<?php echo esc_attr( $command_palette_label ); ?>" onclick='if ( window.wp && wp.data && wp.data.dispatch ) { wp.data.dispatch( "core/commands" ).open(); } return false;'>
1597 + <kbd><?php echo esc_html( $command_palette_shortcut ); ?></kbd>
1598 + </a>
1599 + </span>
1600 + <?php
1601 + endif;
1602 + if ( $website ) :
1603 + ?>
1604 + <?php if ( $id && $website && '' !== $website->sync_errors ) : ?>
1605 + <a href="#" class="mainwp-updates-overview-reconnect-site ui green button" adminuser="<?php echo esc_attr( $website->adminname ); ?>" 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> <?php echo esc_html__( 'Reconnect', 'mainwp' ); ?></a>
1606 + <?php
1607 + else :
1608 + $site_sync_info = MainWP_Utility::get_last_sync_info( $id );
1609 + $site_sync_tooltip = '';
1610 + $site_sync_outdated = false;
1611 + $current_time = time();
1612 + $twenty_four_h = 24 * HOUR_IN_SECONDS;
1355 1613
1356 - <?php $custom_theme = MainWP_Settings::get_instance()->get_current_user_theme(); ?>
1357 - <div id="mainwp-select-theme-button" class="ui button icon mainwp-selecte-theme-button" custom-theme="default" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_html_e( 'Select MainWP theme', 'mainwp' ); ?>">
1358 - <i class="palette icon"></i>
1359 - </div>
1614 + $site_name = stripslashes( $website->name );
1615 + if ( ! empty( $site_sync_info['timestamp'] ) && ( $current_time - $site_sync_info['timestamp'] ) > $twenty_four_h ) {
1616 + $site_sync_outdated = true;
1617 + /* translators: 1: Site name. */
1618 + $site_sync_tooltip = sprintf( esc_attr__( 'Data not synced for more than 24h. Click here to sync %1$s.', 'mainwp' ), $site_name );
1619 + } elseif ( ! empty( $site_sync_info['formatted'] ) ) {
1620 + /* translators: 1: Last sync date/time, 2: Site name. */
1621 + $site_sync_tooltip = sprintf( esc_attr__( 'Last sync: %1$s. Click here to sync %2$s.', 'mainwp' ), $site_sync_info['formatted'], $site_name );
1622 + } else {
1623 + /* translators: 1: Site name. */
1624 + $site_sync_tooltip = sprintf( esc_attr__( 'Get fresh data from %1$s.', 'mainwp' ), $site_name );
1625 + }
1626 + ?>
1627 + <a class="ui green <?php echo 0 < $sites_count ? '' : 'disabled'; ?> button" id="mainwp-sync-sites" data-tooltip="<?php echo esc_attr( $site_sync_tooltip ); ?>" data-inverted="" data-position="left center" aria-label="<?php echo esc_attr( $site_sync_tooltip ); ?>" style="position: relative;">
1628 + <?php if ( $site_sync_outdated ) : ?>
1629 + <span class="ui red empty circular looping pulsating transition label" style="position: absolute; top: -4px; right: -4px;"></span>
1630 + <?php endif; ?>
1631 + <i class="sync alternate icon"></i> <span class="mainwp-768-hide"><?php echo esc_html__( 'Sync', 'mainwp' ); ?></span>
1632 + </a>
1633 + <?php endif; ?>
1634 + <?php
1635 + else :
1636 + $el_id_syc_1 = 'mainwp-sync-sites';
1637 + $sync_info = MainWP_Utility::get_last_sync_info();
1638 + $sync_tooltip = '';
1639 + $sync_outdated = false;
1640 + $current_time = time();
1641 + $twenty_four_h = 24 * HOUR_IN_SECONDS;
1360 1642
1361 - <?php
1362 - /**
1363 - * After select theme actions.
1364 - *
1365 - * @since 4.5.2
1366 - */
1367 - do_action( 'mainwp_header_actions_after_select_themes' );
1368 - ?>
1369 - <div class="ui icon top left pointing dropdown button" id="mainwp-help-menu-icon-button">
1370 - <i class="ellipsis horizontal icon"></i>
1371 - <div class="menu">
1372 - <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=Settings' ) ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to MainWP Settings', 'mainwp' ); ?>">
1373 - <i class="cog icon"></i> <?php esc_html_e( 'Settings', 'mainwp' ); ?></span>
1374 - </a>
1375 - <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformation' ) ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to MainWP Info', 'mainwp' ); ?>">
1376 - <i class="circle info icon"></i> <?php esc_html_e( 'Info', 'mainwp' ); ?></span>
1377 - </a>
1378 - <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to WP Admin', 'mainwp' ); ?>">
1379 - <i class="wordpress icon"></i> <?php //phpcs:ignore -- ignore wordpress icon. ?> <?php esc_html_e( 'WP Admin', 'mainwp' ); ?></span>
1380 - </a>
1381 - <a class="item" href="<?php echo wp_logout_url(); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Log out of your MainWP Dashboard', 'mainwp' ); ?>">
1382 - <i class="sign out icon"></i> <?php esc_html_e( 'Log Out', 'mainwp' ); ?></span>
1383 - </a>
1384 - <a id="mainwp-help-sidebar" class="item" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Need help?', 'mainwp' ); ?>">
1385 - <i class="life ring icon"></i> <?php esc_html_e( 'Get Support', 'mainwp' ); ?>
1386 - </a>
1387 - <a class="item" id="mainwp-community-button" data-inverted="" data-position="bottom right" href="https://managers.mainwp.com/" target="_blank" data-tooltip="<?php esc_attr_e( 'MainWP Community', 'mainwp' ); ?>">
1388 - <i class="discourse icon"></i> <?php esc_html_e( 'Managers Community', 'mainwp' ); ?>
1389 - </a>
1390 - <a class="item" id="mainwp-account-button" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to your MainWP Account at MainWP.com', 'mainwp' ); ?>" target="_blank" href="https://mainwp.com/my-account/">
1391 - <i class="user icon"></i> <?php esc_html_e( 'My MainWP Account', 'mainwp' ); ?>
1392 - </a>
1393 - </div>
1394 - </div>
1395 - <script>
1396 - jQuery( document ).ready( function( $ ) {
1397 - $( '#mainwp-help-menu-icon-button' ).dropdown();
1398 - } );
1399 - </script>
1400 -
1401 - <?php
1643 + if ( ! empty( $sync_info['timestamp'] ) && ( $current_time - $sync_info['timestamp'] ) > $twenty_four_h ) {
1644 + $sync_outdated = true;
1645 + $sync_tooltip = esc_attr__( 'Data not synced for more than 24h. Click here to sync all sites.', 'mainwp' );
1646 + } elseif ( ! empty( $sync_info['formatted'] ) ) {
1647 + /* translators: 1: Last sync date/time. */
1648 + $sync_tooltip = sprintf( esc_attr__( 'Last sync: %1$s. Click here to sync all sites.', 'mainwp' ), $sync_info['formatted'] );
1649 + } else {
1650 + $sync_tooltip = esc_attr__( 'Click here to sync all sites.', 'mainwp' );
1651 + }
1652 + ?>
1653 + <a class="ui green <?php echo 0 < $sites_count ? '' : 'disabled'; ?> button" id="<?php echo esc_attr( $el_id_syc_1 ); ?>" data-tooltip="<?php echo esc_attr( $sync_tooltip ); ?>" data-inverted="" data-position="left center" aria-label="<?php echo esc_attr( $sync_tooltip ); ?>" style="position: relative;">
1654 + <?php if ( $sync_outdated ) : ?>
1655 + <span class="ui red empty circular looping pulsating transition label" style="position: absolute; top: -4px; right: -4px;"></span>
1656 + <?php endif; ?>
1657 + <i class="sync alternate icon"></i> <span class="mainwp-768-hide"><?php echo esc_html__( 'Sync', 'mainwp' ); ?></span>
1658 + </a>
1659 + <?php endif; ?>
1402 1660
1403 - $all_updates = wp_get_update_data();
1404 - if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) {
1405 - ?>
1406 - <a id="mainwp-available-dashboard-updates-button" class="ui red icon button" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Your MainWP Dashboard sites needs your attention. Please check the available updates', 'mainwp' ); ?>" href="update-core.php">
1407 - <i class="exclamation triangle icon"></i>
1408 - </a>
1409 - <?php
1410 - }
1411 - $output = ob_get_clean();
1412 - return $output;
1413 - }
1661 + <div class="ui 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' ); ?>">
1662 + <i class="plus icon"></i> <?php echo esc_html__( 'Add', 'mainwp' ); ?>
1663 + <div class="menu">
1664 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Add Website', 'mainwp' ); ?></a>
1665 + <?php if ( \mainwp_current_user_can( 'dashboard', 'manage_clients' ) ) { ?>
1666 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=ClientAddNew' ) ); ?>"><?php esc_html_e( 'Add Client', 'mainwp' ); ?></a>
1667 + <?php } ?>
1668 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=CostTrackerAdd' ) ); ?>"><?php esc_html_e( 'Add Cost', 'mainwp' ); ?></a>
1669 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=PostBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Post', 'mainwp' ); ?></a>
1670 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=PageBulkAdd' ) ); ?>"><?php esc_html_e( 'Create Page', 'mainwp' ); ?></a>
1671 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=PluginsInstall' ) ); ?>"><?php esc_html_e( 'Install Plugin', 'mainwp' ); ?></a>
1672 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=ThemesInstall' ) ); ?>"><?php esc_html_e( 'Install Theme', 'mainwp' ); ?></a>
1673 + <a class="item" href="<?php echo esc_url( admin_url( 'admin.php?page=UserBulkAdd' ) ); ?>"><?php esc_html_e( ' Create User', 'mainwp' ); ?></a>
1674 + </div>
1675 + </div>
1414 1676
1415 - /**
1416 - * Method render_page_navigation()
1417 - *
1418 - * Render page navigation.
1419 - *
1420 - * @param array $subitems [access, active, style].
1421 - * @param null $name_caller Menu Name.
1422 - */
1423 - public static function render_page_navigation( $subitems = array(), $name_caller = null ) {
1677 + <?php if ( $screen && ( ( 'mainwp_tab' === $page ) || isset( $_GET['dashboard'] ) || ( ( 'ManageClients' === $page ) && isset( $_GET['client_id'] ) ) || ( 'CostSummary' === $page ) || ( 'InsightsOverview' === $page ) ) ) : ?>
1678 + <span id="mainwp-header-layout-actions">
1679 + <?php MainWP_Ui_Manage_Widgets_Layout::render_edit_layout( $screen->id ); ?>
1680 + </span>
1681 + <?php endif; ?>
1424 1682
1425 - /**
1426 - * Filter: mainwp_page_navigation
1427 - *
1428 - * Filters MainWP page navigation menu items.
1429 - *
1430 - * @since 4.0
1431 - */
1432 - $subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller );
1433 - ?>
1434 - <div id="mainwp-page-navigation-wrapper">
1435 -
1436 - <div class="ui vertical menu mainwp-page-navigation">
1437 - <?php
1683 + <span id="mainwp-header-secondary-actions" class="mainwp-768-hide">
1684 + <?php if ( ( 'mainwp_tab' === $page ) || isset( $_GET['dashboard'] ) || in_array( $page, $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Recommended ?>
1685 + <a id="mainwp-screen-options-button" class="ui icon button" 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' ); ?>">
1686 + <i class="cog icon"></i>
1687 + </a>
1438 1688
1439 - if ( is_array( $subitems ) ) {
1440 - foreach ( $subitems as $item ) {
1689 + <?php endif; ?>
1690 + <?php
1691 + // phpcs:enable
1692 + /**
1693 + * Filter: mainwp_header_actions_right
1694 + *
1695 + * Filters the MainWP header element actions.
1696 + *
1697 + * @since 4.0
1698 + */
1699 + $actions = apply_filters( 'mainwp_header_actions_right', '' );
1700 + if ( ! empty( $actions ) ) {
1701 + echo $actions; // phpcs:ignore WordPress.Security.EscapeOutput
1702 + }
1703 + ?>
1704 + <a class="ui button icon" id="mainwp-sites-sidebar" aria-label="<?php esc_attr_e( 'Open sites shortcuts sidebar', 'mainwp' ); ?>">
1705 + <i class="globe icon"></i>
1706 + </a>
1707 + <?php if ( 'default-dark' === $custom_theme && empty( $themes_files ) ) : ?>
1708 + <a id="mainwp-select-light-theme-button" class="ui button icon" aria-label="<?php esc_attr_e( 'Select MainWP Light theme', 'mainwp' ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_html_e( 'Switch to Light mode', 'mainwp' ); ?>">
1709 + <i class="sun icon"></i>
1710 + </a>
1711 + <?php elseif ( 'default' === $custom_theme && empty( $themes_files ) ) : ?>
1712 + <a id="mainwp-select-dark-theme-button" class="ui button icon" aria-label="<?php esc_attr_e( 'Select MainWP Dark theme', 'mainwp' ); ?>" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_html_e( 'Switch to Dark mode', 'mainwp' ); ?>">
1713 + <i class="moon icon"></i>
1714 + </a>
1715 + <?php else : ?>
1716 + <a 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' ); ?>">
1717 + <i class="palette icon"></i>
1718 + </a>
1719 + <?php endif; ?>
1720 + </span>
1441 1721
1442 - if ( ! is_array( $item ) ) {
1443 - continue;
1444 - }
1722 + <?php
1723 + /**
1724 + * After select theme actions.
1725 + *
1726 + * @since 4.5.2
1727 + */
1728 + do_action( 'mainwp_header_actions_after_select_themes' );
1729 + $show_avar = get_option( 'show_avatars' );
1730 + ?>
1731 + <div class="ui top right pointing dropdown <?php echo $show_avar ? '' : 'icon button'; ?> mainwp-768-hide" id="mainwp-user-menu-button">
1732 + <?php
1733 + if ( $show_avar ) {
1734 + echo get_avatar(
1735 + $current_user,
1736 + 38,
1737 + 'wavatar',
1738 + esc_html__( 'Settings', 'mainwp' ),
1739 + array(
1740 + 'extra_attr' => 'style="width:38px!important;height:38px!important;"',
1741 + 'class' => 'ui small avatar image',
1742 + )
1743 + );
1744 + } else {
1745 + ?>
1746 + <i class="user icon"></i>
1747 + <?php
1748 + }
1749 + ?>
1750 + <div class="menu">
1751 + <a class="item" id="mainwp-settings-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=Settings' ) ); ?>">
1752 + <i class="cog grey icon"></i> <?php esc_html_e( 'MainWP Settings', 'mainwp' ); ?>
1753 + </a>
1754 + <a class="item" id="mainwp-tools-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=MainWPTools' ) ); ?>">
1755 + <i class="tools grey icon"></i> <?php esc_html_e( 'MainWP Tools', 'mainwp' ); ?>
1756 + </a>
1757 + <a class="item" id="mainwp-system-info-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformation' ) ); ?>">
1758 + <i class="circle grey info icon"></i> <?php esc_html_e( 'System Info', 'mainwp' ); ?>
1759 + </a>
1760 + <a class="item" id="mainwp-privacy-policy-menu-item" href="<?php echo esc_url( admin_url( 'admin.php?page=PluginPrivacy' ) ); ?>">
1761 + <i class="file contract grey icon"></i> <?php esc_html_e( 'Privacy Policy', 'mainwp' ); ?>
1762 + </a>
1763 + <a id="mainwp-help-sidebar" class="item" href="#" target="_blank">
1764 + <i class="life ring grey icon"></i> <?php esc_html_e( 'Get Help', 'mainwp' ); ?>
1765 + </a>
1766 + <div class="ui divider"></div>
1767 + <a class="item" id="mainwp-wp-admin-menu-item" href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>">
1768 + <i class="wordpress grey icon"></i> <?php //phpcs:ignore -- ignore wordpress icon. ?> <?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?>
1769 + </a>
1770 + <?php $all_updates = wp_get_update_data(); ?>
1771 + <?php if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) : ?>
1772 + <a class="item" id="mainwp-available-updates-menu-item" data-inverted="" data-position="left center" 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">
1773 + <i class="exclamation triangle red icon"></i> <?php esc_html_e( 'Update Dashboard Site', 'mainwp' ); ?>
1774 + </a>
1775 + <?php endif; ?>
1776 + <div class="ui divider"></div>
1777 + <a class="item" id="mainwp-community-button" href="https://community.mainwp.com/" target="_blank">
1778 + <i class="discourse grey icon"></i> <?php esc_html_e( 'Managers Community', 'mainwp' ); ?>
1779 + </a>
1780 + <a class="item" id="mainwp-account-button" target="_blank" href="https://mainwp.com/my-account/"> <?php // NOSONAR - noopener - open safe. ?>
1781 + <i class="user grey icon"></i> <?php esc_html_e( 'My MainWP Account', 'mainwp' ); ?>
1782 + </a>
1783 + <div class="ui divider"></div>
1784 + <a class="item" id="mainwp-sign-out-button" href="<?php echo wp_logout_url(); // phpcs:ignore WordPress.Security.EscapeOutput ?>">
1785 + <i class="sign out grey icon"></i> <?php esc_html_e( 'Log Out', 'mainwp' ); ?>
1786 + </a>
1787 + </div>
1788 + </div>
1789 + <a class="ui icon button" href="javascript:void(0)" id="mainwp-mobile-menu-trigger">
1790 + <i class="bars icon"></i>
1791 + </a>
1792 + <?php $pulse = apply_filters( 'mainwp_screen_options_pulse_control', 1 ); ?>
1793 + <input type="hidden" id="mainwp-screen-options-pulse-control" value="<?php echo esc_attr( $pulse ); ?>">
1794 + <script>
1795 + jQuery( document ).ready( function( $ ) {
1796 + $( '#mainwp-user-menu-button' ).dropdown();
1797 + } );
1798 + </script>
1799 + <?php
1800 + return ob_get_clean();
1801 + }
1445 1802
1446 - if ( isset( $item['access'] ) && ! $item['access'] ) {
1447 - continue;
1448 - }
1803 + /**
1804 + * Method render_page_navigation()
1805 + *
1806 + * Render page navigation.
1807 + *
1808 + * @param array $subitems [access, active, style, target, rel].
1809 + * @param null $name_caller Menu Name.
1810 + */
1811 + public static function render_page_navigation( $subitems = array(), $name_caller = null ) { //phpcs:ignore -- NOSONAR - complex.
1449 1812
1450 - $class = '';
1451 - if ( isset( $item['active'] ) && $item['active'] ) {
1452 - $class = 'active';
1453 - }
1813 + /**
1814 + * Filter: mainwp_page_navigation
1815 + *
1816 + * Filters MainWP page navigation menu items.
1817 + *
1818 + * @since 4.0
1819 + */
1820 + $subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller );
1821 + ?>
1822 + <div id="mainwp-page-navigation-wrapper">
1823 + <?php if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) || isset( $_GET['monitor_wpid'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification ?>
1824 + <?php
1825 + //phpcs:disable WordPress.Security.NonceVerification
1826 + $id = 0;
1827 + if ( isset( $_GET['dashboard'] ) ) {
1828 + $id = intval( $_GET['dashboard'] );
1829 + } elseif ( isset( $_GET['id'] ) ) {
1830 + $id = intval( $_GET['id'] );
1831 + } elseif ( isset( $_GET['updateid'] ) ) {
1832 + $id = intval( $_GET['updateid'] );
1833 + } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1834 + $id = intval( $_GET['emailsettingsid'] );
1835 + } elseif ( isset( $_GET['scanid'] ) ) {
1836 + $id = intval( $_GET['scanid'] );
1837 + } elseif ( isset( $_GET['monitor_wpid'] ) ) {
1838 + $id = intval( $_GET['monitor_wpid'] );
1839 + }
1840 + // phpcs:enable
1841 + $website = MainWP_DB::instance()->get_website_by_id( $id );
1454 1842
1455 - if ( isset( $item['class'] ) ) {
1456 - $class = $class . ' ' . $item['class'];
1457 - }
1843 + // To avoid error in case of direct access to page with wrong id.
1844 + if ( ! empty( $website ) && ! empty( $website->url ) ) {
1845 + $overview_mshot = static::get_mshots_image_sources( $website->url, 170 );
1846 + ?>
1847 + <img alt="<?php esc_attr_e( 'Website preview', 'mainwp' ); ?>" src="<?php echo esc_url( $overview_mshot['src'] ); ?>" data-mainwp-mshot-src="<?php echo esc_url( $overview_mshot['src'] ); ?>" data-mainwp-mshot-requeue-src="<?php echo esc_url( $overview_mshot['requeue_src'] ); ?>" id="mainwp-site-preview-image">
1848 + <?php
1849 + }
1850 + ?>
1851 + <?php endif; ?>
1852 + <div class="ui vertical menu mainwp-page-navigation">
1458 1853
1459 - $style = '';
1460 - if ( isset( $item['style'] ) ) {
1461 - $style = $item['style'];
1462 - }
1854 + <?php
1463 1855
1464 - ?>
1465 - <a class="<?php echo esc_attr( $class ); ?> item" style="<?php echo esc_attr( $style ); ?>" href="<?php echo esc_url( $item['href'] ); ?>">
1466 - <?php echo esc_html( $item['title'] ); ?> <?php echo isset( $item['after_title'] ) ? $item['after_title'] : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?>
1467 - </a>
1468 - <?php
1469 - }
1470 - }
1856 + if ( is_array( $subitems ) ) {
1857 + foreach ( $subitems as $item ) {
1471 1858
1472 - do_action( 'mainwp_page_navigation_menu' );
1473 - ?>
1474 - </div>
1475 -
1476 - </div>
1477 - <?php
1478 - $is_site = MainWP_System::is_mainwp_site_page();
1479 - if ( $is_site ) {
1480 - ?>
1481 - <div id="mainwp-site-mode-wrap">
1482 - <?php } ?>
1483 -
1484 - <?php
1485 - }
1859 + if ( ! is_array( $item ) ) {
1860 + continue;
1861 + }
1486 1862
1487 - /**
1488 - * Method render_header()
1489 - *
1490 - * Render page title.
1491 - *
1492 - * @param string $title Page title.
1493 - *
1494 - * @return void Render page title and hidden divider html.
1495 - */
1496 - public static function render_header( $title = '' ) {
1497 - self::render_top_header( array( 'title' => $title ) );
1498 - echo '<div class="ui hidden clearing fitted divider"></div>';
1499 - echo '<div class="wrap">';
1500 - }
1863 + if ( isset( $item['access'] ) && ! $item['access'] ) {
1864 + continue;
1865 + }
1501 1866
1502 - /**
1503 - * Method render_footer()
1504 - *
1505 - * Render page footer.
1506 - *
1507 - * @return void Render closing tags for page container.
1508 - */
1509 - public static function render_footer() {
1510 - $is_site = MainWP_System::is_mainwp_site_page();
1511 - if ( $is_site ) {
1512 - echo '</div>';
1513 - }
1514 - echo '</div>';
1515 - echo '</div>';
1516 - }
1867 + $class = '';
1868 + if ( isset( $item['active'] ) && $item['active'] ) {
1869 + $class = 'active';
1870 + }
1517 1871
1518 - /**
1519 - * Method add_widget_box()
1520 - *
1521 - * Customize WordPress add_meta_box() function.
1522 - *
1523 - * @param mixed $id Widget ID parameter.
1524 - * @param mixed $callback Callback function.
1525 - * @param null $screen Current page.
1526 - * @param array $layout widget layout.
1527 - *
1528 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1529 - */
1530 - public static function add_widget_box( $id, $callback, $screen = null, $layout = array() ) {
1531 - /**
1532 - * MainWP widget boxes array.
1533 - *
1534 - * @global object
1535 - */
1536 - global $mainwp_widget_boxes;
1872 + if ( isset( $item['class'] ) ) {
1873 + $class = $class . ' ' . $item['class'];
1874 + }
1537 1875
1538 - $page = MainWP_System_Utility::get_page_id( $screen );
1876 + $style = '';
1877 + if ( isset( $item['style'] ) ) {
1878 + $style = $item['style'];
1879 + }
1539 1880
1540 - if ( empty( $page ) ) {
1541 - return;
1542 - }
1881 + $target = '';
1882 + if ( isset( $item['target'] ) ) {
1883 + $target = $item['target'];
1884 + }
1543 1885
1544 - if ( ! isset( $mainwp_widget_boxes ) ) {
1545 - $mainwp_widget_boxes = array();
1546 - }
1547 - if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
1548 - $mainwp_widget_boxes[ $page ] = array();
1549 - }
1886 + $rel = '';
1887 + if ( isset( $item['rel'] ) ) {
1888 + $rel = $item['rel'];
1889 + } elseif ( '_blank' === $target ) {
1890 + $rel = 'noopener noreferrer';
1891 + }
1550 1892
1551 - if ( empty( $title ) ) {
1552 - $title = 'No Title';
1553 - }
1554 - $mainwp_widget_boxes[ $page ][ $id ] = array(
1555 - 'id' => $id,
1556 - 'callback' => $callback,
1557 - 'layout' => $layout,
1558 - );
1559 - }
1893 + ?>
1894 + <a class="<?php echo esc_attr( $class ); ?> item" style="<?php echo esc_attr( $style ); ?>" href="<?php echo esc_url( $item['href'] ); ?>" <?php if ( ! empty( $target ) ) : ?>target="<?php echo esc_attr( $target ); ?>"<?php endif; ?> <?php if ( ! empty( $rel ) ) : ?>rel="<?php echo esc_attr( $rel ); ?>"<?php endif; ?>>
1895 + <?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 ?>
1896 + </a>
1897 + <?php
1898 + }
1899 + }
1560 1900
1561 - /**
1562 - * Method do_widget_boxes()
1563 - *
1564 - * Customize WordPress do_meta_boxes() function.
1565 - *
1566 - * @param mixed $screen_id Current page ID.
1567 - * @param array ...$args Widget callback args.
1568 - *
1569 - * @return void Renders widget container box.
1570 - *
1571 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1572 - */
1573 - public static function do_widget_boxes( $screen_id, ...$args ) { // phpcs:ignore -- complex.
1574 - global $mainwp_widget_boxes;
1575 - $page = MainWP_System_Utility::get_page_id( $screen_id );
1576 - if ( empty( $page ) ) {
1577 - return;
1578 - }
1579 - $wgsorted = get_user_option( 'mainwp_widgets_sorted_' . strtolower( $page ) );
1901 + do_action( 'mainwp_page_navigation_menu' );
1902 + ?>
1903 + </div>
1580 1904
1581 - if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
1582 - $wgsorted = json_decode( $wgsorted, true );
1583 - }
1905 + </div>
1906 + <?php
1907 + $is_site = MainWP_System::is_mainwp_site_page();
1908 + if ( $is_site ) {
1909 + echo '<div id="mainwp-site-mode-wrap">';
1910 + }
1911 + }
1584 1912
1585 - $client_id = 0;
1586 - if ( 'mainwp_page_manageclients' === $page ) {
1587 - $sorted_array = is_array( $wgsorted ) ? $wgsorted : array();
1588 - $wgsorted = array();
1589 - $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1590 - if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
1591 - $wgsorted = $sorted_array[ $client_id ];
1592 - }
1593 - }
1913 + /**
1914 + * Method render_header()
1915 + *
1916 + * Render page title.
1917 + *
1918 + * @param string $title Page title.
1919 + *
1920 + * @return void Render page title and hidden divider html.
1921 + */
1922 + public static function render_header( $title = '' ) {
1923 + static::render_top_header( array( 'title' => $title ) );
1924 + echo '<div class="ui hidden clearing fitted divider"></div>';
1925 + echo '<div class="wrap">';
1926 + }
1594 1927
1595 - $wgsorted = apply_filters( 'mainwp_do_widget_boxes_sorted', $wgsorted, $page, $client_id );
1928 + /**
1929 + * Method render_footer()
1930 + *
1931 + * Render page footer.
1932 + *
1933 + * @return void Render closing tags for page container.
1934 + */
1935 + public static function render_footer() {
1936 + $is_site = MainWP_System::is_mainwp_site_page();
1937 + if ( $is_site ) {
1938 + echo '</div>';
1939 + }
1940 + echo '</div>';
1941 + echo '</div>';
1942 + }
1596 1943
1597 - if ( ! is_array( $wgsorted ) ) {
1598 - $wgsorted = array();
1599 - }
1944 + /**
1945 + * Method add_widget_box()
1946 + *
1947 + * Customize WordPress add_meta_box() function.
1948 + *
1949 + * @param mixed $id Widget ID parameter.
1950 + * @param mixed $callback Callback function.
1951 + * @param null $screen Current page.
1952 + * @param array $layout widget layout.
1953 + *
1954 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1955 + */
1956 + public static function add_widget_box( $id, $callback, $screen = null, $layout = array() ) {
1957 + /**
1958 + * MainWP widget boxes array.
1959 + *
1960 + * @global object
1961 + */
1962 + global $mainwp_widget_boxes;
1600 1963
1601 - if ( 'mainwp_page_manageclients' === $page ) {
1602 - $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
1603 - } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1604 - $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
1605 - } else {
1606 - $show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
1607 - }
1964 + $page = MainWP_System_Utility::get_page_id( $screen );
1608 1965
1609 - if ( ! is_array( $show_widgets ) ) {
1610 - $show_widgets = array();
1611 - }
1966 + if ( empty( $page ) ) {
1967 + return;
1968 + }
1612 1969
1613 - if ( isset( $mainwp_widget_boxes[ $page ] ) ) {
1614 - foreach ( (array) $mainwp_widget_boxes[ $page ] as $box ) {
1615 - if ( false === $box || ! isset( $box['callback'] ) ) {
1616 - continue;
1617 - }
1970 + if ( ! isset( $mainwp_widget_boxes ) ) {
1971 + $mainwp_widget_boxes = array();
1972 + }
1973 + if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
1974 + $mainwp_widget_boxes[ $page ] = array();
1975 + }
1618 1976
1619 - // to avoid hidden widgets.
1620 - if ( isset( $show_widgets[ $box['id'] ] ) && 0 === (int) $show_widgets[ $box['id'] ] ) {
1621 - continue;
1622 - }
1977 + $mainwp_widget_boxes[ $page ][ $id ] = array(
1978 + 'id' => $id,
1979 + 'callback' => $callback,
1980 + 'layout' => $layout,
1981 + );
1982 + }
1623 1983
1624 - $layout = array();
1625 - if ( isset( $wgsorted[ $box['id'] ] ) ) {
1626 - $val = $wgsorted[ $box['id'] ];
1627 - if ( is_array( $val ) && isset( $val['col'] ) ) {
1628 - $layout = array(
1629 - 'col' => $val['col'],
1630 - 'row' => $val['row'],
1631 - 'size_x' => $val['size_x'],
1632 - 'size_y' => $val['size_y'],
1633 - );
1634 - }
1635 - }
1636 - if ( ! isset( $layout['col'] ) && isset( $box['layout'][0] ) ) {
1637 - $layout = array(
1638 - 'col' => $box['layout'][0],
1639 - 'row' => $box['layout'][1],
1640 - 'size_x' => $box['layout'][2],
1641 - 'size_y' => $box['layout'][3],
1642 - );
1643 - }
1644 - $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'] ) : '' ) . '" ';
1645 - echo '<div id="widget-' . esc_html( $box['id'] ) . '" class="ui segment mainwp-widget" ' . $layout_attrs_escaped . '>' . "\n"; //phpcs:ignore -- escaped.
1646 - call_user_func( $box['callback'], $screen_id, $args );
1647 - echo '<span class="mainwp-resize-handle"></span>' . "\n";
1648 - echo "</div>\n";
1984 + /**
1985 + * Method do_widget_boxes()
1986 + *
1987 + * Customize WordPress do_meta_boxes() function.
1988 + *
1989 + * @param mixed $screen_id Current page ID.
1990 + * @param array ...$args Widget callback args.
1991 + *
1992 + * @return void Renders widget container box.
1993 + *
1994 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1995 + */
1996 + public static function do_widget_boxes( $screen_id, ...$args ) { // phpcs:ignore -- NOSONAR - complex.
1997 + global $mainwp_widget_boxes;
1998 + $page = MainWP_System_Utility::get_page_id( $screen_id );
1999 + if ( empty( $page ) ) {
2000 + return;
2001 + }
1649 2002
1650 - }
1651 - }
1652 - $breakpoint = apply_filters( 'mainwp_flexible_widgets_breakpoint', 1367 );
1653 - ?>
1654 - <script type="text/javascript">
1655 - var is_mobile = false;
1656 - if( jQuery( window ).width() < <?php echo intval( $breakpoint ); ?> ) {
1657 - is_mobile = true;
1658 - }
1659 - if ( ! is_mobile ) {
1660 - var page_sortablewidgets = '<?php echo esc_js( $page ); ?>';
1661 - jQuery( document ).ready( function( $ ) {
1662 - var wgIds = [];
1663 - jQuery( ".mainwp-widget" ).each( function () {
1664 - wgIds.push( jQuery( this ).attr('id') );
1665 - } );
2003 + $page_widget = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
1666 2004
1667 - jQuery( '.gridster' ).gridster( {
1668 - auto_init: true,
1669 - autogenerate_stylesheet: true,
1670 - shift_larger_widgets_down: false,
1671 - shift_widgets_up: true,
1672 - widget_selector: "div.mainwp-widget",
1673 - widget_margins: [20, 20],
1674 - widget_base_dimensions: ["auto", 20],
1675 - min_cols: 1,
1676 - max_cols: 12,
1677 - max_size_x: 12,
1678 - max_rows: 500,
1679 - avoid_overlapped_widgets: true,
1680 - collision: {
1681 - wait_for_mouseup: true
1682 - },
1683 - draggable: {
1684 - handle: '.handle-drag',
1685 - stop: function (e, ui, $widget) {
1686 - mainwp_overview_gridster_reorder(this);
1687 - }
1688 - },
1689 - resize: {
1690 - enabled: true,
1691 - handle_append_to: ".mainwp-resize-handle",
1692 - stop: function (e, ui, $widget) {
1693 - mainwp_overview_gridster_reorder(this);
1694 - }
1695 - }
1696 - } ).data('gridster');
2005 + $wgsorted = false;
2006 + $selected_widget_layout = '';
1697 2007
1698 - mainwp_overview_gridster_reorder = function( $gridObj ){
1699 - var orders = $gridObj.serialize();
1700 - var postVars = {
1701 - action:'mainwp_widgets_order',
1702 - page: page_sortablewidgets,
1703 - order:JSON.stringify(orders),
1704 - wgids: JSON.stringify(wgIds),
1705 - item_id: <?php echo intval( $client_id ); ?>
1706 - };
1707 - jQuery.post( ajaxurl, mainwp_secure_data( postVars ), function ( res ) {
1708 - } );
1709 - }
1710 - });
1711 - }
1712 - </script>
1713 - <?php
1714 - }
2008 + if ( ! empty( $_GET['page'] ) && ! empty( $_GET['select_layout'] ) && ! empty( $_GET['_opennonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_opennonce'] ), 'mainwp-admin-nonce' ) && ! empty( $_GET['updated'] ) && ! empty( $_GET['screen_slug'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2009 + $layid = sanitize_text_field( wp_unslash( $_GET['updated'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2010 + $screen_slug = sanitize_text_field( wp_unslash( $_GET['screen_slug'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1715 2011
1716 - /**
1717 - * Method render_empty_bulk_actions()
1718 - *
1719 - * Render empty bulk actions when drop down is disabled.
1720 - */
1721 - public static function render_empty_bulk_actions() {
1722 - ?>
1723 - <select class="ui disabled dropdown" id="mainwp-bulk-actions">
1724 - <option value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
1725 - </select>
1726 - <button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
1727 - <?php
1728 - }
2012 + $saved_layouts = MainWP_Ui_Manage_Widgets_Layout::set_get_widgets_layout( false, array(), $screen_slug );
2013 + $selected_layout = is_array( $saved_layouts ) && isset( $saved_layouts[ $layid ] ) ? $saved_layouts[ $layid ] : array();
2014 + if ( is_array( $selected_layout ) && isset( $selected_layout['layout'] ) ) {
2015 + $wgsorted = $selected_layout['layout'];
2016 + if ( isset( $selected_layout['name'] ) ) {
2017 + $selected_widget_layout = $selected_layout['name'];
2018 + }
2019 + }
2020 + }
1729 2021
1730 - /**
1731 - * Method render_modal_install_plugin_theme()
1732 - *
1733 - * Render modal window for installing plugins & themes.
1734 - *
1735 - * @param string $what Which window to render, plugin|theme.
1736 - */
1737 - public static function render_modal_install_plugin_theme( $what = 'plugin' ) {
1738 - ?>
1739 - <div id="plugintheme-installation-progress-modal" class="ui modal">
1740 - <i class="close icon"></i>
1741 - <div class="header">
1742 - <?php
1743 - if ( 'plugin' === $what ) {
1744 - esc_html_e( 'Plugin Installation', 'mainwp' );
1745 - } elseif ( 'theme' === $what ) {
1746 - esc_html_e( 'Theme Installation', 'mainwp' );
1747 - }
1748 - ?>
1749 - </div>
1750 - <div class="ui green progress mainwp-modal-progress">
1751 - <div class="bar"><div class="progress"></div></div>
1752 - <div class="label"></div>
1753 - </div>
1754 - <div class="scrolling content">
1755 - <?php
1756 - /**
1757 - * Action: mainwp_before_plugin_theme_install_progress
1758 - *
1759 - * Fires before the progress list in the install modal element.
1760 - *
1761 - * @since 4.1
1762 - */
1763 - do_action( 'mainwp_before_plugin_theme_install_progress' );
1764 - ?>
1765 - <div id="plugintheme-installation-queue"></div>
1766 - <?php
1767 - /**
1768 - * Action: mainwp_after_plugin_theme_install_progress
1769 - *
1770 - * Fires after the progress list in the install modal element.
1771 - *
1772 - * @since 4.1
1773 - */
1774 - do_action( 'mainwp_after_plugin_theme_install_progress' );
1775 - ?>
1776 - </div>
1777 - <div class="actions" item-type="<?php echo esc_attr( $what ); ?>">
1778 - <?php
1779 - /**
1780 - * Action: mainwp_after_plugin_theme_install_progress
1781 - *
1782 - * Fires after the progress list in the install modal element.
1783 - *
1784 - * @since 4.1
1785 - */
1786 - do_action( 'mainwp_install_plugin_theme_modal_action', $what );
1787 - ?>
1788 - <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1789 - </div>
1790 - </div>
1791 - <?php
1792 - }
2022 + if ( empty( $wgsorted ) ) {
2023 + $wgsorted = get_user_option( 'mainwp_widgets_sorted_' . $page );
2024 + }
1793 2025
1794 - /**
1795 - * Method render_modal_upload_icon()
1796 - *
1797 - * Render modal window for upload plugins & themes icon.
1798 - */
1799 - public static function render_modal_upload_icon() {
2026 + if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
2027 + $wgsorted = json_decode( $wgsorted, true );
2028 + }
1800 2029
1801 - ?>
1802 - <div id="mainwp-upload-custom-icon-modal" class="ui modal">
1803 - <i class="close icon"></i>
1804 - <div class="header">
1805 - <?php
1806 - esc_html_e( 'Update Icon', 'mainwp' );
1807 - ?>
1808 - </div>
1809 - <div class="content" id="mainwp-upload-custom-icon-content">
1810 - <form action="" method="post" enctype="multipart/form-data" name="uploadicon_form" id="uploadicon_form" class="">
1811 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1812 - <div class="ui message" id="mainwp-message-zone-upload" style="display:none;"></div>
1813 - <?php
1814 - /**
1815 - * Action: mainwp_after_upload_custom_icon
1816 - *
1817 - * Fires before the modal element.
1818 - *
1819 - * @since 4.3
1820 - */
1821 - do_action( 'mainwp_before_upload_custom_icon' );
1822 - ?>
1823 - <div class="ui form">
1824 - <div class="ui grid field">
1825 - <label class="six wide column middle aligned"><?php esc_html_e( 'Custom icon', 'mainwp' ); ?></label>
1826 - <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1827 - <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' ); ?>" />
1828 - </div>
1829 - </div>
1830 - <div class="ui grid field" id="mainwp_delete_image_field">
1831 - <label class="six wide column middle aligned"></label>
1832 - <div class="six wide column">
1833 - <img class="ui tiny image" src="" /><br/>
1834 - <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, delete image.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1835 - <input type="checkbox"id="mainwp_delete_image_chk" />
1836 - <label for="mainwp_delete_image_chk"><?php esc_html_e( 'Delete Image', 'mainwp' ); ?></label>
1837 - </div>
1838 - </div>
1839 - </div>
1840 - </div>
1841 - <?php
1842 - /**
1843 - * Action: mainwp_after_upload_custom_icon
1844 - *
1845 - * Fires after the modal element.
1846 - *
1847 - * @since 4.3
1848 - */
1849 - do_action( 'mainwp_after_upload_custom_icon' );
1850 - ?>
1851 - </form>
1852 - </div>
1853 - <div class="actions">
1854 - <div class="ui green button" id="update_custom_icon_btn"><?php esc_html_e( 'Update', 'mainwp' ); ?></div>
1855 - </div>
1856 - </div>
1857 - <?php
1858 - }
2030 + if ( ! is_array( $wgsorted ) ) {
2031 + $wgsorted = array();
2032 + }
1859 2033
1860 - /**
1861 - * Method render_show_all_updates_button()
1862 - *
1863 - * Render show all updates button.
1864 - *
1865 - * @return void Render Show All Updates button html.
1866 - */
1867 - public static function render_show_all_updates_button() {
1868 - ?>
1869 - <a href="javascript:void(0)" class="ui mini button trigger-all-accordion">
1870 - <?php
1871 - /**
1872 - * Filter: mainwp_show_all_updates_button_text
1873 - *
1874 - * Filters the Show All Updates button text.
1875 - *
1876 - * @since 4.1
1877 - */
1878 - echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', esc_html__( 'Show All Updates', 'mainwp' ) ) );
1879 - ?>
1880 - </a>
1881 - <?php
1882 - }
2034 + $client_id = 0;
2035 + if ( 'mainwp_page_manageclients' === $page ) {
2036 + $sorted_array = is_array( $wgsorted ) ? $wgsorted : array();
2037 + $wgsorted = array();
2038 + $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2039 + if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
2040 + $wgsorted = $sorted_array[ $client_id ];
2041 + }
2042 + }
1883 2043
1884 - /**
1885 - * Method render_sorting_icons()
1886 - *
1887 - * Render sorting up & down icons.
1888 - *
1889 - * @return void Render Sort up & down incon html.
1890 - */
1891 - public static function render_sorting_icons() {
1892 - ?>
1893 - <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"></i>
1894 - <?php
1895 - }
2044 + $wgsorted = apply_filters( 'mainwp_do_widget_boxes_sorted', $wgsorted, $page, $client_id );
1896 2045
1897 - /**
1898 - * Method render_modal_edit_notes()
1899 - *
1900 - * Render modal window for edit notes.
1901 - *
1902 - * @param string $what What modal window to render. Default = site.
1903 - *
1904 - * @return void
1905 - */
1906 - public static function render_modal_edit_notes( $what = 'site' ) {
1907 - ?>
1908 - <div id="mainwp-notes-modal" class="ui modal">
1909 - <div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div>
1910 - <div class="content" id="mainwp-notes-content">
1911 - <div id="mainwp-notes-status" class="ui message hidden"></div>
1912 - <?php
1913 - /**
1914 - * Action: mainwp_before_edit_site_note
1915 - *
1916 - * Fires before the site note content in the Edit Note modal element.
1917 - *
1918 - * @since 4.1
1919 - */
1920 - do_action( 'mainwp_before_edit_site_note' );
1921 - ?>
1922 - <div id="mainwp-notes-html"></div>
1923 - <div id="mainwp-notes-editor" class="ui form" style="display:none;">
1924 - <div class="field">
1925 - <label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label>
1926 - <textarea id="mainwp-notes-note"></textarea>
1927 - </div>
1928 - <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>
1929 - </div>
1930 - <?php
1931 - /**
1932 - * Action: mainwp_after_edit_site_note
1933 - *
1934 - * Fires after the site note content in the Edit Note modal element.
1935 - *
1936 - * @since 4.1
1937 - */
1938 - do_action( 'mainwp_after_edit_site_note' );
1939 - ?>
1940 - </div>
1941 - <div class="actions">
1942 - <div class="ui grid">
1943 - <div class="eight wide left aligned middle aligned column">
1944 - <input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save Note', 'mainwp' ); ?>" style="display:none;"/>
1945 - <input type="button" class="ui green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit Note', 'mainwp' ); ?>"/>
1946 - </div>
1947 - <div class="eight wide column">
1948 - <input type="button" class="ui button" id="mainwp-notes-cancel" value="<?php esc_attr_e( 'Close', 'mainwp' ); ?>"/>
1949 - <input type="hidden" id="mainwp-notes-websiteid" value=""/>
1950 - <input type="hidden" id="mainwp-notes-slug" value=""/>
1951 - <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
1952 - <input type="hidden" id="mainwp-notes-itemid" value=""/>
1953 - </div>
1954 - </div>
1955 - </div>
1956 - </div>
2046 + if ( 'mainwp_page_manageclients' === $page ) {
2047 + $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
2048 + } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
2049 + $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
2050 + } else {
2051 + $show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
2052 + }
1957 2053
1958 - <?php
1959 - }
2054 + if ( ! is_array( $show_widgets ) ) {
2055 + $show_widgets = array();
2056 + }
1960 2057
1961 - /**
1962 - * No Sites Modal
1963 - *
1964 - * Renders modal window for notification when there are no connected sites.
1965 - *
1966 - * @return void
1967 - */
1968 - public static function render_modal_no_sites_note() {
1969 - if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-no-sites-modal-notice' ) ) :
1970 - ?>
1971 - <div id="mainwp-no-sites-modal" class="ui small modal">
1972 - <div class="content" id="mainwp-no-sites-modal-content" style="text-align:center">
1973 - <div class="ui hidden divider"></div>
1974 - <div class="ui hidden divider"></div>
1975 - <h4><?php esc_html_e( 'Hi MainWP Manager, there is not anything to see here before connecting your first site.', 'mainwp' ); ?></h4>
1976 - <div class="ui hidden divider"></div>
1977 - <div class="ui hidden divider"></div>
1978 - <a href="admin.php?page=managesites&do=new" class="ui big green button"><?php esc_html_e( 'Connect Your WordPress Site', 'mainwp' ); ?></a>
1979 - <div class="ui hidden fitted divider"></div>
1980 - <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>
1981 - </div>
1982 - <div class="actions">
1983 - <div class="ui grid">
1984 - <div class="eight wide left aligned middle aligned column">
1985 - <a href="https://kb.mainwp.com/docs/add-site-to-your-dashboard/" class="ui basic green mini button" target="_blank"><?php esc_html_e( 'See How to Connect Sites', 'mainwp' ); ?></a>
1986 - </div>
1987 - <div class="eight wide column">
1988 - <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' ); ?>"/>
1989 - </div>
1990 - </div>
1991 - </div>
1992 - </div>
1993 - <script type="text/javascript">
1994 - jQuery( '#mainwp-no-sites-modal' ).modal( {
1995 - blurring: true,
1996 - inverted: true,
1997 - closable: false
1998 - } ).modal( 'show' );
1999 - </script>
2000 - <?php
2001 - endif;
2002 - }
2058 + if ( $selected_widget_layout ) {
2059 + // to support saving selected layout.
2060 + ?>
2061 + <input type="hidden" id="mainwp-widgets-selected-layout" layout-name="<?php echo esc_attr( $selected_layout['name'] ); ?>" layout-idx="<?php echo esc_attr( $layid ); ?>" data-save-on-load="true" >
2062 + <?php
2063 + }
2064 + ?>
2065 + <div id="mainwp-grid-stack-wrapper" class="grid-stack">
2066 + <?php
2067 + if ( isset( $mainwp_widget_boxes[ $page ] ) ) {
2068 + foreach ( (array) $mainwp_widget_boxes[ $page ] as $box ) {
2069 + if ( false === $box || ! isset( $box['callback'] ) ) {
2070 + continue;
2071 + }
2003 2072
2004 - /**
2005 - * Method render_screen_options()
2006 - *
2007 - * Render modal window for Page Settings.
2008 - *
2009 - * @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Overview page.
2010 - *
2011 - * @return void Render modal window for Page Settings html.
2012 - */
2013 - public static function render_screen_options( $setting_page = true ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated.
2073 + // to avoid hidden widgets.
2074 + if ( isset( $show_widgets[ $box['id'] ] ) && 0 === (int) $show_widgets[ $box['id'] ] ) {
2075 + continue;
2076 + }
2014 2077
2015 - $default_widgets = array(
2016 - 'overview' => esc_html__( 'Updates Overview', 'mainwp' ),
2017 - 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
2018 - 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
2019 - 'plugins' => esc_html__( 'Plugins (Individual Site Overview page)', 'mainwp' ),
2020 - 'themes' => esc_html__( 'Themes (Individual Site Overview page)', 'mainwp' ),
2021 - 'connection_status' => esc_html__( 'Connection Status', 'mainwp' ),
2022 - 'security_issues' => esc_html__( 'Security Issues', 'mainwp' ),
2023 - 'notes' => esc_html__( 'Notes (Individual Site Overview page)', 'mainwp' ),
2024 - 'clients' => esc_html__( 'Clients', 'mainwp' ),
2025 - 'child_site_info' => esc_html__( 'Child site info (Individual Site Overview page)', 'mainwp' ),
2026 - 'client_info' => esc_html__( 'Client info (Individual Site Overview page)', 'mainwp' ),
2027 - 'non_mainwp_changes' => esc_html__( 'Non-MainWP Changes', 'mainwp' ),
2028 - );
2078 + $layout = array();
2079 + if ( isset( $wgsorted[ $box['id'] ] ) ) {
2080 + $val = $wgsorted[ $box['id'] ];
2081 + if ( is_array( $val ) && ( isset( $val['x'] ) || isset( $val['w'] ) ) ) {
2082 + $layout = array(
2083 + 'x' => $val['x'],
2084 + 'y' => $val['y'],
2085 + 'w' => $val['w'],
2086 + 'h' => $val['h'],
2087 + );
2088 + }
2089 + }
2029 2090
2030 - $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.
2091 + // init widget layout settings.
2092 + if ( ! isset( $layout['x'] ) && ! isset( $layout['w'] ) && isset( $box['layout']['2'] ) ) {
2093 + $layout = array(
2094 + 'x' => $box['layout']['0'],
2095 + 'y' => $box['layout']['1'],
2096 + 'w' => $box['layout']['2'],
2097 + 'h' => $box['layout']['3'],
2098 + );
2099 + }
2031 2100
2032 - /**
2033 - * Filter: mainwp_widgets_screen_options
2034 - *
2035 - * Filters available widgets on the Overview page allowing users to unsent unwanted widgets.
2036 - *
2037 - * @since 4.0
2038 - */
2039 - $custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts );
2101 + $layout_attrs_escaped = '';
2102 + if ( isset( $layout['x'] ) && (int) $layout['x'] >= 0 ) {
2103 + $layout_attrs_escaped .= ' gs-x="' . esc_attr( $layout['x'] ) . '"';
2104 + }
2105 + if ( isset( $layout['y'] ) && (int) $layout['y'] >= 0 ) {
2106 + $layout_attrs_escaped .= ' gs-y="' . esc_attr( $layout['y'] ) . '"';
2107 + }
2108 + if ( isset( $layout['w'] ) && (int) $layout['w'] > 0 ) {
2109 + $layout_attrs_escaped .= ' gs-w="' . esc_attr( $layout['w'] ) . '"';
2110 + }
2111 + if ( isset( $layout['h'] ) && (int) $layout['h'] > 0 ) {
2112 + $layout_attrs_escaped .= ' gs-h="' . esc_attr( $layout['h'] ) . '"';
2113 + }
2040 2114
2041 - if ( is_array( $custom_opts ) && 0 < count( $custom_opts ) ) {
2042 - $default_widgets = array_merge( $default_widgets, $custom_opts );
2043 - }
2115 + echo '<div id="widget-' . esc_html( $box['id'] ) . '" class="grid-stack-item" ' . $layout_attrs_escaped . '>' . "\n"; //phpcs:ignore -- escaped.
2116 + echo '<div class="grid-stack-item-content ui segment mainwp-widget">' . "\n";
2117 + call_user_func( $box['callback'], $screen_id, $args );
2118 + echo "</div>\n";
2119 + echo "</div>\n";
2044 2120
2045 - $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
2121 + }
2122 + }
2123 + ?>
2124 + </div>
2125 + <script type="text/javascript">
2126 + let page_sortablewidgets = '<?php echo esc_js( $page ); ?>';
2127 + let page_widget = '<?php echo esc_js( $page_widget ); ?>';
2128 + jQuery( document ).ready( function( $ ) {
2129 + let wgIds = [];
2130 + jQuery( ".mainwp-widget" ).each( function () {
2131 + wgIds.push( jQuery( this ).attr('id') );
2132 + } );
2133 + let gsOpts = {
2134 + auto: true,
2135 + cellHeight: '1rem',
2136 + float: false,
2137 + resizable: {
2138 + handles: 'e,se,s,sw,w'
2139 + },
2140 + margin: '1rem',
2141 + itemClass: 'grid-stack-item',
2142 + handleClass: 'handle-drag',
2143 + columnOpts: {
2144 + breakpointForWindow: true, // test window vs grid size
2145 + breakpoints: [{w:768, c:1}],
2146 + },
2147 + }
2148 + let grid = GridStack.init(gsOpts);
2046 2149
2047 - if ( ! is_array( $show_widgets ) ) {
2048 - $show_widgets = array();
2049 - }
2150 + grid.on('change', function() {
2151 + mainwp_overview_gridstack_save_layout(<?php echo (int) $client_id; ?>, grid);
2152 + });
2050 2153
2051 - $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
2052 - $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
2053 - $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
2154 + if (jQuery('#mainwp-widgets-selected-layout[data-save-on-load="true"]').length) {
2155 + mainwp_overview_gridstack_save_layout(<?php echo (int) $client_id; ?>, grid);
2156 + }
2054 2157
2055 - /**
2056 - * Action: mainwp_screen_options_modal_top
2057 - *
2058 - * Fires at the top of the Page Settings modal element.
2059 - *
2060 - * @since 4.1
2061 - */
2062 - do_action( 'mainwp_screen_options_modal_top' );
2063 - $which_settings = 'overview_settings';
2064 - ?>
2065 - <?php if ( ! $setting_page ) : ?>
2066 - <?php if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2067 - <?php
2068 - $which_settings = 'sidebar_settings';
2069 - $sidebarPosition = (int) get_user_option( 'mainwp_sidebarPosition', 1 );
2070 - $manageGroupsPage = false;
2071 - if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2072 - $manageGroupsPage = true;
2073 - }
2074 - ?>
2075 - <div class="ui grid field">
2076 - <label tabindex="0" class="six wide column middle aligned"><?php echo $manageGroupsPage ? esc_html__( 'Tags menu position', 'mainwp' ) : esc_html__( 'Sidebar position', 'mainwp' ); ?></label>
2077 - <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">
2078 - <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
2079 - <option value="1" <?php echo ( 1 === $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Right', 'mainwp' ); ?></option>
2080 - <option value="0" <?php echo ( 0 === $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
2081 - </select>
2082 - </div>
2083 - </div>
2084 - <?php endif; ?>
2085 - <?php endif; ?>
2086 - <?php if ( isset( $_GET['page'] ) && ! in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2087 - <div class="ui grid field">
2088 - <label class="six wide column middle aligned"><?php esc_html_e( 'Hide the Update Everything button', 'mainwp' ); ?></label>
2089 - <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">
2090 - <input type="checkbox" name="hide_update_everything" <?php echo ( ( 1 === (int) get_option( 'mainwp_hide_update_everything' ) ) ? 'checked="true"' : '' ); ?> />
2091 - </div>
2092 - </div>
2093 - <div class="ui grid field">
2094 - <label class="six wide column"><?php esc_html_e( 'Show widgets', 'mainwp' ); ?></label>
2095 - <div class="ten wide column" <?php echo $setting_page ? 'data-tooltip="' . esc_attr_e( 'Select widgets that you want to hide in the MainWP Overview page.', 'mainwp' ) . '"' : ''; ?> data-inverted="" data-position="top left">
2096 - <ul class="mainwp_hide_wpmenu_checkboxes">
2097 - <?php
2098 - foreach ( $default_widgets as $name => $title ) {
2099 - $_selected = '';
2100 - if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
2101 - $_selected = 'checked';
2102 - }
2103 - ?>
2104 - <li>
2105 - <div class="ui checkbox">
2106 - <input type="checkbox" id="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" name="mainwp_show_widgets[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
2107 - <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
2108 - </div>
2109 - <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
2110 - </li>
2111 - <?php
2112 - }
2113 - ?>
2114 - </ul>
2115 - </div>
2116 - </div>
2117 - <?php endif; ?>
2118 - <input type="hidden" name="reset_overview_which_settings" value="<?php echo esc_html( $which_settings ); ?>" />
2119 - <?php
2120 - /**
2121 - * Action: mainwp_screen_options_modal_bottom
2122 - *
2123 - * Fires at the bottom of the Page Settings modal element.
2124 - *
2125 - * @since 4.1
2126 - */
2127 - do_action( 'mainwp_screen_options_modal_bottom' );
2128 - }
2158 + jQuery('#mainwp-widgets-placeholder').dimmer('hide');
2159 + });
2160 + </script>
2161 + <?php
2162 + }
2129 2163
2130 - /**
2131 - * Method render_select_mainwp_themes_modal()
2132 - *
2133 - * Render modal window for mainwp themes selection.
2134 - *
2135 - * @return void Render modal window for themes selection.
2136 - */
2137 - public static function render_select_mainwp_themes_modal() {
2138 - ?>
2139 - <div class="ui modal" id="mainwp-select-mainwp-themes-modal">
2140 - <i class="close icon"></i>
2141 - <div class="header"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></div>
2142 - <div class="content ui form">
2143 - <div class="ui blue message">
2144 - <div class=""><?php printf( esc_html__( 'Did you know you can create your custom theme? %1$sSee here how to do it%2$s!', '' ), '<a href="https://kb.mainwp.com/docs/how-to-change-the-theme-for-mainwp/" target="_blank">', '</a>' ); ?></div>
2145 - </div>
2146 - <form method="POST" action="" name="mainwp_select_mainwp_themes_form" id="mainwp_select_mainwp_themes_form">
2147 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2148 - <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPSelectThemes' ) ); ?>" />
2149 - <?php
2150 - /**
2151 - * Action: mainwp_select_themes_modal_top
2152 - *
2153 - * Fires at the top of the modal.
2154 - *
2155 - * @since 4.3
2156 - */
2157 - do_action( 'mainwp_select_themes_modal_top' );
2164 + /**
2165 + * Method add_bulkpost_widget_box()
2166 + *
2167 + * @param mixed $boxid box id.
2168 + * @param mixed $params parameters.
2169 + */
2170 + public static function add_bulkpost_widget_box( $boxid, $params ) {
2171 + /**
2172 + * MainWP widget boxes array.
2173 + *
2174 + * @global object
2175 + */
2176 + global $wp_meta_boxes;
2158 2177
2159 - MainWP_Settings::get_instance()->render_select_custom_themes();
2178 + $screen_page_id = MainWP_System_Utility::get_page_id();
2160 2179
2161 - /**
2162 - * Action: mainwp_select_themes_modal_bottom
2163 - *
2164 - * Fires at the bottom of the modal.
2165 - *
2166 - * @since 4.3
2167 - */
2168 - do_action( 'mainwp_select_themes_modal_bottom' );
2169 - ?>
2170 - </div>
2171 - <div class="actions">
2172 - <div class="ui two columns grid">
2173 - <div class="left aligned column">
2174 -
2175 - </div>
2176 - <div class="ui right aligned column">
2177 - <input type="submit" class="ui green button" id="submit-select-mainwp-themes" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2178 - </div>
2179 - </div>
2180 - </div>
2181 - </form>
2182 - </div>
2183 - <?php
2184 - }
2180 + if ( empty( $screen_page_id ) ) {
2181 + return;
2182 + }
2185 2183
2186 - /**
2187 - * Method render_install_extensions_promo_modal()
2188 - */
2189 - public static function render_install_extensions_promo_modal() {
2190 - $mainwp_api_key = MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key();
2191 - ?>
2192 - <div class="ui small modal" id="mainwp-install-extensions-promo-modal">
2193 - <i class="close icon"></i>
2194 - <?php if ( empty( $mainwp_api_key ) ) : ?>
2195 - <div class="header"><?php esc_html_e( 'Get MainWP Pro', 'mainwp' ); ?></div>
2196 - <div class="content">
2197 - <div class="ui header"><?php esc_html_e( 'With your MainWP Pro subscription, you get access to:', 'mainwp' ); ?></div>
2198 - <div class="ui bulleted list">
2199 - <div class="item"><?php esc_html_e( 'All 30+ Existing Premium Extensions', 'mainwp' ); ?></div>
2200 - <div class="item"><?php esc_html_e( 'All Future Extensions', 'mainwp' ); ?></div>
2201 - <div class="item"><?php esc_html_e( 'Critical Security & Performance Updates', 'mainwp' ); ?></div>
2202 - <div class="item"><?php esc_html_e( 'Priority Support with Subscription', 'mainwp' ); ?></div>
2203 - <div class="item"><?php esc_html_e( 'Manage Unlimited Websites', 'mainwp' ); ?></div>
2204 - </div>
2205 - <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>
2206 - </div>
2207 - <?php else : ?>
2208 - <div class="header"><?php esc_html_e( 'Install Extensions', 'mainwp' ); ?></div>
2209 - <div class="content">
2210 - <div class="ui header"><?php esc_html_e( 'Extension not activated', 'mainwp' ); ?></div>
2211 - <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>
2212 - </div>
2213 - <?php endif; ?>
2214 - </div>
2215 - <?php
2216 - }
2184 + if ( ! is_array( $params ) ) {
2185 + $params = array();
2186 + }
2217 2187
2218 - /**
2219 - * Method render_empty_element_placeholder()
2220 - *
2221 - * Renders the content for empty elements.
2222 - *
2223 - * @param string $placeholder Placelolder text.
2224 - */
2225 - public static function render_empty_element_placeholder( $placeholder = '' ) {
2226 - ?>
2227 - <div class="ui one column grid" style="height:100%">
2228 - <div class="middle aligned center aligned column">
2229 - <img src="/wp-content/plugins/mainwp/assets/images/mainwp-widget-placeholder.png" class="mainwp-no-results-placeholder"/>
2230 - <?php if ( '' !== $placeholder ) : ?>
2231 - <p><?php echo $placeholder; //phpcs:ignore -- requires escaped. ?></p>
2232 - <?php else : ?>
2233 - <p><?php echo esc_html__( 'Nothing to show here, check back later!', 'mainwp' ); ?></p>
2234 - <?php endif; ?>
2235 - </div>
2236 - </div>
2237 - <?php
2238 - }
2188 + if ( ! isset( $wp_meta_boxes ) ) {
2189 + $wp_meta_boxes = array(); //phpcs:ignore -- NOSONAR - ok.
2190 + }
2191 +
2192 + $page = MainWP_Post::get_fix_metabox_page( $screen_page_id );
2193 +
2194 + if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
2195 + $wp_meta_boxes[ $page ] = array(); //phpcs:ignore -- NOSONAR - ok.
2196 + }
2197 +
2198 + $context = ! empty( $params['context'] ) ? $params['context'] : 'normal';
2199 + $priority = ! empty( $params['priority'] ) ? $params['priority'] : 'default';
2200 +
2201 + if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
2202 + $wp_meta_boxes[ $page ][ $context ] = array(); //phpcs:ignore -- NOSONAR - ok.
2203 + }
2204 +
2205 + if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
2206 + $wp_meta_boxes[ $page ][ $context ][ $priority ] = array(); //phpcs:ignore -- NOSONAR - ok.
2207 + }
2208 +
2209 + if ( ! empty( $params['id'] ) ) {
2210 + $params['id'] = 'bulkpost-metabox-' . $params['id'];
2211 + } else {
2212 + $params['id'] = '';
2213 + }
2214 +
2215 + if ( empty( $params['metabox-custom'] ) ) {
2216 + $params['metabox-custom'] = 'bulkpost';
2217 + }
2218 + $wp_meta_boxes[ $page ][ $context ][ $priority ][ $boxid ] = $params; //phpcs:ignore -- NOSONAR - ok.
2219 + }
2220 +
2221 + /**
2222 + * Method render_empty_bulk_actions()
2223 + *
2224 + * Render empty bulk actions when drop down is disabled.
2225 + */
2226 + public static function render_empty_bulk_actions() {
2227 + ?>
2228 + <select class="ui disabled dropdown" id="mainwp-bulk-actions">
2229 + <option value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
2230 + </select>
2231 + <button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
2232 + <?php
2233 + }
2234 +
2235 + /**
2236 + * Method render_modal_install_plugin_theme()
2237 + *
2238 + * Render modal window for installing plugins & themes.
2239 + *
2240 + * @param string $what Which window to render, plugin|theme.
2241 + */
2242 + public static function render_modal_install_plugin_theme( $what = 'plugin' ) {
2243 + ?>
2244 + <div id="plugintheme-installation-progress-modal" class="ui modal">
2245 + <i class="close icon"></i>
2246 + <div class="header">
2247 + <?php
2248 + if ( 'plugin' === $what ) {
2249 + esc_html_e( 'Plugin Installation', 'mainwp' );
2250 + } elseif ( 'theme' === $what ) {
2251 + esc_html_e( 'Theme Installation', 'mainwp' );
2252 + }
2253 + ?>
2254 + </div>
2255 + <div class="ui green progress mainwp-modal-progress">
2256 + <div class="bar"><div class="progress"></div></div>
2257 + <div class="label"></div>
2258 + </div>
2259 + <div class="scrolling content">
2260 + <?php
2261 + /**
2262 + * Action: mainwp_before_plugin_theme_install_progress
2263 + *
2264 + * Fires before the progress list in the install modal element.
2265 + *
2266 + * @since 4.1
2267 + */
2268 + do_action( 'mainwp_before_plugin_theme_install_progress' );
2269 + ?>
2270 + <div id="plugintheme-installation-queue"></div>
2271 + <?php
2272 + /**
2273 + * Action: mainwp_after_plugin_theme_install_progress
2274 + *
2275 + * Fires after the progress list in the install modal element.
2276 + *
2277 + * @since 4.1
2278 + */
2279 + do_action( 'mainwp_after_plugin_theme_install_progress' );
2280 + ?>
2281 + </div>
2282 + <div class="actions" item-type="<?php echo esc_attr( $what ); ?>">
2283 + <?php
2284 + /**
2285 + * Action: mainwp_after_plugin_theme_install_progress
2286 + *
2287 + * Fires after the progress list in the install modal element.
2288 + *
2289 + * @since 4.1
2290 + */
2291 + do_action( 'mainwp_install_plugin_theme_modal_action', $what );
2292 + ?>
2293 +
2294 + </div>
2295 + </div>
2296 + <?php
2297 + }
2298 +
2299 + /**
2300 + * Method render_modal_upload_icon()
2301 + *
2302 + * Render modal window for upload plugins & themes icon.
2303 + */
2304 + public static function render_modal_upload_icon() {
2305 +
2306 + ?>
2307 + <div id="mainwp-upload-custom-icon-modal" class="ui modal">
2308 + <i class="close icon"></i>
2309 + <div class="header">
2310 + <?php
2311 + esc_html_e( 'Upload Icon', 'mainwp' );
2312 + ?>
2313 + </div>
2314 + <div class="content" id="mainwp-upload-custom-icon-content">
2315 + <form action="" method="post" enctype="multipart/form-data" name="uploadicon_form" id="uploadicon_form" class="">
2316 + <?php self::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
2317 + <div class="ui message" id="mainwp-message-zone-upload" style="display:none;"></div>
2318 + <?php
2319 + /**
2320 + * Action: mainwp_after_upload_custom_icon
2321 + *
2322 + * Fires before the modal element.
2323 + *
2324 + * @since 4.3
2325 + */
2326 + do_action( 'mainwp_before_upload_custom_icon' );
2327 + ?>
2328 + <div class="ui form">
2329 + <div class="ui grid field">
2330 + <label class="six wide column middle aligned"><?php esc_html_e( 'Custom icon', 'mainwp' ); ?></label>
2331 + <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2332 + <div class="ui file input">
2333 + <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' ); ?>" />
2334 + </div>
2335 + </div>
2336 + </div>
2337 + <div class="ui grid field" id="mainwp_delete_image_field">
2338 + <label class="six wide column middle aligned"></label>
2339 + <div class="six wide column">
2340 + <img class="ui tiny image" src="" alt="<?php esc_attr_e( 'Icon to remove.', 'mainwp' ); ?>"/><br/>
2341 + <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, delete image.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2342 + <input type="checkbox"id="mainwp_delete_image_chk" item-icon-id="" />
2343 + <label for="mainwp_delete_image_chk"><?php esc_html_e( 'Delete Image', 'mainwp' ); ?></label>
2344 + </div>
2345 + </div>
2346 + </div>
2347 + </div>
2348 + <?php
2349 + /**
2350 + * Action: mainwp_after_upload_custom_icon
2351 + *
2352 + * Fires after the modal element.
2353 + *
2354 + * @since 4.3
2355 + */
2356 + do_action( 'mainwp_after_upload_custom_icon' );
2357 + ?>
2358 + </form>
2359 + </div>
2360 + <div class="actions">
2361 + <div class="ui green button" uploading-icon="default" id="update_custom_icon_btn"><?php esc_html_e( 'Update', 'mainwp' ); ?></div>
2362 + </div>
2363 + </div>
2364 + <?php
2365 + }
2366 +
2367 + /**
2368 + * Method render_show_all_updates_button()
2369 + *
2370 + * Render show all updates button.
2371 + *
2372 + * @return void Render Show All Updates button html.
2373 + */
2374 + public static function render_show_all_updates_button() {
2375 + ?>
2376 + <a href="javascript:void(0)" class="ui mini button trigger-all-accordion mainwp-show-all-updates-button">
2377 + <?php
2378 + /**
2379 + * Filter: mainwp_show_all_updates_button_text
2380 + *
2381 + * Filters the Show All Updates button text.
2382 + *
2383 + * @since 4.1
2384 + */
2385 + echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', esc_html__( 'Show All Updates', 'mainwp' ) ) );
2386 + ?>
2387 + </a>
2388 + <?php
2389 + }
2390 +
2391 + /**
2392 + * Method render_sorting_icons()
2393 + *
2394 + * Render sorting up & down icons.
2395 + *
2396 + * @return void Render Sort up & down incon html.
2397 + */
2398 + public static function render_sorting_icons() {
2399 + ?>
2400 + <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"></i>
2401 + <?php
2402 + }
2403 +
2404 + /**
2405 + * Method render_modal_edit_notes()
2406 + *
2407 + * Render modal window for edit notes.
2408 + *
2409 + * @param string $what What modal window to render. Default = site.
2410 + *
2411 + * @return void
2412 + */
2413 + public static function render_modal_edit_notes( $what = 'site' ) {
2414 + ?>
2415 + <div id="mainwp-notes-modal" class="ui modal">
2416 + <i class="close icon" id="mainwp-notes-cancel"></i>
2417 + <div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div>
2418 + <div class="content" id="mainwp-notes-content">
2419 + <div id="mainwp-notes-status" class="ui message hidden"></div>
2420 + <?php
2421 + /**
2422 + * Action: mainwp_before_edit_site_note
2423 + *
2424 + * Fires before the site note content in the Edit Note modal element.
2425 + *
2426 + * @since 4.1
2427 + */
2428 + do_action( 'mainwp_before_edit_site_note' );
2429 + ?>
2430 + <div id="mainwp-notes-html"></div>
2431 + <div id="mainwp-notes-editor" class="ui form" style="display:none;">
2432 + <div class="field">
2433 + <label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label>
2434 + <textarea id="mainwp-notes-note"></textarea>
2435 + </div>
2436 + <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>
2437 + </div>
2438 + <?php
2439 + /**
2440 + * Action: mainwp_after_edit_site_note
2441 + *
2442 + * Fires after the site note content in the Edit Note modal element.
2443 + *
2444 + * @since 4.1
2445 + */
2446 + do_action( 'mainwp_after_edit_site_note' );
2447 + ?>
2448 + </div>
2449 + <div class="actions">
2450 + <div class="ui grid">
2451 + <div class="eight wide left aligned middle aligned column">
2452 + <input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save Note', 'mainwp' ); ?>" style="display:none;"/>
2453 + <input type="button" class="ui green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit Note', 'mainwp' ); ?>"/>
2454 + </div>
2455 + <div class="eight wide column">
2456 + <input type="hidden" id="mainwp-notes-websiteid" value=""/>
2457 + <input type="hidden" id="mainwp-notes-slug" value=""/>
2458 + <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
2459 + <input type="hidden" id="mainwp-notes-itemid" value=""/>
2460 + </div>
2461 + </div>
2462 + </div>
2463 + </div>
2464 + <?php
2465 + }
2466 +
2467 + /**
2468 + * No Sites Modal
2469 + *
2470 + * Renders modal window for notification when there are no connected sites.
2471 + *
2472 + * @return void
2473 + */
2474 + public static function render_modal_no_sites_note() {
2475 + if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-no-sites-modal-notice' ) ) :
2476 + ?>
2477 + <div id="mainwp-no-sites-modal" class="ui small modal">
2478 + <div class="content" id="mainwp-no-sites-modal-content" style="text-align:center">
2479 + <div class="ui hidden divider"></div>
2480 + <div class="ui hidden divider"></div>
2481 + <h4><?php esc_html_e( 'Hi MainWP Manager, there is not anything to see here before connecting your first site.', 'mainwp' ); ?></h4>
2482 + <div class="ui hidden divider"></div>
2483 + <div class="ui hidden divider"></div>
2484 + <a href="admin.php?page=managesites&do=new" class="ui big green button"><?php esc_html_e( 'Connect Your WordPress Site', 'mainwp' ); ?></a>
2485 + <div class="ui hidden fitted divider"></div>
2486 + <small><?php /* translators: 1: Opening anchor tag for bulk import link, 2: Closing anchor tag. */ printf( esc_html__( 'or you can %1$sbulk import%2$s your sites.', 'mainwp' ), '<a href="admin.php?page=managesites&do=bulknew">', '</a>' ); ?></small>
2487 + </div>
2488 + <div class="actions">
2489 + <div class="ui grid">
2490 + <div class="eight wide left aligned middle aligned column">
2491 + <a href="https://docs.mainwp.com/getting-started/get-started-with-mainwp" class="ui basic green mini button" target="_blank"><?php esc_html_e( 'See How to Connect Sites', 'mainwp' ); // NOSONAR - noopener - open safe. ?></a>
2492 + </div>
2493 + <div class="eight wide column">
2494 + <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' ); ?>"/>
2495 + </div>
2496 + </div>
2497 + </div>
2498 + </div>
2499 + <script type="text/javascript">
2500 + jQuery( '#mainwp-no-sites-modal' ).modal( {
2501 + blurring: true,
2502 + inverted: true,
2503 + closable: false
2504 + } ).modal( 'show' );
2505 + </script>
2506 + <?php
2507 + endif;
2508 + }
2509 +
2510 + /**
2511 + * Help Modal
2512 + *
2513 + * Renders the help modal.
2514 + *
2515 + * @return void
2516 + */
2517 + public static function render_help_modal() { //phpcs:ignore -- NOSONAR - complex.
2518 + $siteViewMode = MainWP_Utility::get_siteview_mode();
2519 +
2520 + // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized.Recommended
2521 + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
2522 +
2523 + $tour_id = '';
2524 + $video_id = '';
2525 + if ( 'mainwp_tab' === $page ) {
2526 + $tour_id = '13112';
2527 + $video_id = 'VZeUhuihddw';
2528 + } elseif ( 'managesites' === $page ) {
2529 + if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) {
2530 + $tour_id = '13210';
2531 + $video_id = 'k1-4x6h0LfE';
2532 + } elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) {
2533 + $tour_id = '60206';
2534 + } elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
2535 + if ( 'grid' === $siteViewMode ) {
2536 + $tour_id = '27217';
2537 + } else {
2538 + $tour_id = '29331';
2539 + }
2540 + }
2541 + } elseif ( 'MonitoringSites' === $page ) {
2542 + $tour_id = '29003';
2543 + } elseif ( 'ManageClients' === $page ) {
2544 + if ( isset( $_GET['client_id'] ) ) {
2545 + $tour_id = '28258';
2546 + } else {
2547 + $tour_id = '28240';
2548 + }
2549 + } elseif ( 'ClientAddNew' === $page ) {
2550 + if ( isset( $_GET['client_id'] ) ) {
2551 + $tour_id = '28962';
2552 + } else {
2553 + $tour_id = '28256';
2554 + }
2555 + $video_id = '8Th7bSZAHjw';
2556 + } elseif ( 'ClientAddField' === $page ) {
2557 + $tour_id = '28257';
2558 + } elseif ( 'PluginsManage' === $page ) {
2559 + $tour_id = '28510';
2560 + $video_id = 'p0pB7mXoIYw';
2561 + } elseif ( 'ManageGroups' === $page ) {
2562 + $tour_id = '27275';
2563 + } elseif ( 'UpdatesManage' === $page ) {
2564 + $video_id = 'igOn8wOBcAQ';
2565 + $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
2566 + if ( 'plugins-updates' === $tab ) {
2567 + $tour_id = '28259';
2568 + } elseif ( 'themes-updates' === $tab ) {
2569 + $tour_id = '28447';
2570 + } elseif ( 'wordpress-updates' === $tab ) {
2571 + $tour_id = '29005';
2572 + } elseif ( 'translations-updates' === $tab ) {
2573 + $tour_id = '29007';
2574 + } elseif ( 'abandoned-plugins' === $tab ) {
2575 + $tour_id = '29008';
2576 + } elseif ( 'abandoned-themes' === $tab ) {
2577 + $tour_id = '29009';
2578 + } elseif ( 'plugin-db-updates' === $tab ) {
2579 + $tour_id = '33161';
2580 + } else {
2581 + $tour_id = '28259';
2582 + }
2583 + } elseif ( 'PluginsInstall' === $page ) {
2584 + $tour_id = '29011';
2585 + } elseif ( 'PluginsAutoUpdate' === $page ) {
2586 + $tour_id = '29015';
2587 + } elseif ( 'PluginsIgnore' === $page ) {
2588 + $tour_id = '29018';
2589 + } elseif ( 'PluginsIgnoredAbandoned' === $page ) {
2590 + $tour_id = '29329';
2591 + } elseif ( 'ThemesManage' === $page ) {
2592 + $tour_id = '28511';
2593 + $video_id = 'fWYBTWNL9gw';
2594 + } elseif ( 'ThemesInstall' === $page ) {
2595 + $tour_id = '29010';
2596 + } elseif ( 'ThemesAutoUpdate' === $page ) {
2597 + $tour_id = '29016';
2598 + } elseif ( 'ThemesIgnore' === $page ) {
2599 + $tour_id = '29019';
2600 + } elseif ( 'ThemesIgnoredAbandoned' === $page ) {
2601 + $tour_id = '29330';
2602 + } elseif ( 'UserBulkManage' === $page ) {
2603 + $tour_id = '28574';
2604 + $video_id = 'lvzpE04nsTs';
2605 + } elseif ( 'UserBulkAdd' === $page ) {
2606 + $tour_id = '28575';
2607 + } elseif ( 'BulkImportUsers' === $page ) {
2608 + $tour_id = '28736';
2609 + } elseif ( 'UpdateAdminPasswords' === $page ) {
2610 + $tour_id = '28737';
2611 + } elseif ( 'PostBulkManage' === $page ) {
2612 + $tour_id = '28796';
2613 + $video_id = 'Z81gzO16K8o';
2614 + } elseif ( 'PostBulkAdd' === $page ) {
2615 + $tour_id = '28799';
2616 + } elseif ( 'PageBulkManage' === $page ) {
2617 + $tour_id = '29045';
2618 + $video_id = 'O4jG-GRHE2Q';
2619 + } elseif ( 'PageBulkAdd' === $page ) {
2620 + $tour_id = '29048';
2621 + } elseif ( 'Extensions' === $page ) {
2622 + $tour_id = '28800';
2623 + $video_id = 'FMkXqpRu6-E';
2624 + } elseif ( 'Settings' === $page ) {
2625 + $tour_id = '28883';
2626 + } elseif ( 'SettingsAdvanced' === $page ) {
2627 + $tour_id = '28886';
2628 + } elseif ( 'SettingsEmail' === $page ) {
2629 + $tour_id = '29054';
2630 + } elseif ( 'MainWPTools' === $page ) {
2631 + $tour_id = '29272';
2632 + } elseif ( 'RESTAPI' === $page ) {
2633 + $tour_id = '29273';
2634 + $video_id = 'BO-u1FlptY0';
2635 + } elseif ( 'ServerInformation' === $page ) {
2636 + $tour_id = '28873';
2637 + } elseif ( 'ServerInformationCron' === $page ) {
2638 + $tour_id = '28874';
2639 + } elseif ( 'ErrorLog' === $page ) {
2640 + $tour_id = '28876';
2641 + } elseif ( 'ActionLogs' === $page ) {
2642 + $tour_id = '28877';
2643 + } elseif ( 'ManageCostTracker' === $page ) {
2644 + $video_id = 'Q1aVVGpkJAQ';
2645 + } elseif ( 'CostTrackerAdd' === $page ) {
2646 + $video_id = 'Q1aVVGpkJAQ';
2647 + } elseif ( 'Extensions-Mainwp-Jetpack-Protect-Extension' === $page ) {
2648 + $tour_id = '31700';
2649 + } elseif ( 'Extensions-Mainwp-Jetpack-Scan-Extension' === $page ) {
2650 + $tour_id = '31694';
2651 + } elseif ( 'Extensions-Termageddon-For-Mainwp' === $page ) {
2652 + $tour_id = '32104';
2653 + $video_id = 'HAHySipH22I';
2654 + } elseif ( 'Extensions-Advanced-Uptime-Monitor-Extension' === $page ) {
2655 + $tour_id = '32149';
2656 + $video_id = '3PIsyNM3OM0';
2657 + } elseif ( 'Extensions-Mainwp-Custom-Dashboard-Extension' === $page ) {
2658 + $tour_id = '32150';
2659 + $video_id = 'T6jzvD3ogfw';
2660 + } elseif ( 'Extensions-Mainwp-Updraftplus-Extension' === $page ) {
2661 + $tour_id = '32151';
2662 + } elseif ( 'Extensions-Mainwp-Sucuri-Extension' === $page ) {
2663 + $tour_id = '32152';
2664 + $video_id = 'bykz9YabuA8';
2665 + } elseif ( 'Extensions-Mainwp-Clean-And-Lock-Extension' === $page ) {
2666 + $tour_id = '32153';
2667 + $video_id = 'uCCDiPbqXUc';
2668 + } elseif ( 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' === $page ) {
2669 + $tour_id = '32851';
2670 + } elseif ( 'Extensions-Mainwp-Buddy-Extension' === $page ) {
2671 + $tour_id = '33064';
2672 + } elseif ( 'Extensions-Mainwp-Backwpup-Extension' === $page ) {
2673 + $tour_id = '32923';
2674 + } elseif ( 'Extensions-Mainwp-Ssl-Monitor-Extension' === $page ) {
2675 + $tour_id = '33164';
2676 + $video_id = 'HYb9xZ7Lxe0';
2677 + } elseif ( 'Extensions-Mainwp-Cache-Control-Extension' === $page ) {
2678 + $tour_id = '33167';
2679 + } elseif ( 'Extensions-Mainwp-Maintenance-Extension' === $page ) {
2680 + $tour_id = '33301';
2681 + } elseif ( 'Extensions-Mainwp-Domain-Monitor-Extension' === $page ) {
2682 + $tour_id = '66031';
2683 + $video_id = 'QMziJ1BxEcE';
2684 + } elseif ( 'Extensions-Mainwp-Favorites-Extension' === $page ) {
2685 + $tour_id = '66035';
2686 + $video_id = 'JRn7SLC4028';
2687 + } elseif ( 'Extensions-Mainwp-Regression-Testing-Extension' === $page ) {
2688 + $tour_id = '66037';
2689 + $video_id = 'rrynCqVxKSw';
2690 + } elseif ( 'Extension-Mainwp-Google-Analytics-Extension' === $page ) {
2691 + $video_id = 'BV0xTftH7as';
2692 + } elseif ( 'Extensions-Mainwp-Code-Snippets-Extension' === $page ) {
2693 + $video_id = 'Bl7rJzGmNU0';
2694 + } elseif ( 'Extensions-Mainwp-Article-Uploader-Extension' === $page ) {
2695 + $video_id = 'e8WoikPFyB0';
2696 + } elseif ( 'Extensions-Mainwp-Branding-Extension' === $page ) {
2697 + $video_id = 'kWvEVIpPEss';
2698 + } elseif ( 'Extensions-Mainwp-Time-Tracker-Extension' === $page ) {
2699 + $video_id = 'nvsKRp_rtiA';
2700 + } elseif ( 'Extensions-Mainwp-Comments-Extension' === $page ) {
2701 + $video_id = 'tCSX3z1KOOg';
2702 + } elseif ( 'Extensions-Mainwp-Lighthouse-Extension' === $page ) {
2703 + $video_id = 'GNYKJsoJso8';
2704 + } elseif ( 'Extensions-Mainwp-Rocket-Extension' === $page ) {
2705 + $video_id = 'qahq6cR7Svo';
2706 + }
2707 +
2708 + $enable_guided_tours = get_option( 'mainwp_enable_guided_tours', 0 );
2709 + $enable_guided_chatbase = get_option( 'mainwp_enable_guided_chatbase', 0 );
2710 + $enable_guided_video = get_option( 'mainwp_enable_guided_video', 0 );
2711 +
2712 + ?>
2713 + <div id="mainwp-help-modal" class="ui modal">
2714 + <i class="close icon"></i>
2715 + <div class="header"><?php esc_html_e( 'Support', 'mainwp' ); ?></div>
2716 +
2717 + <div class="scrolling center aligned content" id="mainwp-help-modal-content">
2718 + <div class="ui two cards" id="mainwp-help-modal-options">
2719 +
2720 + <div class="ui secondary card">
2721 + <div class="content">
2722 + <a id="mainwp-start-chat-card" class="<?php echo $enable_guided_chatbase ? '' : 'mainwp-disabled-link'; ?>" onclick="jQuery('#mainwp-update-permissions-button').fadeOut(200);jQuery('#mainwp-help-back-button').fadeIn(200);mainwp_help_modal_start_content_onclick( false, false, true );return false;">
2723 + <div class="header"><?php esc_html_e( 'Support Assistant', 'mainwp' ); ?></div>
2724 + <div class="ui hidden divider"></div>
2725 + <i class="robot big grey icon" style="opacity:0.5"></i>
2726 + <div class="ui fitted hidden divider"></div><br/>
2727 + <span class="ui grey small text"><?php esc_html_e( 'Chat with our AI Support Assistant for quick guidance and troubleshooting. It\'s trained on MainWP documentation to help you find answers faster.', 'mainwp' ); ?> <span class="ui mini green label">BETA</span></span>
2728 + </a>
2729 + </div>
2730 + <div class="content">
2731 + <div class="ui tiny left aligned list">
2732 + <div class="item" style="padding:0 0 0.21428571em 0;">
2733 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Database', 'mainwp' ); ?></div>
2734 + </div>
2735 + <div class="item" style="padding:0.21428571em 0;">
2736 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Screeen', 'mainwp' ); ?></div>
2737 + </div>
2738 + <div class="item" style="padding:0 0 0 0.21428571em;">
2739 + <i class="check green icon"></i> <div class="content"><?php esc_html_e( 'Processes only information you submit', 'mainwp' ); ?></div>
2740 + </div>
2741 + </div>
2742 + </div>
2743 + <div class="left aligned extra content">
2744 + <div class="ui toggle checkbox" id="mainwp-guided-chatbase-check">
2745 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp-guided-chatbase-option" id="mainwp-guided-chatbase-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_chatbase', 0 ) ? 'checked="true"' : ''; ?> />
2746 + <label><?php esc_html_e( 'Turn On / Turn Off', 'mainwp' ); ?></label>
2747 + </div>
2748 + </div>
2749 + </div>
2750 +
2751 + <div class="ui card">
2752 + <div class="content">
2753 + <a id="mainwp-start-tour-card" class="<?php echo $enable_guided_tours ? '' : 'mainwp-disabled-link'; ?>" onclick="jQuery('#mainwp-help-modal').modal('hide');mainwp_help_modal_start_content_onclick( <?php echo (int) $tour_id; ?> );" >
2754 + <div class="header"><?php esc_html_e( 'Take a Quick Tour', 'mainwp' ); ?></div>
2755 + <div class="ui hidden divider"></div>
2756 + <i class="map marked alternate big grey icon" style="opacity:0.5"></i>
2757 + <div class="ui fitted hidden divider"></div><br/>
2758 + <span class="ui grey small text"><?php esc_html_e( 'Learn how to navigate and use key features with an interactive step-by-step tour.', 'mainwp' ); ?></span>
2759 + </a>
2760 + <div class="ui mini green label"><?php esc_html_e( 'Recommended for first-time users.', 'mainwp' ); ?></div>
2761 + </div>
2762 + <div class="content">
2763 + <div class="ui tiny left aligned list">
2764 + <div class="item" style="padding:0 0 0.21428571em 0;">
2765 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Database', 'mainwp' ); ?></div>
2766 + </div>
2767 + <div class="item" style="padding:0.21428571em 0;">
2768 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Screen', 'mainwp' ); ?></div>
2769 + </div>
2770 + <div class="item" style="padding:0 0 0 0.21428571em;">
2771 + <i class="check green icon"></i> <div class="content"><?php esc_html_e( 'Processes only information you submit', 'mainwp' ); ?></div>
2772 + </div>
2773 + </div>
2774 + </div>
2775 + <div class="left aligned extra content">
2776 + <div class="ui toggle checkbox" id="mainwp-guided-tours-check" data-tooltip="<?php esc_attr_e( 'Changes apply after page reload', 'mainwp' ); ?>" data-position="top left" data-inverted="">
2777 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp-guided-tours-option" id="mainwp-guided-tours-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ? 'checked="true"' : ''; ?> />
2778 + <label><?php esc_html_e( 'Turn On / Turn Off', 'mainwp' ); ?></label>
2779 + </div>
2780 + </div>
2781 + </div>
2782 +
2783 + <div class="ui card">
2784 + <div class="content">
2785 + <a id="mainwp-start-video-card" class="<?php echo $enable_guided_video ? '' : 'mainwp-disabled-link'; ?>" <?php echo '' !== $video_id ? '' : 'style="display:none"'; ?> onclick="jQuery('#mainwp-update-permissions-button').fadeOut(200);jQuery('#mainwp-help-back-button').fadeIn(200);mainwp_help_modal_start_content_onclick( false, '<?php echo esc_js( $video_id ); ?>', false );return false;" >
2786 + <div class="header"><?php esc_html_e( 'MainWP 101 Video Tour', 'mainwp' ); ?></div>
2787 + <div class="ui hidden divider"></div>
2788 + <i class="youtube big grey icon" style="opacity:0.5"></i>
2789 + <div class="ui fitted hidden divider"></div><br/>
2790 + <span class="ui grey small text"><?php esc_html_e( 'Discover the essential features of this page in our quick, step-by-step video guide.', 'mainwp' ); ?></span>
2791 + </a>
2792 + </div>
2793 + <div class="content">
2794 + <div class="ui tiny left aligned list">
2795 + <div class="item" style="padding:0 0 0.21428571em 0;">
2796 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Database', 'mainwp' ); ?></div>
2797 + </div>
2798 + <div class="item" style="padding:0.21428571em 0;">
2799 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Screen', 'mainwp' ); ?></div>
2800 + </div>
2801 + <div class="item" style="padding:0 0 0 0.21428571em;">
2802 + <i class="check green icon"></i> <div class="content"><?php esc_html_e( 'Plays only when you activate it', 'mainwp' ); ?></div>
2803 + </div>
2804 + </div>
2805 + </div>
2806 + <div class="left aligned extra content">
2807 + <div class="ui toggle checkbox" id="mainwp-guided-video-check">
2808 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp-guided-video-option" id="mainwp-guided-video-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_video', 0 ) ? 'checked="true"' : ''; ?> />
2809 + <label><?php esc_html_e( 'Turn On / Turn Off', 'mainwp' ); ?></label>
2810 + </div>
2811 + </div>
2812 + </div>
2813 +
2814 + <div class="ui card">
2815 + <div class="content">
2816 + <a id="mainwp-ticket-form-card" target="_blank" href="https://community.mainwp.com/">
2817 + <div class="header"><?php esc_html_e( 'Contact MainWP Support', 'mainwp' ); ?></div>
2818 + <div class="ui hidden divider"></div>
2819 + <i class="ticket big grey icon" style="opacity:0.5"></i>
2820 + <div class="ui fitted hidden divider"></div><br/>
2821 + <span class="ui grey small text"><?php esc_html_e( 'Get in touch with our team for any inquiries or support ? we\'re here to help you.', 'mainwp' ); ?></span>
2822 +
2823 + </a>
2824 + </div>
2825 + <div class="content">
2826 + <div class="ui tiny left aligned list">
2827 + <div class="item" style="padding:0 0 0.21428571em 0;">
2828 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Database', 'mainwp' ); ?></div>
2829 + </div>
2830 + <div class="item" style="padding:0.21428571em 0;">
2831 + <i class="times red icon"></i> <div class="content"><?php esc_html_e( 'Access to your Screen', 'mainwp' ); ?></div>
2832 + </div>
2833 + <div class="item" style="padding:0 0 0 0.21428571em;">
2834 + <i class="check green icon"></i> <div class="content"><?php esc_html_e( 'Access to community knowledge', 'mainwp' ); ?></div>
2835 + </div>
2836 + </div>
2837 + </div>
2838 + <div class="left aligned extra content">
2839 + <div class="ui toggle disabled checked checkbox on-stop-propagation">
2840 + <input type="checkbox" class="" name="" id="" checked="true" />
2841 + <label><?php esc_html_e( 'Always On', 'mainwp' ); ?></label>
2842 + </div>
2843 + </div>
2844 + </div>
2845 +
2846 + </div>
2847 + <div style="display:none" id="mainwp-chatbase-chat-screen">
2848 + <iframe src="" width="100%" style="height: 100%; min-height: 600px;border: none;" title="MainWP Support Assistant"></iframe>
2849 + </div>
2850 + <div style="display:none;position:relative;padding-bottom:56.25%;height:0;" id="mainwp-chatbase-video-screen">
2851 + <iframe width="420" height="315" src="" style="position:absolute;top:0;left:0;width:100%;height:100%;border:none;" title="MainWP Video Tutorials"></iframe>
2852 + </div>
2853 + </div>
2854 + <div class="actions">
2855 + <div class="ui grid">
2856 + <div class="eight wide left aligned middle aligned column">
2857 + <a href="#" style="display:none" id="mainwp-help-back-button" class="ui mini basic button" onclick="jQuery('#mainwp-help-modal-options').fadeIn(200);jQuery('#mainwp-chatbase-video-screen').fadeOut(200);jQuery('#mainwp-chatbase-chat-screen').fadeOut(200);jQuery('#mainwp-help-back-button').fadeOut(200);jQuery('#mainwp-update-permissions-button').fadeIn(200);return false;"><i class="angle left icon"></i> <?php esc_html_e( 'Back to Support Options', 'mainwp' ); ?></a>
2858 + </div>
2859 + <div class="eight wide right aligned middle aligned column">
2860 + <a class="ui mini basic button" id="mainwp-update-permissions-button" onclick="mainwp_help_modal_content_onclick();return false;"><?php esc_html_e( 'Update Permissions', 'mainwp' ); ?></a>
2861 + </div>
2862 + </div>
2863 + </div>
2864 +
2865 + </div>
2866 + <script type="text/javascript">
2867 + // to fix not keyboard accessible issue.
2868 + document.querySelector('.ui.toggle.on-stop-propagation')
2869 + .addEventListener('keydown', function (event) {
2870 + if (event.key === 'Enter' || event.key === ' ') {
2871 + event.preventDefault();
2872 + event.stopPropagation();
2873 + }
2874 + });
2875 + </script>
2876 + <?php
2877 + }
2878 +
2879 + /**
2880 + * Method render_loader_element()
2881 + *
2882 + * Renders navigation loading dimmer element with click handlers.
2883 + *
2884 + * Displays a page dimmer with loading text that shows when users click
2885 + * on left menu items (level 0 and level 2). The dimmer provides visual
2886 + * feedback during page navigation transitions.
2887 + *
2888 + * @return void Outputs HTML dimmer element and JavaScript event handlers.
2889 + */
2890 + public static function render_loader_element() {
2891 + ?>
2892 + <div id="mainwp-nav-dimmer" class="ui page dimmer">
2893 + <div class="ui double text loader"><?php esc_html_e( 'Loading...', 'mainwp' ); ?></div>
2894 + </div>
2895 + <script>
2896 + jQuery( document ).ready( function () {
2897 + jQuery('#mainwp-first-level-navigation-menu .left-menu-item-level-0, #mainwp-second-level-navigation .left-menu-item-level-2:not(.extension-inactive)').on('click', function () {
2898 + jQuery('#mainwp-nav-dimmer').dimmer({
2899 + duration: 25,
2900 + opacity: 1,
2901 + }).dimmer('show');
2902 + });
2903 + } );
2904 + </script>
2905 + <?php
2906 + }
2907 +
2908 + /**
2909 + * Method render_screen_options()
2910 + *
2911 + * Render modal window for Page Settings.
2912 + *
2913 + * @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Operations page.
2914 + *
2915 + * @return void Render modal window for Page Settings html.
2916 + */
2917 + 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.
2918 +
2919 + $default_widgets = array(
2920 + 'overview' => esc_html__( 'Updates Overview', 'mainwp' ),
2921 + 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
2922 + 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
2923 + 'plugins' => esc_html__( 'Plugins (Individual Site Operations page)', 'mainwp' ),
2924 + 'themes' => esc_html__( 'Themes (Individual Site Operations page)', 'mainwp' ),
2925 + 'connection_status' => esc_html__( 'Connection Status', 'mainwp' ),
2926 + 'security_issues' => esc_html__( 'Site Hardening', 'mainwp' ),
2927 + 'notes' => esc_html__( 'Notes (Individual Site Operations page)', 'mainwp' ),
2928 + 'clients' => esc_html__( 'Clients', 'mainwp' ),
2929 + 'child_site_info' => esc_html__( 'Child site info (Individual Site Operations page)', 'mainwp' ),
2930 + 'client_info' => esc_html__( 'Client info (Individual Site Operations page)', 'mainwp' ),
2931 + 'non_mainwp_changes' => esc_html__( 'Network Activity', 'mainwp' ),
2932 + 'get-started' => esc_html__( 'Get Started with MainWP', 'mainwp' ),
2933 + 'uptime_monitoring_status' => esc_html__( 'Uptime Monitoring', 'mainwp' ),
2934 + 'uptime_monitoring_response_time' => esc_html__( 'Uptime Monitoring (Individual Site Operations page)', 'mainwp' ),
2935 + );
2936 +
2937 + if ( ! MainWP_Uptime_Monitoring_Edit::is_enable_global_monitoring() ) {
2938 + unset( $default_widgets['uptime_monitoring_status'] );
2939 + unset( $default_widgets['uptime_monitoring_response_time'] );
2940 + }
2941 +
2942 + $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.
2943 +
2944 + /**
2945 + * Filter: mainwp_widgets_screen_options
2946 + *
2947 + * Filters available widgets on the Operations page allowing users to unset unwanted widgets.
2948 + *
2949 + * @since 4.0
2950 + */
2951 + $custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts );
2952 +
2953 + if ( is_array( $custom_opts ) && ! empty( $custom_opts ) ) {
2954 + $default_widgets = array_merge( $default_widgets, $custom_opts );
2955 + }
2956 +
2957 + $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
2958 +
2959 + if ( ! is_array( $show_widgets ) ) {
2960 + $show_widgets = array();
2961 + }
2962 +
2963 + $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
2964 + $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
2965 + $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
2966 +
2967 + /**
2968 + * Action: mainwp_screen_options_modal_top
2969 + *
2970 + * Fires at the top of the Page Settings modal element.
2971 + *
2972 + * @since 4.1
2973 + */
2974 + do_action( 'mainwp_screen_options_modal_top' );
2975 + $which_settings = 'overview_settings';
2976 + ?>
2977 + <?php if ( ! $setting_page ) : ?>
2978 + <?php if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2979 + <?php
2980 + $which_settings = 'sidebar_settings';
2981 + $sidebarPosition = (int) get_user_option( 'mainwp_sidebarPosition', 1 );
2982 + $manageGroupsPage = false;
2983 + if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2984 + $manageGroupsPage = true;
2985 + }
2986 + ?>
2987 + <div class="ui grid field">
2988 + <label tabindex="0" class="six wide column middle aligned"><?php echo $manageGroupsPage ? esc_html__( 'Tags menu position', 'mainwp' ) : esc_html__( 'Sidebar position', 'mainwp' ); ?></label>
2989 + <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">
2990 + <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
2991 + <option value="1" <?php echo 1 === $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Right', 'mainwp' ); ?></option>
2992 + <option value="0" <?php echo 0 === $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
2993 + </select>
2994 + </div>
2995 + </div>
2996 + <?php endif; ?>
2997 + <?php endif; ?>
2998 + <?php
2999 + if ( isset( $_GET['page'] ) && ! in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
3000 + $hide_up_everything = (int) get_option( 'mainwp_hide_update_everything' );
3001 + ?>
3002 + <div class="ui grid field settings-field-indicator-wrapper">
3003 + <label class="six wide column middle aligned">
3004 + <?php
3005 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_hide_update_everything', $hide_up_everything );
3006 + esc_html_e( 'Hide the Update Everything button', 'mainwp' );
3007 + ?>
3008 + </label>
3009 + <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">
3010 + <input type="checkbox" class="settings-field-value-change-handler" name="hide_update_everything" <?php echo 1 === $hide_up_everything ? 'checked="true"' : ''; ?> />
3011 + </div>
3012 + </div>
3013 + <?php
3014 + $indi_val = 'all';
3015 + foreach ( $default_widgets as $name => $title ) {
3016 + if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
3017 + continue;
3018 + }
3019 + $indi_val = '';
3020 + }
3021 + ?>
3022 + <div class="ui grid field settings-field-indicator-wrapper" default-indi-value="all">
3023 + <label class="six wide column">
3024 + <?php
3025 + if ( $setting_page ) {
3026 + MainWP_Settings_Indicator::render_not_default_indicator( 'show_default_widgets', $indi_val );
3027 + }
3028 + esc_html_e( 'Show widgets', 'mainwp' );
3029 + ?>
3030 + </label>
3031 + <div class="ten wide column" <?php echo $setting_page ? 'data-tooltip="' . esc_attr__( 'Select widgets that you want to hide in the MainWP Operations page.', 'mainwp' ) . '"' : ''; ?> data-inverted="" data-position="top left">
3032 + <ul class="mainwp_hide_wpmenu_checkboxes">
3033 + <?php
3034 + foreach ( $default_widgets as $name => $title ) {
3035 + $_selected = '';
3036 + if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
3037 + $_selected = 'checked';
3038 + }
3039 + ?>
3040 + <li>
3041 + <div class="ui checkbox">
3042 + <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 ); ?>">
3043 + <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
3044 + </div>
3045 + <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
3046 + </li>
3047 + <?php
3048 + }
3049 + ?>
3050 + </ul>
3051 + </div>
3052 + </div>
3053 + <?php
3054 + endif;
3055 + // phpcs:enable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized.Recommended
3056 + ?>
3057 + <input type="hidden" name="reset_overview_which_settings" value="<?php echo esc_html( $which_settings ); ?>" />
3058 + <?php
3059 + /**
3060 + * Action: mainwp_screen_options_modal_bottom
3061 + *
3062 + * Fires at the bottom of the Page Settings modal element.
3063 + *
3064 + * @since 4.1
3065 + */
3066 + do_action( 'mainwp_screen_options_modal_bottom' );
3067 + }
3068 +
3069 + /**
3070 + * Method render_select_mainwp_themes_modal()
3071 + *
3072 + * Render modal window for mainwp themes selection.
3073 + *
3074 + * @return void Render modal window for themes selection.
3075 + */
3076 + public static function render_select_mainwp_themes_modal() {
3077 + ?>
3078 + <div class="ui modal" id="mainwp-select-mainwp-themes-modal">
3079 + <i class="close icon"></i>
3080 + <div class="header"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></div>
3081 + <div class="content ui form">
3082 + <div class="ui blue message">
3083 + <div class=""><?php /* translators: 1: Opening anchor tag for documentation link, 2: Closing anchor tag. */ printf( esc_html__( 'Did you know you can create your custom theme? %1$sSee here how to do it%2$s!', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/management/mainwp-dashboard-settings#select-mainwp-theme" target="_blank">', '</a>' ); // NOSONAR - noopener - open safe. ?></div>
3084 + </div>
3085 + <form method="POST" action="" name="mainwp_select_mainwp_themes_form" id="mainwp_select_mainwp_themes_form">
3086 + <?php self::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
3087 + <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPSelectThemes' ) ); ?>" />
3088 + <?php
3089 + /**
3090 + * Action: mainwp_select_themes_modal_top
3091 + *
3092 + * Fires at the top of the modal.
3093 + *
3094 + * @since 4.3
3095 + */
3096 + do_action( 'mainwp_select_themes_modal_top' );
3097 +
3098 + MainWP_Settings::get_instance()->render_select_custom_themes();
3099 +
3100 + /**
3101 + * Action: mainwp_select_themes_modal_bottom
3102 + *
3103 + * Fires at the bottom of the modal.
3104 + *
3105 + * @since 4.3
3106 + */
3107 + do_action( 'mainwp_select_themes_modal_bottom' );
3108 + ?>
3109 + </div>
3110 + <div class="actions">
3111 + <div class="ui two columns grid">
3112 + <div class="left aligned column">
3113 +
3114 + </div>
3115 + <div class="ui right aligned column">
3116 + <input type="submit" class="ui green button" id="submit-select-mainwp-themes" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
3117 + </div>
3118 + </div>
3119 + </div>
3120 + </form>
3121 + </div>
3122 + <?php
3123 + }
3124 +
3125 + /**
3126 + * Method render_install_extensions_promo_modal()
3127 + */
3128 + public static function render_install_extensions_promo_modal() {
3129 + $mainwp_api_key = MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key();
3130 + ?>
3131 + <div class="ui small modal" id="mainwp-install-extensions-promo-modal">
3132 + <i class="close icon"></i>
3133 + <?php if ( empty( $mainwp_api_key ) ) : ?>
3134 + <div class="header"><?php esc_html_e( 'Get MainWP Pro', 'mainwp' ); ?></div>
3135 + <div class="content">
3136 + <div class="ui header"><?php esc_html_e( 'With your MainWP Pro subscription, you get access to:', 'mainwp' ); ?></div>
3137 + <div class="ui bulleted list">
3138 + <div class="item"><?php esc_html_e( 'All 30+ Existing Premium Add-ons', 'mainwp' ); ?></div>
3139 + <div class="item"><?php esc_html_e( 'All Future Add-ons', 'mainwp' ); ?></div>
3140 + <div class="item"><?php esc_html_e( 'Critical Security & Performance Updates', 'mainwp' ); ?></div>
3141 + <div class="item"><?php esc_html_e( 'Priority Support with Subscription', 'mainwp' ); ?></div>
3142 + <div class="item"><?php esc_html_e( 'Manage Unlimited Websites', 'mainwp' ); ?></div>
3143 + </div>
3144 + <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. ?>
3145 + </div>
3146 + <?php else : ?>
3147 + <div class="header"><?php esc_html_e( 'Install Add-ons', 'mainwp' ); ?></div>
3148 + <div class="content">
3149 + <div class="ui header"><?php esc_html_e( 'Add-on not activated', 'mainwp' ); ?></div>
3150 + <div><?php esc_html_e( 'Go to the ', 'mainwp' ); ?><a href="admin.php?page=Extensions">MainWP > Add-ons</a><?php esc_html_e( ' page to install and activate add-ons.', 'mainwp' ); ?></div>
3151 + </div>
3152 + <?php endif; ?>
3153 + </div>
3154 + <?php
3155 + }
3156 +
3157 + /**
3158 + * Method render_empty_element_placeholder()
3159 + *
3160 + * Renders the content for empty elements.
3161 + *
3162 + * @param string $title Title text.
3163 + * @param string $message Message text.
3164 + * @param string $icon Icon HTML markup.
3165 + */
3166 + public static function render_empty_element_placeholder( $title = '', $message = '', $icon = '' ) {
3167 + ?>
3168 + <div class="mainwp-empty-widget-placeholder">
3169 + <h3 class="ui big icon header">
3170 + <?php if ( '' !== $icon ) : ?>
3171 + <?php echo $icon; //phpcs:ignore -- requires escaped. ?>
3172 + <?php else : ?>
3173 + <i class="search icon"></i>
3174 + <?php endif; ?>
3175 + <div class="content">
3176 + <?php if ( '' !== $title ) : ?>
3177 + <?php echo $title; //phpcs:ignore -- requires escaped. ?>
3178 + <?php else : ?>
3179 + <?php echo esc_html__( 'Nothing to show right now.', 'mainwp' ); ?>
3180 + <?php endif; ?>
3181 + <?php if ( '' !== $message ) : ?>
3182 + <div class="sub header">
3183 + <?php echo $message; //phpcs:ignore -- requires escaped. ?>
3184 + </div>
3185 + <?php endif; ?>
3186 + </div>
3187 + </h3>
3188 + </div>
3189 + <?php
3190 + }
3191 +
3192 + /**
3193 + * Method render_empty_page_placeholder()
3194 + *
3195 + * Renders the content for empty pages.
3196 + *
3197 + * @param string $title Title text.
3198 + * @param string $message Message text.
3199 + * @param string $icon Icon HTML markup.
3200 + */
3201 + public static function render_empty_page_placeholder( $title = '', $message = '', $icon = '' ) {
3202 + ?>
3203 + <div class="mainwp-empty-page-placeholder ui center aligned middle aligned very padded segment">
3204 + <div class="ui hidden divider"></div>
3205 + <h2 class="ui icon header">
3206 + <?php if ( '' !== $icon ) : ?>
3207 + <?php echo $icon; //phpcs:ignore -- requires escaped. ?>
3208 + <?php else : ?>
3209 + <i class="massive green check tada transition icon"></i>
3210 + <?php endif; ?>
3211 + <div class="content">
3212 + <?php if ( '' !== $title ) : ?>
3213 + <?php echo $title; //phpcs:ignore -- requires escaped. ?>
3214 + <?php else : ?>
3215 + <?php echo esc_html__( 'Nothing to show here!', 'mainwp' ); ?>
3216 + <?php endif; ?>
3217 + <?php if ( '' !== $message ) : ?>
3218 + <div class="sub header"><?php echo $message; //phpcs:ignore -- requires escaped. ?></div>
3219 + <?php else : ?>
3220 + <div class="sub header"><?php echo esc_html__( 'Check back later.', 'mainwp' ); ?></div>
3221 + <?php endif; ?>
3222 + </div>
3223 + </h2>
3224 + </div>
3225 + <?php
3226 + }
3227 +
3228 + /**
3229 + * Method render_modal_save_segment()
3230 + *
3231 + * Render modal window.
3232 + *
3233 + * @param string $name Model segment name.
3234 + *
3235 + * @return void
3236 + */
3237 + public static function render_modal_save_segment( $name = '' ) {
3238 + ?>
3239 + <div id="mainwp-common-filter-segment-modal" class="ui tiny modal">
3240 + <i class="close icon" id="mainwp-common-filter-segment-cancel"></i>
3241 + <div class="header"><?php esc_html_e( 'Save Segment', 'mainwp' ); ?></div>
3242 + <div class="content" id="mainwp-common-filter-segment-content">
3243 + <div id="mainwp-common-filter-edit-segment-status" class="ui message hidden"></div>
3244 + <div id="mainwp-common-filter-segment-edit-fields" class="ui form">
3245 + <div class="field">
3246 + <label><?php esc_html_e( 'Enter the segment name', 'mainwp' ); ?></label>
3247 + </div>
3248 + <div class="field">
3249 + <input type="text" id="mainwp-common-filter-edit-segment-name" value=""/>
3250 + </div>
3251 + </div>
3252 + <div id="mainwp-common-filter-segment-select-fields" style="display:none;">
3253 + <div class="field">
3254 + <label><?php esc_html_e( 'Select a segment', 'mainwp' ); ?></label>
3255 + </div>
3256 + <div class="field">
3257 + <div id="mainwp-common-filter-segments-lists-wrapper"></div>
3258 + </div>
3259 + </div>
3260 + </div>
3261 + <div class="actions">
3262 + <div class="ui grid">
3263 + <div class="eight wide left aligned middle aligned column">
3264 + <input type="button" class="ui green button" id="mainwp-common-filter-edit-segment-save" value="<?php esc_attr_e( 'Save', 'mainwp' ); ?>"/>
3265 + <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;"/>
3266 + <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;"/>
3267 + </div>
3268 + <div class="eight wide column">
3269 +
3270 + </div>
3271 + </div>
3272 + </div>
3273 + <input type="hidden" id="mainwp-common-filter-segments-model-name" value="<?php echo esc_attr( $name ); ?>" />
3274 + </div>
3275 + <?php
3276 + }
3277 +
3278 +
3279 + /**
3280 + * Method generate_wp_nonce()
3281 + *
3282 + * @param mixed $act Action.
3283 + * @param mixed $name Input name.
3284 + * @param mixed $id Input id.
3285 + * @param mixed $echo_out Echo or not.
3286 + * @return mixed Output.
3287 + */
3288 + public static function generate_wp_nonce( $act, $name = '_wpnonce', $id = '__auto__', $echo_out = true ) {
3289 +
3290 + if ( '__auto__' === $id ) {
3291 + $id = wp_generate_password( 12, false );
3292 + }
3293 +
3294 + $nonce = wp_create_nonce( $act );
3295 + $out = '<input type="hidden" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="' . esc_attr( $nonce ) . '" />';
3296 +
3297 + if ( $echo_out ) {
3298 + echo $out; //phpcs:ignore --ok.
3299 + return '';
3300 + }
3301 + return $out;
3302 + }
3303 +
3304 + /**
3305 + * Method render_modal_reconnect()
3306 + *
3307 + * Render modal window.
3308 + *
3309 + * @return void
3310 + */
3311 + public static function render_modal_reconnect() {
3312 + ?>
3313 + <div class="ui modal" id="mainwp-reconnect-site-with-user-passwd-modal">
3314 + <i class="close icon"></i>
3315 + <div class="header"><?php esc_html_e( 'Reconnect Site', 'mainwp' ); ?></div>
3316 + <div class="content">
3317 + <div class="ui message" id="mainwp-message-zone-reconnect" style="display:none;"></div>
3318 + <div class="ui grid field" >
3319 + <label class="six wide column middle aligned"><?php esc_html_e( 'Administrator username', 'mainwp' ); ?></label>
3320 + <div class="ui ten wide fluid column" data-tooltip="<?php esc_attr_e( 'Enter the website Administrator username.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
3321 + <div class="ui left fluid labeled input" tabindex="0">
3322 + <input type="text" id="mainwp_managesites_add_wpadmin" name="mainwp_managesites_add_wpadmin" value="" />
3323 + </div>
3324 + </div>
3325 + </div>
3326 + <div id="mainwp-administrator-password-field">
3327 + <input type="password" id="fake-disable-autofill" style="display:none;" name="fake-disable-autofill" />
3328 + <div class="ui grid field">
3329 + <label class="six wide column top aligned"><?php esc_html_e( 'Administrator password', 'mainwp' ); ?></label>
3330 + <div class="ui ten wide column" data-tooltip="<?php esc_attr_e( 'Enter the website Administrator password.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
3331 + <div class="ui left fluid labeled input">
3332 + <input type="password" id="mainwp_managesites_add_admin_pwd" name="mainwp_managesites_add_admin_pwd" autocomplete="one-time-code" autocorrect="off" autocapitalize="none" spellcheck="false" value="" />
3333 + </div>
3334 + <div class="ui hidden fitted divider"></div>
3335 + <span class="ui small text"><?php esc_html_e( 'Your password is never stored by your Dashboard and never sent to MainWP.com. Once this initial connection is complete, your MainWP Dashboard generates a secure Public and Private key pair (2048 bits) using OpenSSL, allowing future connections without needing your password again. For added security, you can even change this admin password once connected, just be sure not to delete the admin account, as this would disrupt the connection.', 'mainwp' ); ?></span>
3336 + </div>
3337 + </div>
3338 + </div>
3339 + </div>
3340 + <div class="actions">
3341 + <input type="button" autofocus name="mainwp-popup-reconnect-site-btn" id="mainwp-popup-reconnect-site-btn" class="ui button green big focus" value="<?php esc_attr_e( 'Reconnect', 'mainwp' ); ?>" />
3342 + </div>
3343 + </div>
3344 + <?php
3345 + }
3346 +
3347 + /**
3348 + * Method get_default_icons().
3349 + *
3350 + * @return array icons.
3351 + */
3352 + public static function get_default_icons() { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR - compatible phpcs's line breaks.
3353 + return array(
3354 + 'wordpress', //phpcs:ignore -- WP icon.
3355 + 'ambulance',
3356 + 'anchor',
3357 + 'archive',
3358 + 'award',
3359 + 'baby carriage',
3360 + 'balance scale',
3361 + 'balance scale left',
3362 + 'balance scale right',
3363 + 'bath',
3364 + 'bed',
3365 + 'beer',
3366 + 'bell',
3367 + 'bell outline',
3368 + 'bicycle',
3369 + 'binoculars',
3370 + 'birthday cake',
3371 + 'blender',
3372 + 'bomb',
3373 + 'book',
3374 + 'book dead',
3375 + 'bookmark',
3376 + 'bookmark outline',
3377 + 'briefcase',
3378 + 'broadcast tower',
3379 + 'bug',
3380 + 'building',
3381 + 'building outline',
3382 + 'bullhorn',
3383 + 'bullseye',
3384 + 'bus',
3385 + 'calculator',
3386 + 'calendar',
3387 + 'calendar alternate',
3388 + 'calendar alternate outline',
3389 + 'calendar outline',
3390 + 'camera',
3391 + 'camera retro',
3392 + 'candy cane',
3393 + 'car',
3394 + 'carrot',
3395 + 'church',
3396 + 'clipboard',
3397 + 'clipboard outline',
3398 + 'cloud',
3399 + 'coffee',
3400 + 'cog',
3401 + 'cogs',
3402 + 'compass',
3403 + 'compass outline',
3404 + 'cookie',
3405 + 'cookie bite',
3406 + 'copy',
3407 + 'copy outline',
3408 + 'cube',
3409 + 'cubes',
3410 + 'cut',
3411 + 'dice',
3412 + 'dice d20',
3413 + 'dice d6',
3414 + 'dice five',
3415 + 'dice four',
3416 + 'dice one',
3417 + 'dice six',
3418 + 'dice three',
3419 + 'dice two',
3420 + 'digital tachograph',
3421 + 'door closed',
3422 + 'door open',
3423 + 'drum',
3424 + 'drum steelpan',
3425 + 'envelope',
3426 + 'envelope open',
3427 + 'envelope open outline',
3428 + 'envelope outline',
3429 + 'eraser',
3430 + 'eye',
3431 + 'eye dropper',
3432 + 'eye outline',
3433 + 'fax',
3434 + 'feather',
3435 + 'feather alternate',
3436 + 'fighter jet',
3437 + 'file',
3438 + 'file alternate',
3439 + 'file alternate outline',
3440 + 'file outline',
3441 + 'file prescription',
3442 + 'film',
3443 + 'fire',
3444 + 'fire alternate',
3445 + 'fire extinguisher',
3446 + 'flag',
3447 + 'flag checkered',
3448 + 'flag outline',
3449 + 'flask',
3450 + 'futbol',
3451 + 'futbol outline',
3452 + 'gamepad',
3453 + 'gavel',
3454 + 'gem',
3455 + 'gem outline',
3456 + 'gift',
3457 + 'gifts',
3458 + 'glass cheers',
3459 + 'glass martini',
3460 + 'glass whiskey',
3461 + 'glasses',
3462 + 'globe',
3463 + 'graduation cap',
3464 + 'guitar',
3465 + 'hat wizard',
3466 + 'hdd',
3467 + 'hdd outline',
3468 + 'headphones',
3469 + 'headphones alternate',
3470 + 'headset',
3471 + 'heart',
3472 + 'heart broken',
3473 + 'heart outline',
3474 + 'helicopter',
3475 + 'highlighter',
3476 + 'holly berry',
3477 + 'home',
3478 + 'hospital',
3479 + 'hospital outline',
3480 + 'hourglass',
3481 + 'hourglass outline',
3482 + 'igloo',
3483 + 'image',
3484 + 'image outline',
3485 + 'images',
3486 + 'images outline',
3487 + 'industry',
3488 + 'key',
3489 + 'keyboard',
3490 + 'keyboard outline',
3491 + 'laptop',
3492 + 'leaf',
3493 + 'lemon',
3494 + 'lemon outline',
3495 + 'life ring',
3496 + 'life ring outline',
3497 + 'lightbulb',
3498 + 'lightbulb outline',
3499 + 'lock',
3500 + 'lock open',
3501 + 'magic',
3502 + 'magnet',
3503 + 'map',
3504 + 'map marker',
3505 + 'map marker alternate',
3506 + 'map outline',
3507 + 'map pin',
3508 + 'map signs',
3509 + 'marker',
3510 + 'medal',
3511 + 'medkit',
3512 + 'memory',
3513 + 'microchip',
3514 + 'microphone',
3515 + 'microphone alternate',
3516 + 'mitten',
3517 + 'mobile',
3518 + 'mobile alternate',
3519 + 'money bill',
3520 + 'money bill alternate',
3521 + 'money bill alternate outline',
3522 + 'money check',
3523 + 'money check alternate',
3524 + 'moon',
3525 + 'moon outline',
3526 + 'motorcycle',
3527 + 'mug hot',
3528 + 'newspaper',
3529 + 'newspaper outline',
3530 + 'paint brush',
3531 + 'paper plane',
3532 + 'paper plane outline',
3533 + 'paperclip',
3534 + 'paste',
3535 + 'paw',
3536 + 'pen',
3537 + 'pen alternate',
3538 + 'pen fancy',
3539 + 'pen nib',
3540 + 'pencil alternate',
3541 + 'phone',
3542 + 'phone alternate',
3543 + 'plane',
3544 + 'plug',
3545 + 'print',
3546 + 'puzzle piece',
3547 + 'ring',
3548 + 'road',
3549 + 'rocket',
3550 + 'ruler combined',
3551 + 'ruler horizontal',
3552 + 'ruler vertical',
3553 + 'satellite',
3554 + 'satellite dish',
3555 + 'save',
3556 + 'save outline',
3557 + 'school',
3558 + 'screwdriver',
3559 + 'scroll',
3560 + 'sd card',
3561 + 'search',
3562 + 'shield alternate',
3563 + 'shopping bag',
3564 + 'shopping basket',
3565 + 'shopping cart',
3566 + 'shower',
3567 + 'sim card',
3568 + 'skull crossbones',
3569 + 'sleigh',
3570 + 'snowflake',
3571 + 'snowflake outline',
3572 + 'snowplow',
3573 + 'space shuttle',
3574 + 'star',
3575 + 'star outline',
3576 + 'sticky note',
3577 + 'sticky note outline',
3578 + 'stopwatch',
3579 + 'stroopwafel',
3580 + 'subway',
3581 + 'suitcase',
3582 + 'sun',
3583 + 'sun outline',
3584 + 'tablet',
3585 + 'tablet alternate',
3586 + 'tachometer alternate',
3587 + 'tag',
3588 + 'tags',
3589 + 'taxi',
3590 + 'thumbtack',
3591 + 'ticket alternate',
3592 + 'toilet',
3593 + 'toolbox',
3594 + 'tools',
3595 + 'train',
3596 + 'tram',
3597 + 'trash',
3598 + 'trash alternate',
3599 + 'trash alternate outline',
3600 + 'tree',
3601 + 'trophy',
3602 + 'truck',
3603 + 'tv',
3604 + 'umbrella',
3605 + 'university',
3606 + 'unlock',
3607 + 'unlock alternate',
3608 + 'utensil spoon',
3609 + 'utensils',
3610 + 'wallet',
3611 + 'weight',
3612 + 'wheelchair',
3613 + 'wine glass',
3614 + 'wrench',
3615 + 'folder',
3616 + 'folder open',
3617 + 'palette',
3618 + 'server',
3619 + 'tint',
3620 + );
3621 + }
2239 3622 }