PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
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 +3488 -2025 4.6.0.1 → 6.2.1 View file →
@@ -6,2154 +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 - ),
518 - );
519 - $title = MainWP_Utility::esc_content( $title, 'note', $more_tags );
268 + ++$rendered_count;
520 269
521 - /**
522 - * Filter: mainwp_header_left
523 - *
524 - * Filter the MainWP header element left side content.
525 - *
526 - * @since 4.0
527 - */
528 - $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 ); ?>"/>
529 273
530 - $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>
531 288
532 - /**
533 - * Filter: mainwp_header_right
534 - *
535 - * Filter the MainWP header element right side content.
536 - *
537 - * @since 4.0
538 - */
539 - $right = apply_filters( 'mainwp_header_right', $right );
540 289
541 - if ( $show_menu ) {
542 - MainWP_Menu::render_left_menu();
543 - MainWP_Menu::render_mobile_menu();
544 - }
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 + }
545 316
546 - $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
547 - if ( false === $sidebarPosition ) {
548 - $sidebarPosition = 1;
549 - }
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;
550 346
551 - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
347 + static $rendered_count = 0;
552 348
553 - $count_sites = MainWP_DB::instance()->get_websites_count();
349 + $rand_id_prefix = '';
554 350
555 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
556 - if ( empty( $count_sites ) ) {
557 - if ( ! isset( $_GET['do'] ) ) {
558 - self::render_modal_no_sites_note();
559 - }
560 - }
351 + if ( ! empty( $rendered_count ) ) {
352 + $rand_id_prefix = '-' . MainWP_Utility::gen_rand_id();
353 + }
561 354
562 - $siteViewMode = MainWP_Utility::get_siteview_mode();
355 + ++$rendered_count;
563 356
564 - $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 + }
565 382
566 - $tour_id = '';
567 - if ( 'mainwp_tab' === $page ) {
568 - $tour_id = '13112';
569 - } elseif ( 'managesites' === $page ) {
570 - if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) {
571 - $tour_id = '13210';
572 - } elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) {
573 - $tour_id = '27274';
574 - } elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
575 - if ( 'grid' === $siteViewMode ) {
576 - $tour_id = '27217';
577 - } else {
578 - $tour_id = '29331';
579 - }
580 - }
581 - } elseif ( 'MonitoringSites' === $page ) {
582 - $tour_id = '29003';
583 - } elseif ( 'ManageClients' === $page ) {
584 - if ( isset( $_GET['client_id'] ) ) {
585 - $tour_id = '28258';
586 - } else {
587 - $tour_id = '28240';
588 - }
589 - } elseif ( 'ClientAddNew' === $page ) {
590 - if ( isset( $_GET['client_id'] ) ) {
591 - $tour_id = '28962';
592 - } else {
593 - $tour_id = '28256';
594 - }
595 - } elseif ( 'ClientAddField' === $page ) {
596 - $tour_id = '28257';
597 - } elseif ( 'PluginsManage' === $page ) {
598 - $tour_id = '28510';
599 - } elseif ( 'ManageGroups' === $page ) {
600 - $tour_id = '27275';
601 - } elseif ( 'UpdatesManage' === $page ) {
602 - $tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
603 - if ( 'plugins-updates' === $tab ) {
604 - $tour_id = '28259';
605 - } elseif ( 'themes-updates' === $tab ) {
606 - $tour_id = '28447';
607 - } elseif ( 'wordpress-updates' === $tab ) {
608 - $tour_id = '29005';
609 - } elseif ( 'translations-updates' === $tab ) {
610 - $tour_id = '29007';
611 - } elseif ( 'abandoned-plugins' === $tab ) {
612 - $tour_id = '29008';
613 - } elseif ( 'abandoned-themes' === $tab ) {
614 - $tour_id = '29009';
615 - } elseif ( 'plugin-db-updates' === $tab ) {
616 - $tour_id = '33161';
617 - } else {
618 - $tour_id = '28259';
619 - }
620 - } elseif ( 'PluginsInstall' === $page ) {
621 - $tour_id = '29011';
622 - } elseif ( 'PluginsAutoUpdate' === $page ) {
623 - $tour_id = '29015';
624 - } elseif ( 'PluginsIgnore' === $page ) {
625 - $tour_id = '29018';
626 - } elseif ( 'PluginsIgnoredAbandoned' === $page ) {
627 - $tour_id = '29329';
628 - } elseif ( 'ThemesManage' === $page ) {
629 - $tour_id = '28511';
630 - } elseif ( 'ThemesInstall' === $page ) {
631 - $tour_id = '29010';
632 - } elseif ( 'ThemesAutoUpdate' === $page ) {
633 - $tour_id = '29016';
634 - } elseif ( 'ThemesIgnore' === $page ) {
635 - $tour_id = '29019';
636 - } elseif ( 'ThemesIgnoredAbandoned' === $page ) {
637 - $tour_id = '29330';
638 - } elseif ( 'UserBulkManage' === $page ) {
639 - $tour_id = '28574';
640 - } elseif ( 'UserBulkAdd' === $page ) {
641 - $tour_id = '28575';
642 - } elseif ( 'BulkImportUsers' === $page ) {
643 - $tour_id = '28736';
644 - } elseif ( 'UpdateAdminPasswords' === $page ) {
645 - $tour_id = '28737';
646 - } elseif ( 'PostBulkManage' === $page ) {
647 - $tour_id = '28796';
648 - } elseif ( 'PostBulkAdd' === $page ) {
649 - $tour_id = '28799';
650 - } elseif ( 'PageBulkManage' === $page ) {
651 - $tour_id = '29045';
652 - } elseif ( 'PageBulkAdd' === $page ) {
653 - $tour_id = '29048';
654 - } elseif ( 'Extensions' === $page ) {
655 - $tour_id = '28800';
656 - } elseif ( 'Settings' === $page ) {
657 - $tour_id = '28883';
658 - } elseif ( 'SettingsAdvanced' === $page ) {
659 - $tour_id = '28886';
660 - } elseif ( 'SettingsEmail' === $page ) {
661 - $tour_id = '29054';
662 - } elseif ( 'MainWPTools' === $page ) {
663 - $tour_id = '29272';
664 - } elseif ( 'RESTAPI' === $page ) {
665 - $tour_id = '29273';
666 - } elseif ( 'ServerInformation' === $page ) {
667 - $tour_id = '28873';
668 - } elseif ( 'ServerInformationCron' === $page ) {
669 - $tour_id = '28874';
670 - } elseif ( 'ErrorLog' === $page ) {
671 - $tour_id = '28876';
672 - } elseif ( 'ActionLogs' === $page ) {
673 - $tour_id = '28877';
674 - } elseif ( 'Extensions-Mainwp-Jetpack-Protect-Extension' === $page ) {
675 - $tour_id = '31700';
676 - } elseif ( 'Extensions-Mainwp-Jetpack-Scan-Extension' === $page ) {
677 - $tour_id = '31694';
678 - } elseif ( 'Extensions-Termageddon-For-Mainwp' === $page ) {
679 - $tour_id = '32104';
680 - } elseif ( 'Extensions-Advanced-Uptime-Monitor-Extension' === $page ) {
681 - $tour_id = '32149';
682 - } elseif ( 'Extensions-Mainwp-Custom-Dashboard-Extension' === $page ) {
683 - $tour_id = '32150';
684 - } elseif ( 'Extensions-Mainwp-Updraftplus-Extension' === $page ) {
685 - $tour_id = '32151';
686 - } elseif ( 'Extensions-Mainwp-Sucuri-Extension' === $page ) {
687 - $tour_id = '32152';
688 - } elseif ( 'Extensions-Mainwp-Clean-And-Lock-Extension' === $page ) {
689 - $tour_id = '32153';
690 - } elseif ( 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' === $page ) {
691 - $tour_id = '32851';
692 - } elseif ( 'Extensions-Mainwp-Buddy-Extension' === $page ) {
693 - $tour_id = '33064';
694 - } elseif ( 'Extensions-Mainwp-Backwpup-Extension' === $page ) {
695 - $tour_id = '32923';
696 - } elseif ( 'Extensions-Mainwp-Ssl-Monitor-Extension' === $page ) {
697 - $tour_id = '33164';
698 - } elseif ( 'Extensions-Mainwp-Cache-Control-Extension' === $page ) {
699 - $tour_id = '33167';
700 - } elseif ( 'Extensions-Mainwp-Maintenance-Extension' === $page ) {
701 - $tour_id = '33301';
702 - } elseif ( 'Extensions-Mainwp-Domain-Monitor-Extension' === $page ) {
703 - $tour_id = '33300';
704 - }
705 - // phpcs:enable
706 - ?>
707 - <div class="ui segment right sites sidebar" style="padding:0px" id="mainwp-sites-menu-sidebar">
708 - <div class="ui segment" style="margin-bottom:0px">
709 - <div class="ui header"><?php esc_html_e( 'Quick Site Shortcuts', 'mainwp' ); ?></div>
710 - </div>
711 - <div class="ui fitted divider"></div>
712 - <div class="ui segment" style="margin-bottom:0px">
713 - <div class="ui mini fluid icon input" <?php echo $websites ? '' : 'style="display: none;"'; ?> >
714 - <input type="text" id="mainwp-sites-menu-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" />
715 - <i class="filter icon"></i>
716 - </div>
717 - </div>
718 - <div class="ui fluid vertical accordion menu" id="mainwp-sites-sidebar-menu" style="margin-top:0px;border-radius:0px;box-shadow:none;">
719 - <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
720 - <div class="item mainwp-site-menu-item">
721 - <a class="title">
722 - <i class="dropdown icon"></i>
723 - <label><?php echo esc_html( $website->name ); ?></label>
724 - </a>
725 - <div class="content">
726 - <div class="ui link tiny list">
727 - <a class="item" href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website->id ); ?>">
728 - <i class="grid layout icon"></i>
729 - <?php esc_html_e( 'Overview', 'mainwp' ); ?>
730 - </a>
731 - <a class="item" href="<?php echo 'admin.php?page=managesites&updateid=' . intval( $website->id ); ?>">
732 - <i class="redo icon"></i>
733 - <?php esc_html_e( 'Updates', 'mainwp' ); ?>
734 - </a>
735 - <a class="item" href="<?php echo 'admin.php?page=managesites&id=' . intval( $website->id ); ?>">
736 - <i class="edit icon"></i>
737 - <?php esc_html_e( 'Edit Site', 'mainwp' ); ?>
738 - </a>
739 - <a class="item" href="<?php echo 'admin.php?page=managesites&scanid=' . intval( $website->id ); ?>">
740 - <i class="shield icon"></i>
741 - <?php esc_html_e( 'Security Scan', 'mainwp' ); ?>
742 - </a>
743 - <a class="item" 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' ) ); ?>">
744 - <i class="sign in icon"></i>
745 - <?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?>
746 - </a>
747 - <a class="item" target="_blank" href="<?php echo esc_url( $website->url ); ?>">
748 - <i class="globe icon"></i>
749 - <?php esc_html_e( 'Visit Site', 'mainwp' ); ?>
750 - </a>
751 - <?php
752 - /**
753 - * Action: mainwp_quick_sites_shortcut
754 - *
755 - * Adds a new shortcut item in the Quick Sites Shortcuts sidebar menu.
756 - *
757 - * @param array $website Array containing the child site data.
758 - *
759 - * Suggested HTML markup:
760 - *
761 - * <a class="item" href="your custom URL">
762 - * <i class="your custom icon"></i>
763 - * Your custom label text
764 - * </a>
765 - *
766 - * @since 4.1
767 - */
768 - do_action( 'mainwp_quick_sites_shortcut', $website );
769 - ?>
770 - </div>
771 - </div>
772 - </div>
773 - <?php } ?>
774 - </div>
775 - </div>
776 - <div class="ui segment right wide help sidebar" id="mainwp-documentation-sidebar">
777 - <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>
778 - <div class="ui hidden divider"></div>
779 - <div class="ui info message" style="display:block!important;">
780 - <?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>' ); ?>
781 - </div>
782 - <div class="ui hidden divider"></div>
783 - <div class="ui toggle checkbox">
784 - <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>
785 - </div>
786 - <div class="ui hidden divider"></div>
787 - <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
788 - <p><?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?></p>
789 - <p><?php esc_html_e( 'Click the Start Page Tour button to start the guided tour for the current page.', 'mainwp' ); ?></p>
790 - <div class="ui hidden divider"></div>
791 - <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>
792 - <?php if ( 'mainwp_tab' === $page ) : ?>
793 - <div class="ui hidden divider"></div>
794 - <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>
795 - <?php endif; ?>
796 - <?php endif; ?>
797 - <div class="ui header"><?php esc_html_e( 'MainWP Documenation', 'mainwp' ); ?></div>
798 - <div class="ui hidden divider"></div>
799 - <?php
800 - /**
801 - * Action: mainwp_help_sidebar_content
802 - *
803 - * Fires Help sidebar content
804 - *
805 - * @since 4.0
806 - */
807 - do_action( 'mainwp_help_sidebar_content' );
808 - ?>
809 - <div class="ui hidden divider"></div>
810 - <a href="https://kb.mainwp.com/" class="ui big green fluid button"><?php esc_html_e( 'Help Documentation', 'mainwp' ); ?></a>
811 - <div class="ui hidden divider"></div>
812 - <div id="mainwp-sticky-help-button" class="" style="position: absolute; bottom: 1em; left: 1em; right: 1em;">
813 - <a href="https://managers.mainwp.com/" target="_blank" class="ui fluid button"><?php esc_html_e( 'Still Need Help?', 'mainwp' ); ?></a>
814 - </div>
815 - </div>
816 - <?php
817 - /**
818 - * Action: mainwp_before_mainwp_content_wrap
819 - *
820 - * Fires before the #mainwp-content-wrap element.
821 - *
822 - * @param array $websites Array containing the child site data.
823 - *
824 - * @since 4.1
825 - */
826 - do_action( 'mainwp_before_mainwp_content_wrap', $websites );
827 - global $wp_version;
828 - $fix_menu_overflow = 1;
829 - if ( version_compare( $wp_version, '5.5.3', '>' ) ) {
830 - $fix_menu_overflow = 2;
831 - }
383 + $site_client_editing = ( $add_edit_client_id && $website->client_id && $add_edit_client_id === $website->client_id ) ? true : false;
832 384
833 - if ( 'page_clients_overview' !== $which ) {
834 - ?>
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 + }
835 397
836 - <div class="ui modal" id="mainwp-overview-screen-options-modal">
837 - <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
838 - <div class="content ui form">
839 - <?php
840 - /**
841 - * Action: mainwp_overview_screen_options_top
842 - *
843 - * Fires at the top of the Sceen Options modal on the Overview page.
844 - *
845 - * @since 4.1
846 - */
847 - do_action( 'mainwp_overview_screen_options_top' );
848 - ?>
849 - <form method="POST" action="" name="mainwp_overview_screen_options_form" id="mainwp-overview-screen-options-form">
850 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
851 - <input type="hidden" name="wp_nonce" value="<?php echo esc_html( wp_create_nonce( 'MainWPScrOptions' ) ); ?>" />
852 - <?php self::render_screen_options( false ); ?>
853 - <?php
854 - /**
855 - * Action: mainwp_overview_screen_options_bottom
856 - *
857 - * Fires at the bottom of the Sceen Options modal on the Overview page.
858 - *
859 - * @since 4.1
860 - */
861 - do_action( 'mainwp_overview_screen_options_bottom' );
862 - ?>
863 - </div>
864 - <div class="actions">
865 - <div class="ui two columns grid">
866 - <div class="left aligned column">
867 - <span data-tooltip="<?php esc_attr_e( 'Returns this page to the state it was in when installed. The feature also restores any widgets you have moved through the drag and drop feature on the page.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><input type="button" class="ui button" name="reset" id="reset-overview-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span>
868 - </div>
869 - <div class="ui right aligned column">
870 - <input type="submit" class="ui green button" id="submit-overview-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
871 - <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
872 - </div>
873 - </div>
874 - </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 + }
875 442
876 - <input type="hidden" name="reset_overview_settings" value="" />
877 - </form>
878 - </div>
879 - <?php } ?>
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' ) );
880 461
881 - <div class="mainwp-content-wrap <?php echo empty( $sidebarPosition ) ? 'mainwp-sidebar-left' : ''; ?>" menu-overflow="<?php echo intval( $fix_menu_overflow ); ?>">
882 - <?php if ( MainWP_Demo_Handle::is_demo_mode() ) : ?>
883 - <div class="ui segment" style="background-color:#1c1d1b!important;margin-bottom:0px;">
884 - <div class="ui inverted accordion" id="mainwp_demo_mode_accordion" style="background-color:#1c1d1b;">
885 - <div class="title">
886 - <i class="dropdown icon"></i>
887 - <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
888 - <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>
889 - <?php } else { ?>
890 - <strong style="color:#fff;font-size:16px;"><?php esc_html_e( 'You are in Demo Mode. Click here for more info', 'mainwp' ); ?></strong>
891 - <?php } ?>
892 - </div>
893 - <div class="content">
894 - <br/>
895 - <div class="ui stackable grid">
896 - <div class="eleven wide middle aligned column">
897 - <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
898 - <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>
899 - <?php } ?>
900 - <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>
901 - </div>
902 - <div class="five wide middle aligned column">
903 - <?php if ( ! MainWP_Demo_Handle::is_instawp_site() ) { ?>
904 - <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>
905 - <?php } else { ?>
906 - <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>
907 - <?php } ?>
908 - </div>
909 - </div>
910 - <br/>
911 - </div>
912 - </div>
913 - </div>
914 - <script type="text/javascript">
915 - jQuery( '#mainwp_demo_mode_accordion' ).accordion();
916 - </script>
917 - <?php endif; ?>
918 - <?php
919 - /**
920 - * Action: mainwp_before_header
921 - *
922 - * Fires before the MainWP header element.
923 - *
924 - * @param array $websites Array containing the child site data.
925 - *
926 - * @since 4.0
927 - */
928 - do_action( 'mainwp_before_header', $websites );
929 - ?>
930 - <div id="mainwp-top-header" class="">
931 - <div class="ui middle aligned grid">
932 - <div class="five wide column">
933 - <h4 class="mainwp-page-title">
934 - <?php echo $left; // phpcs:ignore WordPress.Security.EscapeOutput ?>
935 - </h4>
936 - </div>
937 - <div class="two wide right aligned column">
938 - <?php if ( isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
939 - <select class="ui mini selection fluid dropdown" id="mainwp-jump-to-site-overview-dropdown">
940 - <?php $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); ?>
941 - <option class="item"><?php esc_html_e( 'Jump to site overview...', 'mainwp' ); ?></option>
942 - <?php while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { ?>
943 - <option class="item" value="<?php echo esc_attr( $website->id ); ?>"><?php echo esc_html( $website->name ); ?></option>
944 - <?php } ?>
945 - <?php MainWP_DB::free_result( $websites ); ?>
946 - </select>
947 - <?php endif; ?>
948 - </div>
949 - <div class="nine wide right aligned column"><?php echo $right; ?></div> <?php // phpcs:ignore WordPress.Security.EscapeOutput ?>
462 + static $rendered_count = 0;
950 463
951 - </div>
952 - </div>
464 + $rand_id_prefix2 = '';
953 465
954 - <?php if ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) : ?>
955 - <script type="text/javascript">
956 - jQuery( document ).ready( function() {
957 - jQuery( '#mainwp-start-page-tour-button' ).on( 'click', function() {
958 - var tourId = jQuery( this ).attr( 'tour-id' );
959 - jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
960 - window.USETIFUL.tour.start( parseInt( tourId ) );
961 - } );
962 - jQuery( '#mainwp-interface-tour-button' ).on( 'click', function() {
963 - jQuery( '#mainwp-documentation-sidebar' ).sidebar( 'toggle' );
964 - window.USETIFUL.tour.start( 13282 );
965 - } );
966 - } );
967 - </script>
968 - <?php endif; ?>
466 + if ( ! empty( $rendered_count ) ) {
467 + $rand_id_prefix2 = '-' . MainWP_Utility::gen_rand_id();
468 + }
969 469
970 - <?php
971 - if ( isset( $_GET['message'] ) && ( 'qsw-import' === $_GET['message'] || 'enable-demo-mode' === $_GET['message'] ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
972 - ?>
973 - <script type= 'text/javascript'>
974 - var _count_retry = 0;
975 - _try_start_usetiful_tour = function () {
976 - setTimeout(
977 - function () {
978 - try {
979 - window.USETIFUL.tour.start( parseInt( 40279 ) );
980 - } catch ( e ) {
981 - if ( _count_retry < 10 ) {
982 - _count_retry++;
983 - console.log('retry:' + _count_retry);
984 - _try_start_usetiful_tour();
985 - }
986 - }
987 - },
988 - 1000
989 - );
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' );
990 1268 }
991 - jQuery(document).ready(
992 - function () {
993 - _try_start_usetiful_tour();
994 - }
995 - );
996 - </script>
997 - <?php
998 - endif;
999 - ?>
1269 + } );
1000 1270
1001 - <script type="text/javascript">
1002 - jQuery( document ).ready( function () {
1271 + <?php if ( ! $fix_dom_issue_for_wp_editor ) { ?>
1003 1272
1004 - jQuery( '#mainwp-jump-to-site-overview-dropdown' ).on( 'change', function() {
1005 - var site_id = jQuery( this ).val();
1006 - window.location.href = 'admin.php?page=managesites&dashboard=' + site_id;
1007 - } );
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);
1008 1294
1009 - jQuery( '#mainwp-sites-menu-sidebar' ).prependTo( 'body' );
1010 - jQuery( '#mainwp-documentation-sidebar' ).prependTo( 'body' );
1011 - 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>
1012 1303
1013 - jQuery( '.ui.sticky' ).sticky( { pushing: false } ).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 + }
1014 1332
1015 - jQuery( '#mainwp-help-sidebar' ).on( 'click', function() {
1016 - jQuery( '.ui.help.sidebar' ).sidebar( {
1017 - transition: 'overlay'
1018 - } );
1019 - jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' );
1020 - return false;
1021 - } );
1022 - jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() {
1023 - jQuery( '.ui.sites.sidebar' ).sidebar( {
1024 - transition: 'overlay',
1025 - 'onVisible': function() {
1026 - jQuery( '#mainwp-sites-menu-filter' ).focus();
1027 - }
1028 - } );
1029 - jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' );
1030 - return false;
1031 - } );
1032 - jQuery( '#mainwp-sites-sidebar-menu' ).accordion();
1033 - } );
1034 - </script>
1035 - <?php
1036 - /**
1037 - * Action: mainwp_after_header
1038 - *
1039 - * Fires after the MainWP header element.
1040 - *
1041 - * @param array $websites Array containing the child site data.
1042 - *
1043 - * @since 4.0
1044 - */
1045 - do_action( 'mainwp_after_header', $websites );
1046 - ?>
1047 - <?php
1048 - }
1049 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>
1050 1368
1051 - /**
1052 - * Method render_showhide_columns_settings()
1053 - *
1054 - * Render show/hide columns settings.
1055 - *
1056 - * @param array $cols Columns.
1057 - * @param array $show_columns Show Columns.
1058 - * @param string $what what.
1059 - */
1060 - public static function render_showhide_columns_settings( $cols, $show_columns, $what ) {
1061 - ?>
1062 - <div class="ui grid field">
1063 - <label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label>
1064 - <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">
1065 - <ul>
1066 - <?php
1067 - foreach ( $cols as $name => $title ) {
1068 - $_selected = '';
1069 - if ( ! isset( $show_columns[ $name ] ) || 1 === (int) $show_columns[ $name ] ) {
1070 - $_selected = 'checked';
1071 - }
1072 - ?>
1073 - <li>
1074 - <div class="ui checkbox">
1075 - <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 ); ?>">
1076 - <label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
1077 - </div>
1078 - <input type="hidden" name="mainwp_columns_name[]" value="<?php echo esc_attr( $name ); ?>">
1079 - </li>
1080 - <?php
1081 - }
1082 - ?>
1083 - </ul>
1084 - </div>
1369 + </div>
1370 + <?php
1085 1371
1086 - </div>
1087 - <?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 + }
1088 1380
1089 - $input_name = '';
1090 - if ( 'post' === $what ) {
1091 - $input_name = 'mainwp_manageposts_show_columns_settings';
1092 - } elseif ( 'page' === $what ) {
1093 - $input_name = 'mainwp_managepages_show_columns_settings';
1094 - } elseif ( 'user' === $what ) {
1095 - $input_name = 'mainwp_manageusers_show_columns_settings';
1096 - }
1381 + if ( ! empty( $input_name ) ) {
1382 + ?>
1383 + <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1384 + <?php
1385 + }
1386 + }
1097 1387
1098 - if ( ! empty( $input_name ) ) {
1099 - ?>
1100 - <input type="hidden" name="<?php echo esc_attr( $input_name ); ?>" value="1">
1101 - <?php
1102 - }
1103 - }
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 = '' ) {
1104 1398
1105 - /**
1106 - * Method render_second_top_header()
1107 - *
1108 - * Render second top header.
1109 - *
1110 - * @param string $which Current page.
1111 - *
1112 - * @return void Render second top header html.
1113 - */
1114 - 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 + ?>
1115 1432
1116 - /**
1117 - * Action: mainwp_before_subheader
1118 - *
1119 - * Fires before the MainWP sub-header element.
1120 - *
1121 - * @since 4.0
1122 - */
1123 - do_action( 'mainwp_before_subheader' );
1124 - if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) {
1125 - ?>
1126 - <div class="mainwp-sub-header">
1127 - <?php
1128 - if ( 'overview' === $which ) {
1129 - ?>
1130 - <div class="ui stackable grid">
1131 - <div class="column full">
1132 - <?php self::gen_groups_sites_selection(); ?>
1133 - </div>
1134 - </div>
1135 - <?php
1136 - }
1137 - ?>
1138 - <?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?>
1139 - <?php
1140 - /**
1141 - * Action: mainwp_managesites_tabletop
1142 - *
1143 - * Fires at the table top on the Manage Sites and Monitoring page.
1144 - *
1145 - * @since 4.0
1146 - */
1147 - do_action( 'mainwp_managesites_tabletop' );
1148 - ?>
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 + }
1149 1457
1150 - <?php else : ?>
1151 - <?php
1152 - /**
1153 - * Action: mainwp_subheader_actions
1154 - *
1155 - * Fires at the subheader element to hook available actions.
1156 - *
1157 - * @since 4.0
1158 - */
1159 - do_action( 'mainwp_subheader_actions' );
1160 - ?>
1161 - <?php endif; ?>
1162 - </div>
1163 - <?php
1164 - }
1165 - /**
1166 - * Action: mainwp_after_subheader
1167 - *
1168 - * Fires after the MainWP sub-header element.
1169 - *
1170 - * @since 4.0
1171 - */
1172 - do_action( 'mainwp_after_subheader' );
1173 - }
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 + }
1174 1519
1175 - /**
1176 - * Method gen_groups_sites_selection()
1177 - *
1178 - * Generate group sites selection box.
1179 - *
1180 - * @return void Render group sites selection box.
1181 - *
1182 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_manage_sites()
1183 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_not_empty_groups()
1184 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1185 - * @uses \MainWP\Dashboard\MainWP_DB::query()
1186 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1187 - * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1188 - */
1189 - public static function gen_groups_sites_selection() {
1190 - $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' ) );
1191 - $websites = MainWP_DB::instance()->query( $sql );
1192 - $g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1193 - $s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1194 - ?>
1195 - <div class="column full wide">
1196 - <select id="mainwp_top_quick_jump_group" class="ui dropdown">
1197 - <option value="" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1198 - <option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Tags', 'mainwp' ); ?></option>
1199 - <?php
1200 - $groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites();
1201 - foreach ( $groups as $group ) {
1202 - ?>
1203 - <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>
1204 - <?php
1205 - }
1206 - ?>
1207 - </select>
1208 - <select class="ui dropdown" id="mainwp_top_quick_jump_page">
1209 - <option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1210 - <option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option>
1211 - <?php
1212 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1213 - ?>
1214 - <option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s === (int) $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo esc_html( stripslashes( $website->name ) ); ?></option>
1215 - <?php
1216 - }
1217 - ?>
1218 - </select>
1219 - </div>
1220 - <script type="text/javascript">
1221 - jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () {
1222 - var jumpid = jQuery( this ).val();
1223 - window.location = 'admin.php?page=managesites&g=' + jumpid;
1224 - } );
1225 - jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () {
1226 - var jumpid = jQuery( this ).val();
1227 - if ( jumpid == -1 )
1228 - window.location = 'admin.php?page=managesites&s=' + jumpid;
1229 - else
1230 - window.location = 'admin.php?page=managesites&dashboard=' + jumpid;
1231 - } );
1232 - </script>
1233 - <?php
1234 - MainWP_DB::free_result( $websites );
1235 - }
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 = '';
1236 1541
1237 - /**
1238 - * Method render_header_actions()
1239 - *
1240 - * Render header action buttons,
1241 - * (Sync|Add|Options|Community|User|Updates).
1242 - *
1243 - * @return mixed $output Render header action buttons html.
1244 - *
1245 - * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1246 - */
1247 - public static function render_header_actions() { //phpcs:ignore -- complex method.
1248 - $sites_count = MainWP_DB::instance()->get_websites_count();
1249 - $website_id = '';
1250 - $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
1251 - $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
1252 - $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'] ?? '' );
1253 1545
1254 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1255 - $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
1256 - ob_start();
1257 - if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) :
1258 - $id = 0;
1259 - if ( isset( $_GET['dashboard'] ) ) {
1260 - $id = intval( $_GET['dashboard'] );
1261 - } elseif ( isset( $_GET['id'] ) ) {
1262 - $id = intval( $_GET['id'] );
1263 - } elseif ( isset( $_GET['updateid'] ) ) {
1264 - $id = intval( $_GET['updateid'] );
1265 - } elseif ( isset( $_GET['emailsettingsid'] ) ) {
1266 - $id = intval( $_GET['emailsettingsid'] );
1267 - } elseif ( isset( $_GET['scanid'] ) ) {
1268 - $id = intval( $_GET['scanid'] );
1269 - }
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' );
1270 1549
1271 - $website = MainWP_DB::instance()->get_website_by_id( $id );
1272 - if ( $id && $website && '' !== $website->sync_errors ) :
1273 - ?>
1274 - <a href="#" class="mainwp-updates-overview-reconnect-site ui green button" siteid="<?php echo intval( $website->id ); ?>" data-position="bottom right" data-tooltip="Reconnect <?php echo esc_html( stripslashes( $website->name ) ); ?>" data-inverted=""><?php esc_html_e( 'Reconnect Site', 'mainwp' ); ?></a>
1275 - <?php else : ?>
1276 - <a class="ui 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">
1277 - <i class="sync icon mainwp-sync-button-icon"></i>
1278 - <span class="mainwp-sync-button-text">
1279 - <?php
1280 - /**
1281 - * Filter: mainwp_main_sync_button_text
1282 - *
1283 - * Filters the Sync Dashboard with Child Sites button text.
1284 - *
1285 - * @since 4.1
1286 - */
1287 - echo esc_html( apply_filters( 'mainwp_site_sync_button_text', esc_html__( 'Sync Site', 'mainwp' ) ) );
1288 - ?>
1289 - </span>
1290 - </a>
1291 - <?php
1292 - endif;
1293 - ?>
1294 - <?php
1295 - else :
1296 - ?>
1297 - <a class="ui button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?> " id="mainwp-sync-sites" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Get fresh data from your child sites.', 'mainwp' ); ?>">
1298 - <i class="sync icon mainwp-sync-button-icon"></i>
1299 - <span class="mainwp-sync-button-text">
1300 - <?php
1301 - /**
1302 - * Filter: mainwp_main_sync_button_text
1303 - *
1304 - * Filters the Sync Dashboard with Child Sites button text.
1305 - *
1306 - * @since 4.1
1307 - */
1308 - echo esc_html( apply_filters( 'mainwp_main_sync_button_text', esc_html__( 'Sync Dashboard with Sites', 'mainwp' ) ) );
1309 - ?>
1310 - </span>
1311 - </a>
1312 - <?php
1313 - endif;
1314 - ?>
1550 + /* translators: %s: Keyboard shortcut label. */
1551 + $command_palette_label = sprintf( esc_attr__( 'Open command palette (%s)', 'mainwp' ), $command_palette_shortcut );
1552 + }
1315 1553
1316 - <div class="ui <?php echo ( empty( $sites_count ) ? 'green' : '' ); ?> buttons" id="mainwp-add-new-buttons">
1317 - <a class="ui icon button" data-inverted="" data-position="right 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' ) ); ?>"><i class="plus icon"></i></a>
1318 - <a class="ui button" data-inverted="" data-position="right 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 New', 'mainwp' ); ?></a>
1319 - <div class="ui floating dropdown icon button" style="z-index: 999;" data-inverted="" data-position="right center" data-tooltip="<?php esc_attr_e( 'More options', 'mainwp' ); ?>">
1320 - <i class="dropdown icon"></i>
1321 - <div class="ui popup bottom right menu">
1322 - <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( 'Website', 'mainwp' ); ?></a>
1323 - <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( 'Client', 'mainwp' ); ?></a>
1324 - <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( 'Post', 'mainwp' ); ?></a>
1325 - <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( 'Page', 'mainwp' ); ?></a>
1326 - <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( 'Plugin', 'mainwp' ); ?></a>
1327 - <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( 'Theme', 'mainwp' ); ?></a>
1328 - <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( 'User', 'mainwp' ); ?></a>
1329 - <?php
1330 - /**
1331 - * Action: mainwp_add_new_menu_option
1332 - *
1333 - * Fires at bottom of the Add New menu options list.
1334 - *
1335 - * Suggested HTML markup:
1336 - * <a class="item" href="your custom URL">Your custom label</a>
1337 - *
1338 - * @since 4.1
1339 - */
1340 - do_action( 'mainwp_add_new_menu_option' );
1341 - ?>
1342 - </div>
1343 - </div>
1344 - </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 + }
1345 1569
1346 - <?php if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) || isset( $_GET['cacheControlId'] ) ) : ?>
1347 - <?php if ( isset( $_GET['dashboard'] ) ) : ?>
1348 - <?php $website_id = intval( $_GET['dashboard'] ); ?>
1349 - <?php elseif ( isset( $_GET['updateid'] ) ) : ?>
1350 - <?php $website_id = intval( $_GET['updateid'] ); ?>
1351 - <?php elseif ( isset( $_GET['emailsettingsid'] ) ) : ?>
1352 - <?php $website_id = intval( $_GET['emailsettingsid'] ); ?>
1353 - <?php elseif ( isset( $_GET['scanid'] ) ) : ?>
1354 - <?php $website_id = intval( $_GET['scanid'] ); ?>
1355 - <?php elseif ( isset( $_GET['cacheControlId'] ) ) : ?>
1356 - <?php $website_id = intval( $_GET['cacheControlId'] ); ?>
1357 - <?php else : ?>
1358 - <?php $website_id = intval( $_GET['id'] ); ?>
1359 - <?php endif; ?>
1360 - <a id="mainwp-go-wp-admin-button" href="<?php MainWP_Site_Open::get_open_site_url( $website_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="bottom right" data-inverted="" class="open_newwindow_wpadmin ui green basic icon button" target="_blank"><i class="sign in icon"></i></a>
1361 - <a id="mainwp-remove-site-button" href="#" site-id="<?php echo intval( $website_id ); ?>" data-tooltip="<?php esc_attr_e( 'Remove the site from your MainWP Dashboard.', 'mainwp' ); ?>" data-position="bottom right" data-inverted="" class="mainwp-remove-site-button ui red basic icon button" target="_blank"><i class="times icon"></i></a>
1362 - <?php endif; ?>
1363 - <?php if ( ( 'mainwp_tab' === $page ) || isset( $_GET['dashboard'] ) || in_array( $page, $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
1364 - <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' ); ?>">
1365 - <i class="cog icon"></i>
1366 - </a>
1367 - <?php endif; ?>
1368 - <?php
1369 - // phpcs:enable
1370 - /**
1371 - * Filter: mainwp_header_actions_right
1372 - *
1373 - * Filters the MainWP header element actions.
1374 - *
1375 - * @since 4.0
1376 - */
1377 - $actions = apply_filters( 'mainwp_header_actions_right', '' );
1378 - if ( ! empty( $actions ) ) {
1379 - echo $actions; // phpcs:ignore WordPress.Security.EscapeOutput
1380 - }
1381 - ?>
1382 - <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' ); ?>">
1383 - <i class="globe icon"></i>
1384 - </a>
1385 - <a class="ui button basic icon" id="mainwp-help-sidebar" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Need help?', 'mainwp' ); ?>">
1386 - <i class="life ring icon"></i>
1387 - </a>
1388 - <a id="mainwp-community-button" class="ui button basic icon" data-inverted="" data-position="bottom right" href="https://managers.mainwp.com/" target="_blank" data-tooltip="<?php esc_attr_e( 'MainWP Community', 'mainwp' ); ?>">
1389 - <i class="discourse icon"></i>
1390 - </a>
1391 - <a id="mainwp-account-button" class="ui button basic icon" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to your MainWP Account at MainWP.com', 'mainwp' ); ?>" target="_blank" href="https://mainwp.com/my-account/">
1392 - <i class="user icon"></i>
1393 - </a>
1394 - <?php
1395 - $custom_theme = MainWP_Settings::get_instance()->get_current_user_theme();
1396 - ?>
1397 - <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' ); ?>">
1398 - <i class="sun icon"></i>
1399 - </div>
1400 - <?php
1401 - /**
1402 - * After select theme actions.
1403 - *
1404 - * @since 4.5.2
1405 - */
1406 - do_action( 'mainwp_header_actions_after_select_themes' );
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;
1407 1613
1408 - $all_updates = wp_get_update_data();
1409 - if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) {
1410 - ?>
1411 - <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">
1412 - <i class="exclamation triangle icon"></i>
1413 - </a>
1414 - <?php
1415 - }
1416 - $output = ob_get_clean();
1417 - return $output;
1418 - }
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;
1419 1642
1420 - /**
1421 - * Method render_page_navigation()
1422 - *
1423 - * Render page navigation.
1424 - *
1425 - * @param array $subitems [access, active, style].
1426 - * @param null $name_caller Menu Name.
1427 - */
1428 - public static function render_page_navigation( $subitems = array(), $name_caller = null ) {
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; ?>
1429 1660
1430 - /**
1431 - * Filter: mainwp_page_navigation
1432 - *
1433 - * Filters MainWP page navigation menu items.
1434 - *
1435 - * @since 4.0
1436 - */
1437 - $subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller );
1438 - ?>
1439 - <div id="mainwp-page-navigation-wrapper">
1440 - <div class="ui secondary green pointing menu stackable mainwp-page-navigation">
1441 - <?php
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>
1442 1676
1443 - if ( is_array( $subitems ) ) {
1444 - foreach ( $subitems as $item ) {
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; ?>
1445 1682
1446 - if ( ! is_array( $item ) ) {
1447 - continue;
1448 - }
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>
1449 1688
1450 - if ( isset( $item['access'] ) && ! $item['access'] ) {
1451 - continue;
1452 - }
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>
1453 1721
1454 - $class = '';
1455 - if ( isset( $item['active'] ) && $item['active'] ) {
1456 - $class = 'active';
1457 - }
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 + }
1458 1802
1459 - if ( isset( $item['class'] ) ) {
1460 - $class = $class . ' ' . $item['class'];
1461 - }
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.
1462 1812
1463 - $style = '';
1464 - if ( isset( $item['style'] ) ) {
1465 - $style = $item['style'];
1466 - }
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 );
1467 1842
1468 - ?>
1469 - <a class="<?php echo esc_attr( $class ); ?> item" style="<?php echo esc_attr( $style ); ?>" href="<?php echo esc_url( $item['href'] ); ?>">
1470 - <?php echo esc_html( $item['title'] ); ?> <?php echo isset( $item['after_title'] ) ? $item['after_title'] : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?>
1471 - </a>
1472 - <?php
1473 - }
1474 - }
1475 - do_action( 'mainwp_page_navigation_menu' );
1476 - ?>
1477 - </div>
1478 - </div>
1479 - <?php
1480 - }
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">
1481 1853
1482 - /**
1483 - * Method render_header()
1484 - *
1485 - * Render page title.
1486 - *
1487 - * @param string $title Page title.
1488 - *
1489 - * @return void Render page title and hidden divider html.
1490 - */
1491 - public static function render_header( $title = '' ) {
1492 - self::render_top_header( array( 'title' => $title ) );
1493 - echo '<div class="ui hidden clearing fitted divider"></div>';
1494 - echo '<div class="wrap">';
1495 - }
1854 + <?php
1496 1855
1497 - /**
1498 - * Method render_footer()
1499 - *
1500 - * Render page footer.
1501 - *
1502 - * @return void Render closing tags for page container.
1503 - */
1504 - public static function render_footer() {
1505 - echo '</div>';
1506 - echo '</div>';
1507 - }
1856 + if ( is_array( $subitems ) ) {
1857 + foreach ( $subitems as $item ) {
1508 1858
1509 - /**
1510 - * Method add_widget_box()
1511 - *
1512 - * Customize WordPress add_meta_box() function.
1513 - *
1514 - * @param mixed $id Widget ID parameter.
1515 - * @param mixed $callback Callback function.
1516 - * @param null $screen Current page.
1517 - * @param array $layout widget layout.
1518 - *
1519 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1520 - */
1521 - public static function add_widget_box( $id, $callback, $screen = null, $layout = array() ) {
1522 - /**
1523 - * MainWP widget boxes array.
1524 - *
1525 - * @global object
1526 - */
1527 - global $mainwp_widget_boxes;
1859 + if ( ! is_array( $item ) ) {
1860 + continue;
1861 + }
1528 1862
1529 - $page = MainWP_System_Utility::get_page_id( $screen );
1863 + if ( isset( $item['access'] ) && ! $item['access'] ) {
1864 + continue;
1865 + }
1530 1866
1531 - if ( empty( $page ) ) {
1532 - return;
1533 - }
1867 + $class = '';
1868 + if ( isset( $item['active'] ) && $item['active'] ) {
1869 + $class = 'active';
1870 + }
1534 1871
1535 - if ( ! isset( $mainwp_widget_boxes ) ) {
1536 - $mainwp_widget_boxes = array();
1537 - }
1538 - if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
1539 - $mainwp_widget_boxes[ $page ] = array();
1540 - }
1872 + if ( isset( $item['class'] ) ) {
1873 + $class = $class . ' ' . $item['class'];
1874 + }
1541 1875
1542 - if ( empty( $title ) ) {
1543 - $title = 'No Title';
1544 - }
1545 - $mainwp_widget_boxes[ $page ][ $id ] = array(
1546 - 'id' => $id,
1547 - 'callback' => $callback,
1548 - 'layout' => $layout,
1549 - );
1550 - }
1876 + $style = '';
1877 + if ( isset( $item['style'] ) ) {
1878 + $style = $item['style'];
1879 + }
1551 1880
1552 - /**
1553 - * Method do_widget_boxes()
1554 - *
1555 - * Customize WordPress do_meta_boxes() function.
1556 - *
1557 - * @param mixed $screen_id Current page ID.
1558 - *
1559 - * @return void Renders widget container box.
1560 - *
1561 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
1562 - */
1563 - public static function do_widget_boxes( $screen_id ) { // phpcs:ignore -- complex.
1564 - global $mainwp_widget_boxes;
1565 - $page = MainWP_System_Utility::get_page_id( $screen_id );
1566 - if ( empty( $page ) ) {
1567 - return;
1568 - }
1569 - $wgsorted = get_user_option( 'mainwp_widgets_sorted_' . strtolower( $page ) );
1570 - if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
1571 - $wgsorted = json_decode( $wgsorted, true );
1572 - }
1881 + $target = '';
1882 + if ( isset( $item['target'] ) ) {
1883 + $target = $item['target'];
1884 + }
1573 1885
1574 - $client_id = 0;
1575 - if ( 'mainwp_page_manageclients' === $page ) {
1576 - $sorted_array = is_array( $wgsorted ) ? $wgsorted : array();
1577 - $wgsorted = array();
1578 - $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
1579 - if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
1580 - $wgsorted = $sorted_array[ $client_id ];
1581 - }
1582 - }
1886 + $rel = '';
1887 + if ( isset( $item['rel'] ) ) {
1888 + $rel = $item['rel'];
1889 + } elseif ( '_blank' === $target ) {
1890 + $rel = 'noopener noreferrer';
1891 + }
1583 1892
1584 - if ( ! is_array( $wgsorted ) ) {
1585 - $wgsorted = array();
1586 - }
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 + }
1587 1900
1588 - if ( 'mainwp_page_manageclients' === $page ) {
1589 - $show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
1590 - } elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
1591 - $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
1592 - } else {
1593 - $show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
1594 - }
1901 + do_action( 'mainwp_page_navigation_menu' );
1902 + ?>
1903 + </div>
1595 1904
1596 - if ( ! is_array( $show_widgets ) ) {
1597 - $show_widgets = array();
1598 - }
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 + }
1599 1912
1600 - if ( isset( $mainwp_widget_boxes[ $page ] ) ) {
1601 - foreach ( (array) $mainwp_widget_boxes[ $page ] as $box ) {
1602 - if ( false === $box || ! isset( $box['callback'] ) ) {
1603 - continue;
1604 - }
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 + }
1605 1927
1606 - // to avoid hidden widgets.
1607 - if ( isset( $show_widgets[ $box['id'] ] ) && 0 === (int) $show_widgets[ $box['id'] ] ) {
1608 - continue;
1609 - }
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 + }
1610 1943
1611 - $layout = array();
1612 - if ( isset( $wgsorted[ $box['id'] ] ) ) {
1613 - $val = $wgsorted[ $box['id'] ];
1614 - if ( is_array( $val ) && isset( $val['col'] ) ) {
1615 - $layout = array(
1616 - 'col' => $val['col'],
1617 - 'row' => $val['row'],
1618 - 'size_x' => $val['size_x'],
1619 - 'size_y' => $val['size_y'],
1620 - );
1621 - }
1622 - }
1623 - if ( ! isset( $layout['col'] ) && isset( $box['layout'][0] ) ) {
1624 - $layout = array(
1625 - 'col' => $box['layout'][0],
1626 - 'row' => $box['layout'][1],
1627 - 'size_x' => $box['layout'][2],
1628 - 'size_y' => $box['layout'][3],
1629 - );
1630 - }
1631 - echo '<div id="widget-' . esc_html( $box['id'] ) . '" class="ui segment mainwp-widget" 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'] ) : '' ) . '">' . "\n";
1632 - call_user_func( $box['callback'] );
1633 - echo '<span class="mainwp-resize-handle"></span>' . "\n";
1634 - echo "</div>\n";
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;
1635 1963
1636 - }
1637 - }
1638 - $breakpoint = apply_filters( 'mainwp_flexible_widgets_breakpoint', 1367 );
1639 - ?>
1640 - <script type="text/javascript">
1641 - var is_mobile = false;
1642 - if( jQuery( window ).width() < <?php echo intval( $breakpoint ); ?> ) {
1643 - is_mobile = true;
1644 - }
1645 - if ( ! is_mobile ) {
1646 - var page_sortablewidgets = '<?php echo esc_js( $page ); ?>';
1647 - jQuery( document ).ready( function( $ ) {
1648 - var wgIds = [];
1649 - jQuery( ".mainwp-widget" ).each( function () {
1650 - wgIds.push( jQuery( this ).attr('id') );
1651 - } );
1964 + $page = MainWP_System_Utility::get_page_id( $screen );
1652 1965
1653 - jQuery( '.gridster' ).gridster( {
1654 - auto_init: true,
1655 - autogenerate_stylesheet: true,
1656 - shift_larger_widgets_down: false,
1657 - shift_widgets_up: true,
1658 - widget_selector: "div.mainwp-widget",
1659 - widget_margins: [20, 20],
1660 - widget_base_dimensions: ["auto", 100],
1661 - min_cols: 1,
1662 - max_cols: 6,
1663 - max_size_x: 6,
1664 - max_rows: 300,
1665 - avoid_overlapped_widgets: true,
1666 - collision: {
1667 - wait_for_mouseup: true
1668 - },
1669 - draggable: {
1670 - handle: '.handle-drag',
1671 - stop: function (e, ui, $widget) {
1672 - mainwp_overview_gridster_reorder(this);
1673 - }
1674 - },
1675 - resize: {
1676 - enabled: true,
1677 - handle_append_to: ".mainwp-resize-handle",
1678 - stop: function (e, ui, $widget) {
1679 - mainwp_overview_gridster_reorder(this);
1680 - }
1681 - }
1682 - } ).data('gridster');
1966 + if ( empty( $page ) ) {
1967 + return;
1968 + }
1683 1969
1684 - mainwp_overview_gridster_reorder = function( $gridObj ){
1685 - var orders = $gridObj.serialize();
1686 - var postVars = {
1687 - action:'mainwp_widgets_order',
1688 - page: page_sortablewidgets,
1689 - order:JSON.stringify(orders),
1690 - wgids: JSON.stringify(wgIds),
1691 - item_id: <?php echo intval( $client_id ); ?>
1692 - };
1693 - jQuery.post( ajaxurl, mainwp_secure_data( postVars ), function ( res ) {
1694 - } );
1695 - }
1696 - });
1697 - }
1698 - </script>
1699 - <?php
1700 - }
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 + }
1701 1976
1702 - /**
1703 - * Method render_empty_bulk_actions()
1704 - *
1705 - * Render empty bulk actions when drop down is disabled.
1706 - */
1707 - public static function render_empty_bulk_actions() {
1708 - ?>
1709 - <select class="ui disabled dropdown" id="mainwp-bulk-actions">
1710 - <option value=""><?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?></option>
1711 - </select>
1712 - <button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button>
1713 - <?php
1714 - }
1977 + $mainwp_widget_boxes[ $page ][ $id ] = array(
1978 + 'id' => $id,
1979 + 'callback' => $callback,
1980 + 'layout' => $layout,
1981 + );
1982 + }
1715 1983
1716 - /**
1717 - * Method render_modal_install_plugin_theme()
1718 - *
1719 - * Render modal window for installing plugins & themes.
1720 - *
1721 - * @param string $what Which window to render, plugin|theme.
1722 - */
1723 - public static function render_modal_install_plugin_theme( $what = 'plugin' ) {
1724 - ?>
1725 - <div id="plugintheme-installation-progress-modal" class="ui modal">
1726 - <div class="header">
1727 - <?php
1728 - if ( 'plugin' === $what ) {
1729 - esc_html_e( 'Plugin Installation', 'mainwp' );
1730 - } elseif ( 'theme' === $what ) {
1731 - esc_html_e( 'Theme Installation', 'mainwp' );
1732 - }
1733 - ?>
1734 - </div>
1735 - <div class="ui green progress mainwp-modal-progress">
1736 - <div class="bar"><div class="progress"></div></div>
1737 - <div class="label"></div>
1738 - </div>
1739 - <div class="scrolling content">
1740 - <?php
1741 - /**
1742 - * Action: mainwp_before_plugin_theme_install_progress
1743 - *
1744 - * Fires before the progress list in the install modal element.
1745 - *
1746 - * @since 4.1
1747 - */
1748 - do_action( 'mainwp_before_plugin_theme_install_progress' );
1749 - ?>
1750 - <div id="plugintheme-installation-queue"></div>
1751 - <?php
1752 - /**
1753 - * Action: mainwp_after_plugin_theme_install_progress
1754 - *
1755 - * Fires after the progress list in the install modal element.
1756 - *
1757 - * @since 4.1
1758 - */
1759 - do_action( 'mainwp_after_plugin_theme_install_progress' );
1760 - ?>
1761 - </div>
1762 - <div class="actions">
1763 - <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1764 - </div>
1765 - </div>
1766 - <?php
1767 - }
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 + }
1768 2002
1769 - /**
1770 - * Method render_modal_upload_icon()
1771 - *
1772 - * Render modal window for upload plugins & themes icon.
1773 - */
1774 - public static function render_modal_upload_icon() {
2003 + $page_widget = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
1775 2004
1776 - ?>
1777 - <div id="mainwp-upload-custom-icon-modal" class="ui modal">
1778 - <div class="header">
1779 - <?php
1780 - esc_html_e( 'Update Icon', 'mainwp' );
1781 - ?>
1782 - </div>
1783 - <div class="content" id="mainwp-upload-custom-icon-content">
1784 - <form action="" method="post" enctype="multipart/form-data" name="uploadicon_form" id="uploadicon_form" class="">
1785 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1786 - <div class="ui message" id="mainwp-message-zone-upload" style="display:none;"></div>
1787 - <?php
1788 - /**
1789 - * Action: mainwp_after_upload_custom_icon
1790 - *
1791 - * Fires before the modal element.
1792 - *
1793 - * @since 4.3
1794 - */
1795 - do_action( 'mainwp_before_upload_custom_icon' );
1796 - ?>
1797 - <div class="ui form">
1798 - <div class="ui grid field">
1799 - <label class="six wide column middle aligned"><?php esc_html_e( 'Custom icon', 'mainwp' ); ?></label>
1800 - <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Upload a custom icon.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1801 - <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' ); ?>" />
1802 - </div>
1803 - </div>
1804 - <div class="ui grid field" id="mainwp_delete_image_field">
1805 - <label class="six wide column middle aligned"></label>
1806 - <div class="six wide column">
1807 - <img class="ui tiny image" src="" /><br/>
1808 - <div class="ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, delete image.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1809 - <input type="checkbox"id="mainwp_delete_image_chk" />
1810 - <label for="mainwp_delete_image_chk"><?php esc_html_e( 'Delete Image', 'mainwp' ); ?></label>
1811 - </div>
1812 - </div>
1813 - </div>
1814 - </div>
1815 - <?php
1816 - /**
1817 - * Action: mainwp_after_upload_custom_icon
1818 - *
1819 - * Fires after the modal element.
1820 - *
1821 - * @since 4.3
1822 - */
1823 - do_action( 'mainwp_after_upload_custom_icon' );
1824 - ?>
1825 - </form>
1826 - </div>
1827 - <div class="actions">
1828 - <div class="ui green button" id="update_custom_icon_btn"><?php esc_html_e( 'Update', 'mainwp' ); ?></div>
1829 - <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1830 - </div>
1831 - </div>
1832 - <?php
1833 - }
2005 + $wgsorted = false;
2006 + $selected_widget_layout = '';
1834 2007
1835 - /**
1836 - * Method render_show_all_updates_button()
1837 - *
1838 - * Render show all updates button.
1839 - *
1840 - * @return void Render Show All Updates button html.
1841 - */
1842 - public static function render_show_all_updates_button() {
1843 - ?>
1844 - <a href="javascript:void(0)" class="ui mini button trigger-all-accordion">
1845 - <?php
1846 - /**
1847 - * Filter: mainwp_show_all_updates_button_text
1848 - *
1849 - * Filters the Show All Updates button text.
1850 - *
1851 - * @since 4.1
1852 - */
1853 - echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', esc_html__( 'Show All Updates', 'mainwp' ) ) );
1854 - ?>
1855 - </a>
1856 - <?php
1857 - }
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
1858 2011
1859 - /**
1860 - * Method render_sorting_icons()
1861 - *
1862 - * Render sorting up & down icons.
1863 - *
1864 - * @return void Render Sort up & down incon html.
1865 - */
1866 - public static function render_sorting_icons() {
1867 - ?>
1868 - <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"></i>
1869 - <?php
1870 - }
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 + }
1871 2021
1872 - /**
1873 - * Method render_modal_edit_notes()
1874 - *
1875 - * Render modal window for edit notes.
1876 - *
1877 - * @param string $what What modal window to render. Default = site.
1878 - *
1879 - * @return void
1880 - */
1881 - public static function render_modal_edit_notes( $what = 'site' ) {
1882 - ?>
1883 - <div id="mainwp-notes-modal" class="ui modal">
1884 - <div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div>
1885 - <div class="content" id="mainwp-notes-content">
1886 - <div id="mainwp-notes-status" class="ui message hidden"></div>
1887 - <?php
1888 - /**
1889 - * Action: mainwp_before_edit_site_note
1890 - *
1891 - * Fires before the site note content in the Edit Note modal element.
1892 - *
1893 - * @since 4.1
1894 - */
1895 - do_action( 'mainwp_before_edit_site_note' );
1896 - ?>
1897 - <div id="mainwp-notes-html"></div>
1898 - <div id="mainwp-notes-editor" class="ui form" style="display:none;">
1899 - <div class="field">
1900 - <label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label>
1901 - <textarea id="mainwp-notes-note"></textarea>
1902 - </div>
1903 - <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>
1904 - </div>
1905 - <?php
1906 - /**
1907 - * Action: mainwp_after_edit_site_note
1908 - *
1909 - * Fires after the site note content in the Edit Note modal element.
1910 - *
1911 - * @since 4.1
1912 - */
1913 - do_action( 'mainwp_after_edit_site_note' );
1914 - ?>
1915 - </div>
1916 - <div class="actions">
1917 - <div class="ui grid">
1918 - <div class="eight wide left aligned middle aligned column">
1919 - <input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save Note', 'mainwp' ); ?>" style="display:none;"/>
1920 - <input type="button" class="ui green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit Note', 'mainwp' ); ?>"/>
1921 - </div>
1922 - <div class="eight wide column">
1923 - <input type="button" class="ui button" id="mainwp-notes-cancel" value="<?php esc_attr_e( 'Close', 'mainwp' ); ?>"/>
1924 - <input type="hidden" id="mainwp-notes-websiteid" value=""/>
1925 - <input type="hidden" id="mainwp-notes-slug" value=""/>
1926 - <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
1927 - <input type="hidden" id="mainwp-notes-itemid" value=""/>
1928 - </div>
1929 - </div>
1930 - </div>
1931 - </div>
2022 + if ( empty( $wgsorted ) ) {
2023 + $wgsorted = get_user_option( 'mainwp_widgets_sorted_' . $page );
2024 + }
1932 2025
1933 - <?php
1934 - }
2026 + if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
2027 + $wgsorted = json_decode( $wgsorted, true );
2028 + }
1935 2029
1936 - /**
1937 - * No Sites Modal
1938 - *
1939 - * Renders modal window for notification when there are no connected sites.
1940 - *
1941 - * @return void
1942 - */
1943 - public static function render_modal_no_sites_note() {
1944 - if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-no-sites-modal-notice' ) ) :
1945 - ?>
1946 - <div id="mainwp-no-sites-modal" class="ui small modal">
1947 - <div class="content" id="mainwp-no-sites-modal-content" style="text-align:center">
1948 - <div class="ui hidden divider"></div>
1949 - <div class="ui hidden divider"></div>
1950 - <h4><?php esc_html_e( 'Hi MainWP Manager, there is not anything to see here before connecting your first site.', 'mainwp' ); ?></h4>
1951 - <div class="ui hidden divider"></div>
1952 - <div class="ui hidden divider"></div>
1953 - <a href="admin.php?page=managesites&do=new" class="ui big green button"><?php esc_html_e( 'Connect Your WordPress Site', 'mainwp' ); ?></a>
1954 - <div class="ui hidden fitted divider"></div>
1955 - <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>
1956 - </div>
1957 - <div class="actions">
1958 - <div class="ui grid">
1959 - <div class="eight wide left aligned middle aligned column">
1960 - <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>
1961 - </div>
1962 - <div class="eight wide column">
1963 - <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' ); ?>"/>
1964 - </div>
1965 - </div>
1966 - </div>
1967 - </div>
1968 - <script type="text/javascript">
1969 - jQuery( '#mainwp-no-sites-modal' ).modal( {
1970 - blurring: true,
1971 - inverted: true,
1972 - closable: false
1973 - } ).modal( 'show' );
1974 - </script>
1975 - <?php
1976 - endif;
1977 - }
2030 + if ( ! is_array( $wgsorted ) ) {
2031 + $wgsorted = array();
2032 + }
1978 2033
1979 - /**
1980 - * Method render_screen_options()
1981 - *
1982 - * Render modal window for Page Settings.
1983 - *
1984 - * @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Overview page.
1985 - *
1986 - * @return void Render modal window for Page Settings html.
1987 - */
1988 - 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.
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 + }
1989 2043
1990 - $default_widgets = array(
1991 - 'overview' => esc_html__( 'Updates Overview', 'mainwp' ),
1992 - 'recent_posts' => esc_html__( 'Recent Posts', 'mainwp' ),
1993 - 'recent_pages' => esc_html__( 'Recent Pages', 'mainwp' ),
1994 - 'plugins' => esc_html__( 'Plugins (Individual Site Overview page)', 'mainwp' ),
1995 - 'themes' => esc_html__( 'Themes (Individual Site Overview page)', 'mainwp' ),
1996 - 'connection_status' => esc_html__( 'Connection Status', 'mainwp' ),
1997 - 'security_issues' => esc_html__( 'Security Issues', 'mainwp' ),
1998 - 'notes' => esc_html__( 'Notes (Individual Site Overview page)', 'mainwp' ),
1999 - 'clients' => esc_html__( 'Clients', 'mainwp' ),
2000 - 'child_site_info' => esc_html__( 'Child site info (Individual Site Overview page)', 'mainwp' ),
2001 - 'client_info' => esc_html__( 'Client info (Individual Site Overview page)', 'mainwp' ),
2002 - 'non_mainwp_changes' => esc_html__( 'Non-MainWP Changes', 'mainwp' ),
2003 - );
2044 + $wgsorted = apply_filters( 'mainwp_do_widget_boxes_sorted', $wgsorted, $page, $client_id );
2004 2045
2005 - $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.
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 + }
2006 2053
2007 - /**
2008 - * Filter: mainwp_widgets_screen_options
2009 - *
2010 - * Filters available widgets on the Overview page allowing users to unsent unwanted widgets.
2011 - *
2012 - * @since 4.0
2013 - */
2014 - $custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts );
2054 + if ( ! is_array( $show_widgets ) ) {
2055 + $show_widgets = array();
2056 + }
2015 2057
2016 - if ( is_array( $custom_opts ) && 0 < count( $custom_opts ) ) {
2017 - $default_widgets = array_merge( $default_widgets, $custom_opts );
2018 - }
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 + }
2019 2072
2020 - $show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
2073 + // to avoid hidden widgets.
2074 + if ( isset( $show_widgets[ $box['id'] ] ) && 0 === (int) $show_widgets[ $box['id'] ] ) {
2075 + continue;
2076 + }
2021 2077
2022 - if ( ! is_array( $show_widgets ) ) {
2023 - $show_widgets = array();
2024 - }
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 + }
2025 2090
2026 - $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
2027 - $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
2028 - $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
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 + }
2029 2100
2030 - /**
2031 - * Action: mainwp_screen_options_modal_top
2032 - *
2033 - * Fires at the top of the Page Settings modal element.
2034 - *
2035 - * @since 4.1
2036 - */
2037 - do_action( 'mainwp_screen_options_modal_top' );
2038 - $which_settings = 'overview_settings';
2039 - ?>
2040 - <?php if ( ! $setting_page ) : ?>
2041 - <?php if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2042 - <?php
2043 - $which_settings = 'sidebar_settings';
2044 - $sidebarPosition = (int) get_user_option( 'mainwp_sidebarPosition', 1 );
2045 - $manageGroupsPage = false;
2046 - if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
2047 - $manageGroupsPage = true;
2048 - }
2049 - ?>
2050 - <div class="ui grid field">
2051 - <label tabindex="0" class="six wide column middle aligned"><?php echo $manageGroupsPage ? esc_html__( 'Tags menu position', 'mainwp' ) : esc_html__( 'Sidebar position', 'mainwp' ); ?></label>
2052 - <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">
2053 - <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
2054 - <option value="1" <?php echo ( 1 === $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Right', 'mainwp' ); ?></option>
2055 - <option value="0" <?php echo ( 0 === $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
2056 - </select>
2057 - </div>
2058 - </div>
2059 - <?php endif; ?>
2060 - <?php endif; ?>
2061 - <?php if ( isset( $_GET['page'] ) && ! in_array( $_GET['page'], $sidebar_pages ) ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended ?>
2062 - <div class="ui grid field">
2063 - <label class="six wide column middle aligned"><?php esc_html_e( 'Hide the Update Everything button', 'mainwp' ); ?></label>
2064 - <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">
2065 - <input type="checkbox" name="hide_update_everything" <?php echo ( ( 1 === (int) get_option( 'mainwp_hide_update_everything' ) ) ? 'checked="true"' : '' ); ?> />
2066 - </div>
2067 - </div>
2068 - <div class="ui grid field">
2069 - <label class="six wide column"><?php esc_html_e( 'Show widgets', 'mainwp' ); ?></label>
2070 - <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">
2071 - <ul class="mainwp_hide_wpmenu_checkboxes">
2072 - <?php
2073 - foreach ( $default_widgets as $name => $title ) {
2074 - $_selected = '';
2075 - if ( ! isset( $show_widgets[ $name ] ) || 1 === (int) $show_widgets[ $name ] ) {
2076 - $_selected = 'checked';
2077 - }
2078 - ?>
2079 - <li>
2080 - <div class="ui checkbox">
2081 - <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 ); ?>">
2082 - <label for="mainwp_show_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
2083 - </div>
2084 - <input type="hidden" name="mainwp_widgets_name[]" value="<?php echo esc_attr( $name ); ?>">
2085 - </li>
2086 - <?php
2087 - }
2088 - ?>
2089 - </ul>
2090 - </div>
2091 - </div>
2092 - <?php endif; ?>
2093 - <input type="hidden" name="reset_overview_which_settings" value="<?php echo esc_html( $which_settings ); ?>" />
2094 - <?php
2095 - /**
2096 - * Action: mainwp_screen_options_modal_bottom
2097 - *
2098 - * Fires at the bottom of the Page Settings modal element.
2099 - *
2100 - * @since 4.1
2101 - */
2102 - do_action( 'mainwp_screen_options_modal_bottom' );
2103 - }
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 + }
2104 2114
2105 - /**
2106 - * Method render_select_mainwp_themes_modal()
2107 - *
2108 - * Render modal window for mainwp themes selection.
2109 - *
2110 - * @return void Render modal window for themes selection.
2111 - */
2112 - public static function render_select_mainwp_themes_modal() {
2113 - ?>
2114 - <div class="ui modal" id="mainwp-select-mainwp-themes-modal">
2115 - <div class="header"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></div>
2116 - <div class="content ui form">
2117 - <div class="ui blue message">
2118 - <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>
2119 - </div>
2120 - <form method="POST" action="" name="mainwp_select_mainwp_themes_form" id="mainwp_select_mainwp_themes_form">
2121 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2122 - <input type="hidden" name="wp_scr_options_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPSelectThemes' ) ); ?>" />
2123 - <?php
2124 - /**
2125 - * Action: mainwp_select_themes_modal_top
2126 - *
2127 - * Fires at the top of the modal.
2128 - *
2129 - * @since 4.3
2130 - */
2131 - do_action( 'mainwp_select_themes_modal_top' );
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";
2132 2120
2133 - MainWP_Settings::get_instance()->render_select_custom_themes();
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);
2134 2149
2135 - /**
2136 - * Action: mainwp_select_themes_modal_bottom
2137 - *
2138 - * Fires at the bottom of the modal.
2139 - *
2140 - * @since 4.3
2141 - */
2142 - do_action( 'mainwp_select_themes_modal_bottom' );
2143 - ?>
2144 - </div>
2145 - <div class="actions">
2146 - <div class="ui two columns grid">
2147 - <div class="left aligned column">
2148 - <input type="submit" class="ui green button" id="submit-select-mainwp-themes" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2149 - </div>
2150 - <div class="ui right aligned column">
2151 - <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
2152 - </div>
2153 - </div>
2154 - </div>
2155 - </form>
2156 - </div>
2157 - <?php
2158 - }
2150 + grid.on('change', function() {
2151 + mainwp_overview_gridstack_save_layout(<?php echo (int) $client_id; ?>, grid);
2152 + });
2153 +
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 + }
2157 +
2158 + jQuery('#mainwp-widgets-placeholder').dimmer('hide');
2159 + });
2160 + </script>
2161 + <?php
2162 + }
2163 +
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;
2177 +
2178 + $screen_page_id = MainWP_System_Utility::get_page_id();
2179 +
2180 + if ( empty( $screen_page_id ) ) {
2181 + return;
2182 + }
2183 +
2184 + if ( ! is_array( $params ) ) {
2185 + $params = array();
2186 + }
2187 +
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 + }
2159 3622 }