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
mainwp / class / class-mainwp-ui.php

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

881 lines 40.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class MainWP_UI {
4
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 ) {
6
7 if ( $postId ) {
8 $selected_websites = unserialize( base64_decode( get_post_meta( $postId, '_selected_sites', true ) ) );
9 if ( $selected_websites == '' ) {
10 $selected_websites = array();
11 }
12
13 $selected_groups = unserialize( base64_decode( get_post_meta( $postId, '_selected_groups', true ) ) );
14 if ( $selected_groups == '' ) {
15 $selected_groups = array();
16 }
17 }
18
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 ); ?>
22 </div>
23 <?php
24 }
25
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 ) {
27
28 if ( $selected_websites != 'all' && !is_array( $selected_websites ) ) {
29 $selected_websites = array();
30 }
31
32 if ( !is_array( $selected_groups ) ) {
33 $selected_groups = array();
34 }
35
36 $websites = MainWP_DB::Instance()->query( MainWP_DB::Instance()->getSQLWebsitesForCurrentUser() );
37 $groups = MainWP_DB::Instance()->getNotEmptyGroups( null, $enableOfflineSites );
38
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' );
41
42 $edit_site_id = false;
43 if ( $postId ) {
44 $edit_site_id = get_post_meta( $postId, '_mainwp_edit_post_site_id', true );
45 $edit_site_id = intval( $edit_site_id );
46 }
47
48 if ( $edit_site_id ) {
49 $show_group = false;
50 }
51 // to fix layout with multi sites selector
52 $tab_id = rand();
53 ?>
54
55
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>
72
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>
117 </div>
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>
134
135 </div>
136
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 }
159 }
160 ?>
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>
167 <?php
168 } else {
169 ?>
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>
176 <?php
177 }
178
179 }
180 @MainWP_DB::free_result( $websites );
181 endif;
182
183 ?>
184 </div>
185 </div>
186
187 </div>
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>
218
219 </div>
220
221
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>
227
228
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 }
234
235 public static function render_top_header( $params = array() ) {
236
237 $title = isset($params['title']) ? $params['title'] : '';
238 $title = apply_filters( 'mainwp_header_title', $title );
239
240 $show_menu = true;
241 $show_new_items = true;
242
243 if ( isset($params['show_menu'] ) )
244 $show_menu = $params['show_menu'];
245
246 $left = apply_filters( 'mainwp_header_left', $title );
247
248 $right = self::render_header_actions();
249 $right = apply_filters( 'mainwp_header_right', $right );
250
251
252
253 if ( $show_menu )
254 MainWP_Menu::render_left_menu();
255
256
257 $sidebarPosition = get_user_option( "mainwp_sidebarPosition" );
258 if ( $sidebarPosition === false )
259 $sidebarPosition = 1;
260
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>
267
268 <a href="https://mainwp.com/help/" class="ui big green fluid button"><?php echo __( 'Help Documentation', 'mainwp' ); ?></a>
269
270 <div class="ui hidden divider"></div>
271
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 }
303
304 public static function render_second_top_header ( $which = '' ) {
305 do_action( 'mainwp_before_subheader' );
306
307 if (has_action('mainwp_subheader_actions') || $which == 'overview' || $which == 'managesites') {
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 }
325
326 do_action( 'mainwp_after_subheader' );
327 }
328
329 public static function gen_groups_sites_selection() {
330
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 });
366
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 );
378
379 }
380
381
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;
414 ?>
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 -->
423
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 }
446
447 public static function render_page_navigation( $subitems = array(), $name_caller = null ) {
448
449 /**
450 * This hook allows you to add extra pages navigation via the 'mainwp_page_navigation' filter.
451 */
452 $subitems = apply_filters( 'mainwp_page_navigation', $subitems , $name_caller );
453
454 ?>
455 <div id="mainwp-page-navigation-wrapper">
456 <div class="ui secondary green pointing menu stackable mainwp-page-navigation">
457 <?php
458
459 if ( is_array( $subitems )) {
460 foreach ( $subitems as $item ) {
461
462 if ( isset( $item[ 'access' ] ) && ! $item[ 'access' ] ) {
463 continue;
464 }
465
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 }
474
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 }
485
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 }
493
494 public static function renderFooter() {
495 ?>
496 </div>
497 </div>
498 <?php
499 }
500
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 }
515
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 }
526
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 }
532
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;
537
538 $page = MainWP_Utility::get_page_id( $screen );
539
540 if (empty($page))
541 return;
542
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 }
552
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();
559
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;
564
565 // If box previously deleted, don't add
566 if ( false === $mainwp_widget_boxes[$page][$a_context][$a_priority][$id] )
567 return;
568
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'];
579 }
580
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]);
584
585 }
586 }
587
588 if ( !isset($mainwp_widget_boxes[$page][$context]) )
589 $mainwp_widget_boxes[$page][$context] = array();
590
591 if ( empty($priority) )
592 $priority = 'default';
593
594 if ( empty($title) ) {
595 $title = 'No Title';
596 }
597 $mainwp_widget_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
598 }
599
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;
604
605 $page = MainWP_Utility::get_page_id( $screen );
606
607 if (empty($page))
608 return;
609
610 $overviewColumns = get_option('mainwp_number_overview_columns', 2);
611 $contexts = array('left', 'right');
612 if ( $overviewColumns == 3){
613 $contexts[] = 'middle';
614 }
615
616 if ( $context == null || !in_array($context, $contexts) ) {
617 $context = 'right';
618 }
619
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 }
628 }
629 }
630
631
632 $hide_widgets = get_user_option('mainwp_settings_hide_widgets');
633 if (!is_array($hide_widgets))
634 $hide_widgets = array();
635
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;
642
643 // to avoid hidden widgets
644 if ( in_array( $box['id'], $hide_widgets ) ) {
645 continue;
646 }
647
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";
651
652 call_user_func($box['callback'], $object, $box);
653
654 echo "</div>\n";
655 echo "</div>\n";
656 }
657 }
658 }
659 }
660 }
661
662 static public function get_empty_bulk_actions() {
663 ob_start();
664 ?>
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;
674 }
675
676 public static function render_modal_install_plugin_theme( $what = 'plugin') {
677 ?>
678 <div id="plugintheme-installation-progress-modal" class="ui modal">
679 <div class="header"><?php
680 if ( $what == 'plugin' ) {
681 esc_html_e( 'Plugin Installation', 'mainwp' );
682 } else if ( $what == 'theme' ) {
683 esc_html_e( 'Theme Installation', 'mainwp' );
684 }
685 ?>
686 </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>
690 </div>
691 </div>
692 <?php
693 }
694
695 public static function render_show_all_updates_button() {
696 ?>
697 <a href="javascript:void(0)" class="ui mini button trigger-all-accordion"><?php _e('Show All Updates', 'mainwp'); ?></a>
698 <?php
699 }
700
701 public static function render_sorting_icons() {
702 ?>
703 <i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon">
704 <?php
705 }
706
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' ); ?>"/>
730 <input type="hidden" id="mainwp-notes-websiteid" value=""/>
731 <input type="hidden" id="mainwp-notes-slug" value=""/>
732 <input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/>
733 </div>
734 </div>
735 </div>
736 </div>
737
738 <?php
739 }
740
741 public static function usersnap_integration() {
742
743 $showtime = get_option( 'mainwp_show_usersnap', false );
744
745 if ( ! $showtime ) {
746 return false;
747 }
748
749 if ( time() > ( $showtime + 24 * 60 * 60 ) ) {
750 MainWP_Utility::update_option( 'mainwp_show_usersnap', 0 );
751 return false;
752 }
753
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);
763
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 }
773
774 public static function render_screen_options( $setting_page = true ) {
775
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 );
787
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();
796
797 ?>
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;
808 }
809
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>
849
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>
871
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>
877 </div>
878 <?php
879 }
880 }
881