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