| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP UI. |
| 4 |
* |
| 5 |
* @package MainWP/Dashboard |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace MainWP\Dashboard; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class MainWP_UI |
| 12 |
* |
| 13 |
* @package MainWP\Dashboard |
| 14 |
*/ |
| 15 |
class MainWP_UI { |
| 16 |
|
| 17 |
/** |
| 18 |
* Method get_class_name() |
| 19 |
* |
| 20 |
* Get Class Name. |
| 21 |
* |
| 22 |
* @return object |
| 23 |
*/ |
| 24 |
public static function get_class_name() { |
| 25 |
return __CLASS__; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Method select_sites_box() |
| 30 |
* |
| 31 |
* Select sites box. |
| 32 |
* |
| 33 |
* @param string $type Input type, radio. |
| 34 |
* @param bool $show_group Whether or not to show group, Default: true. |
| 35 |
* @param bool $show_select_all Whether to show select all. |
| 36 |
* @param string $class Default = ''. |
| 37 |
* @param string $style Default = ''. |
| 38 |
* @param array $selected_websites Selected Child Sites. |
| 39 |
* @param array $selected_groups Selected Groups. |
| 40 |
* @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not. |
| 41 |
* @param integer $postId Post Meta ID. |
| 42 |
*/ |
| 43 |
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 ) { |
| 44 |
|
| 45 |
if ( $postId ) { |
| 46 |
|
| 47 |
$sites_val = get_post_meta( $postId, '_selected_sites', true ); |
| 48 |
$selected_websites = MainWP_System_Utility::maybe_unserialyze( $sites_val ); |
| 49 |
|
| 50 |
if ( '' == $selected_websites ) { |
| 51 |
$selected_websites = array(); |
| 52 |
} |
| 53 |
|
| 54 |
$groups_val = get_post_meta( $postId, '_selected_groups', true ); |
| 55 |
$selected_groups = MainWP_System_Utility::maybe_unserialyze( $groups_val ); |
| 56 |
|
| 57 |
if ( '' == $selected_groups ) { |
| 58 |
$selected_groups = array(); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
if ( empty( $selected_websites ) && isset( $_GET['selected_sites'] ) && ! empty( $_GET['selected_sites'] ) ) { |
| 63 |
$selected_sites = explode( '-', sanitize_text_field( wp_unslash( $_GET['selected_sites'] ) ) ); // sanitize ok. |
| 64 |
$selected_sites = array_map( 'intval', $selected_sites ); |
| 65 |
$selected_websites = array_filter( $selected_sites ); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Action: mainwp_before_seclect_sites |
| 70 |
* |
| 71 |
* Fires before the Select Sites box. |
| 72 |
* |
| 73 |
* @since 4.1 |
| 74 |
*/ |
| 75 |
do_action( 'mainwp_before_seclect_sites' ); |
| 76 |
?> |
| 77 |
<div id="mainwp-select-sites" class="mainwp_select_sites_wrapper"> |
| 78 |
<?php self::select_sites_box_body( $selected_websites, $selected_groups, $type, $show_group, $show_select_all, false, $enableOfflineSites, $postId ); ?> |
| 79 |
</div> |
| 80 |
<?php |
| 81 |
/** |
| 82 |
* Action: mainwp_after_seclect_sites |
| 83 |
* |
| 84 |
* Fires after the Select Sites box. |
| 85 |
* |
| 86 |
* @since 4.1 |
| 87 |
*/ |
| 88 |
do_action( 'mainwp_after_seclect_sites' ); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Method select_sites_box_body() |
| 93 |
* |
| 94 |
* Select sites box Body. |
| 95 |
* |
| 96 |
* @param array $selected_websites Child Site that are selected. |
| 97 |
* @param array $selected_groups Group that are selected. |
| 98 |
* @param string $type Selector type. |
| 99 |
* @param bool $show_group Whether or not to show group, Default: true. |
| 100 |
* @param bool $show_select_all Whether or not to show select all, Default: true. |
| 101 |
* @param bool $updateQty Whether or not to update quantity, Default = false. |
| 102 |
* @param bool $enableOfflineSites Whether or not to enable offline sites, Default: true. |
| 103 |
* @param int $postId Post ID. |
| 104 |
*/ |
| 105 |
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 ) { |
| 106 |
|
| 107 |
if ( 'all' !== $selected_websites && ! is_array( $selected_websites ) ) { |
| 108 |
$selected_websites = array(); |
| 109 |
} |
| 110 |
|
| 111 |
if ( ! is_array( $selected_groups ) ) { |
| 112 |
$selected_groups = array(); |
| 113 |
} |
| 114 |
|
| 115 |
$websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); |
| 116 |
$groups = MainWP_DB_Common::instance()->get_not_empty_groups( null, $enableOfflineSites ); |
| 117 |
|
| 118 |
// support staging extension. |
| 119 |
$staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' ); |
| 120 |
|
| 121 |
$edit_site_id = false; |
| 122 |
if ( $postId ) { |
| 123 |
$edit_site_id = get_post_meta( $postId, '_mainwp_edit_post_site_id', true ); |
| 124 |
$edit_site_id = intval( $edit_site_id ); |
| 125 |
} |
| 126 |
|
| 127 |
if ( $edit_site_id ) { |
| 128 |
$show_group = false; |
| 129 |
} |
| 130 |
// to fix layout with multi sites selector. |
| 131 |
$tab_id = wp_rand(); |
| 132 |
|
| 133 |
self::render_select_sites_header( $tab_id, $staging_enabled, $selected_groups, $show_group, $show_select_all ); |
| 134 |
self::render_select_sites( $websites, $type, $tab_id, $selected_websites, $enableOfflineSites, $edit_site_id ); |
| 135 |
self::render_select_sites_staging( $staging_enabled, $tab_id, $selected_websites, $edit_site_id, $type ); |
| 136 |
if ( $show_group ) { |
| 137 |
self::render_select_sites_group( $groups, $tab_id, $selected_groups, $type ); |
| 138 |
} |
| 139 |
?> |
| 140 |
<script type="text/javascript"> |
| 141 |
jQuery( document ).ready( function () { |
| 142 |
jQuery('#mainwp-select-sites-header .ui.menu .item').tab( {'onVisible': function() { mainwp_sites_selection_onvisible_callback( this ); } } ); |
| 143 |
} ); |
| 144 |
</script> |
| 145 |
<?php |
| 146 |
} |
| 147 |
|
| 148 |
/** |
| 149 |
* Method render_select_sites_header() |
| 150 |
* |
| 151 |
* Render selected sites header. |
| 152 |
* |
| 153 |
* @param int $tab_id Datatab ID. |
| 154 |
* @param bool $staging_enabled True, if in the active plugins list. False, not in the list. |
| 155 |
* @param array $selected_groups Selected groups. |
| 156 |
* @param bool $show_group Whether or not to show group, Default: true. |
| 157 |
* @param bool $show_select_all Whether or not to show select all, Default: true. |
| 158 |
* |
| 159 |
* @todo Move to view folder. |
| 160 |
*/ |
| 161 |
public static function render_select_sites_header( $tab_id, $staging_enabled, $selected_groups, $show_group = true, $show_select_all = true ) { |
| 162 |
|
| 163 |
/** |
| 164 |
* Action: mainwp_before_select_sites_filters |
| 165 |
* |
| 166 |
* Fires before the Select Sites box filters. |
| 167 |
* |
| 168 |
* @since 4.1 |
| 169 |
*/ |
| 170 |
do_action( 'mainwp_before_select_sites_filters' ); |
| 171 |
?> |
| 172 |
<div id="mainwp-select-sites-filters"> |
| 173 |
<div class="ui grid"> |
| 174 |
<?php if ( $show_select_all ) { ?> |
| 175 |
<div class="four wide column"> |
| 176 |
<div class="ui basic icon mini buttons"> |
| 177 |
<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> |
| 178 |
<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> |
| 179 |
</div> |
| 180 |
</div> |
| 181 |
<?php } ?> |
| 182 |
<div class="<?php echo $show_select_all ? 'twelve' : 'sixteen'; ?> wide column"> |
| 183 |
<div class="ui mini fluid icon input"> |
| 184 |
<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;"' : '' ); ?> /> |
| 185 |
<i class="filter icon"></i> |
| 186 |
</div> |
| 187 |
</div> |
| 188 |
</div> |
| 189 |
</div> |
| 190 |
<?php |
| 191 |
/** |
| 192 |
* Action: mainwp_after_select_sites_filters |
| 193 |
* |
| 194 |
* Fires after the Select Sites box filters. |
| 195 |
* |
| 196 |
* @since 4.1 |
| 197 |
*/ |
| 198 |
do_action( 'mainwp_after_select_sites_filters' ); |
| 199 |
?> |
| 200 |
<input type="hidden" name="select_by" id="select_by" value="<?php echo esc_attr( 0 < count( $selected_groups ) ? 'group' : 'site' ); ?>"/> |
| 201 |
<input type="hidden" id="select_sites_tab" value="<?php echo esc_attr( 0 < count( $selected_groups ) ? 'group' : 'site' ); ?>"/> |
| 202 |
<div id="mainwp-select-sites-header"> |
| 203 |
<div class="ui pointing green secondary menu"> |
| 204 |
<a class="item active" data-tab="mainwp-select-sites-<?php echo $tab_id; ?>"><?php esc_html_e( 'Sites', 'mainwp' ); ?></a> |
| 205 |
<?php if ( $show_group ) : ?> |
| 206 |
<a class="item" data-tab="mainwp-select-groups-<?php echo $tab_id; ?>"><?php esc_html_e( 'Groups', 'mainwp' ); ?></a> |
| 207 |
<?php endif; ?> |
| 208 |
<?php if ( $staging_enabled ) : ?> |
| 209 |
<a class="item" data-tab="mainwp-select-staging-sites-<?php echo $tab_id; ?>"><?php esc_html_e( 'Staging', 'mainwp' ); ?></a> |
| 210 |
<?php endif; ?> |
| 211 |
</div> |
| 212 |
</div> |
| 213 |
<div class="ui divider hidden"></div> |
| 214 |
<?php |
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* Method render_select_sites() |
| 219 |
* |
| 220 |
* @param object $websites Object containing child sites info. |
| 221 |
* @param string $type Selector type. |
| 222 |
* @param mixed $tab_id Datatab ID. |
| 223 |
* @param mixed $selected_websites Selected Child Sites. |
| 224 |
* @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not. |
| 225 |
* @param mixed $edit_site_id Child Site ID to edit. |
| 226 |
* |
| 227 |
* @return void Render Select Sites html. |
| 228 |
*/ |
| 229 |
public static function render_select_sites( $websites, $type, $tab_id, $selected_websites, $enableOfflineSites, $edit_site_id ) { |
| 230 |
?> |
| 231 |
<div class="ui tab active" data-tab="mainwp-select-sites-<?php echo $tab_id; ?>" id="mainwp-select-sites" select-by="site"> |
| 232 |
<?php |
| 233 |
/** |
| 234 |
* Action: mainwp_before_select_sites_list |
| 235 |
* |
| 236 |
* Fires before the Select Sites list. |
| 237 |
* |
| 238 |
* @param object $websites Object containing child sites info. |
| 239 |
* |
| 240 |
* @since 4.1 |
| 241 |
*/ |
| 242 |
do_action( 'mainwp_before_select_sites_list', $websites ); |
| 243 |
?> |
| 244 |
<div id="mainwp-select-sites-body"> |
| 245 |
<div class="ui relaxed divided list" id="mainwp-select-sites-list"> |
| 246 |
<?php if ( ! $websites ) : ?> |
| 247 |
<h2 class="ui icon header"> |
| 248 |
<i class="folder open outline icon"></i> |
| 249 |
<div class="content"><?php esc_html_e( 'No Sites connected!', 'mainwp' ); ?></div> |
| 250 |
<div class="ui divider hidden"></div> |
| 251 |
<a href="admin.php?page=managesites&do=new" class="ui green button basic"><?php esc_html_e( 'Add Site', 'mainwp' ); ?></a> |
| 252 |
</h2> |
| 253 |
<?php |
| 254 |
else : |
| 255 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 256 |
$selected = false; |
| 257 |
if ( '' == $website->sync_errors || $enableOfflineSites ) { |
| 258 |
$selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) ); |
| 259 |
$disabled = ''; |
| 260 |
if ( $edit_site_id ) { |
| 261 |
if ( $website->id == $edit_site_id ) { |
| 262 |
$selected = true; |
| 263 |
} else { |
| 264 |
$disabled = 'disabled="disabled"'; |
| 265 |
} |
| 266 |
} |
| 267 |
?> |
| 268 |
<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' : '' ); ?>"> |
| 269 |
<input <?php echo $disabled; ?> type="<?php echo $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"' : '' ); ?> /> |
| 270 |
<label for="selected_sites_<?php echo intval( $website->id ); ?>"> |
| 271 |
<?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span> |
| 272 |
</label> |
| 273 |
</div> |
| 274 |
<?php |
| 275 |
} else { |
| 276 |
?> |
| 277 |
<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' : '' ); ?>"> |
| 278 |
<input type="<?php echo esc_html( $type ); ?>" disabled="disabled"/> |
| 279 |
<label for="selected_sites_<?php echo intval( $website->id ); ?>"> |
| 280 |
<?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span> |
| 281 |
</label> |
| 282 |
</div> |
| 283 |
<?php |
| 284 |
} |
| 285 |
} |
| 286 |
MainWP_DB::free_result( $websites ); |
| 287 |
endif; |
| 288 |
?> |
| 289 |
</div> |
| 290 |
</div> |
| 291 |
<?php |
| 292 |
/** |
| 293 |
* Action: mainwp_after_select_sites_list |
| 294 |
* |
| 295 |
* Fires after the Select Sites list. |
| 296 |
* |
| 297 |
* @param object $websites Object containing child sites info. |
| 298 |
* |
| 299 |
* @since 4.1 |
| 300 |
*/ |
| 301 |
do_action( 'mainwp_after_select_sites_list', $websites ); |
| 302 |
?> |
| 303 |
</div> |
| 304 |
<?php |
| 305 |
} |
| 306 |
|
| 307 |
/** |
| 308 |
* Method render_select_sites_staging() |
| 309 |
* |
| 310 |
* Render selected staging sites. |
| 311 |
* |
| 312 |
* @param bool $staging_enabled (bool) True, if in the active plugins list. False, not in the list. |
| 313 |
* @param mixed $tab_id Datatab ID. |
| 314 |
* @param mixed $selected_websites Selected Child Sites. |
| 315 |
* @param mixed $edit_site_id Child Site ID to edit. |
| 316 |
* @param string $type Selector type. |
| 317 |
* |
| 318 |
* @return void Render selected staging sites html. |
| 319 |
*/ |
| 320 |
public static function render_select_sites_staging( $staging_enabled, $tab_id, $selected_websites, $edit_site_id, $type = 'checkbox' ) { |
| 321 |
if ( $staging_enabled ) : |
| 322 |
$websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'favi_icon' ), $is_staging = 'yes' ) ); |
| 323 |
?> |
| 324 |
<div class="ui tab" data-tab="mainwp-select-staging-sites-<?php echo $tab_id; ?>" select-by="staging"> |
| 325 |
<div id="mainwp-select-sites-body"> |
| 326 |
<div class="ui relaxed divided list" id="mainwp-select-staging-sites-list"> |
| 327 |
<?php if ( ! $websites ) : ?> |
| 328 |
<h2 class="ui icon header"> |
| 329 |
<i class="folder open outline icon"></i> |
| 330 |
<div class="content"><?php esc_html_e( 'No staging websites have been found!', 'mainwp' ); ?></div> |
| 331 |
</h2> |
| 332 |
<?php |
| 333 |
else : |
| 334 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 335 |
$selected = false; |
| 336 |
if ( '' == $website->sync_errors || $enableOfflineSites ) { |
| 337 |
$selected = ( 'all' === $selected_websites || in_array( $website->id, $selected_websites ) ); |
| 338 |
$disabled = ''; |
| 339 |
if ( $edit_site_id ) { |
| 340 |
if ( $website->id != $edit_site_id ) { |
| 341 |
$disabled = 'disabled="disabled"'; |
| 342 |
} |
| 343 |
} |
| 344 |
?> |
| 345 |
<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' : '' ); ?>"> |
| 346 |
<input <?php echo $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"' : '' ); ?> /> |
| 347 |
<label for="selected_sites_<?php echo intval( $website->id ); ?>"> |
| 348 |
<?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span> |
| 349 |
</label> |
| 350 |
</div> |
| 351 |
<?php |
| 352 |
} else { |
| 353 |
?> |
| 354 |
<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' : '' ); ?>"> |
| 355 |
<input <?php echo $disabled; ?> type="<?php echo esc_html( $type ); ?>" disabled="disabled"/> |
| 356 |
<label for="selected_sites_<?php echo intval( $website->id ); ?>"> |
| 357 |
<?php echo stripslashes( $website->name ); ?> <span class="url"><?php echo esc_html( $website->url ); ?></span> |
| 358 |
</label> |
| 359 |
</div> |
| 360 |
<?php |
| 361 |
} |
| 362 |
} |
| 363 |
MainWP_DB::free_result( $websites ); |
| 364 |
endif; |
| 365 |
?> |
| 366 |
</div> |
| 367 |
</div> |
| 368 |
</div> |
| 369 |
<?php |
| 370 |
endif; |
| 371 |
} |
| 372 |
|
| 373 |
/** |
| 374 |
* Method render_select_sites_group() |
| 375 |
* |
| 376 |
* Render selected sites group. |
| 377 |
* |
| 378 |
* @param array $groups Array of groups. |
| 379 |
* @param mixed $tab_id Datatab ID. |
| 380 |
* @param mixed $selected_groups Selected groups. |
| 381 |
* @param string $type Selector type. |
| 382 |
* |
| 383 |
* @return void Render selected sites group html. |
| 384 |
*/ |
| 385 |
public static function render_select_sites_group( $groups, $tab_id, $selected_groups, $type = 'checkbox' ) { |
| 386 |
?> |
| 387 |
<div class="ui tab" data-tab="mainwp-select-groups-<?php echo $tab_id; ?>" id="mainwp-select-groups" select-by="group"> |
| 388 |
<?php |
| 389 |
/** |
| 390 |
* Action: mainwp_before_select_groups_list |
| 391 |
* |
| 392 |
* Fires before the Select Groups list. |
| 393 |
* |
| 394 |
* @param object $groups Object containing groups info. |
| 395 |
* |
| 396 |
* @since 4.1 |
| 397 |
*/ |
| 398 |
do_action( 'mainwp_before_select_groups_list', $groups ); |
| 399 |
?> |
| 400 |
<div id="mainwp-select-sites-body"> |
| 401 |
<div class="ui relaxed divided list" id="mainwp-select-groups-list"> |
| 402 |
<?php |
| 403 |
if ( 0 === count( $groups ) ) { |
| 404 |
?> |
| 405 |
<h2 class="ui icon header"> |
| 406 |
<i class="folder open outline icon"></i> |
| 407 |
<div class="content"><?php esc_html_e( 'No Groups created!', 'mainwp' ); ?></div> |
| 408 |
<div class="ui divider hidden"></div> |
| 409 |
<a href="admin.php?page=ManageGroups" class="ui green button basic"><?php esc_html_e( 'Create Groups', 'mainwp' ); ?></a> |
| 410 |
</h2> |
| 411 |
<?php |
| 412 |
} |
| 413 |
foreach ( $groups as $group ) { |
| 414 |
$selected = in_array( $group->id, $selected_groups ); |
| 415 |
?> |
| 416 |
<div class="mainwp_selected_groups_item ui item <?php echo esc_html( $type ); ?> <?php echo ( $selected ? 'selected_groups_item_checked' : '' ); ?>"> |
| 417 |
<input type="<?php echo esc_html( $type ); ?>" name="<?php echo ( 'radio' === $type ? 'selected_groups' : 'selected_groups[]' ); ?>" value="<?php echo $group->id; ?>" id="selected_groups_<?php echo $group->id; ?>" <?php echo ( $selected ? 'checked="true"' : '' ); ?> /> |
| 418 |
<label for="selected_groups_<?php echo $group->id; ?>"> |
| 419 |
<?php echo stripslashes( $group->name ); ?> |
| 420 |
</label> |
| 421 |
</div> |
| 422 |
<?php |
| 423 |
} |
| 424 |
?> |
| 425 |
</div> |
| 426 |
</div> |
| 427 |
<?php |
| 428 |
/** |
| 429 |
* Action: mainwp_after_select_groups_list |
| 430 |
* |
| 431 |
* Fires after the Select Groups list. |
| 432 |
* |
| 433 |
* @param object $groups Object containing groups info. |
| 434 |
* |
| 435 |
* @since 4.1 |
| 436 |
*/ |
| 437 |
do_action( 'mainwp_after_select_groups_list', $groups ); |
| 438 |
?> |
| 439 |
</div> |
| 440 |
<?php |
| 441 |
} |
| 442 |
|
| 443 |
/** |
| 444 |
* Method render_top_header() |
| 445 |
* |
| 446 |
* Render top header. |
| 447 |
* |
| 448 |
* @param array $params Page parameters. |
| 449 |
*/ |
| 450 |
public static function render_top_header( $params = array() ) { |
| 451 |
|
| 452 |
$title = isset( $params['title'] ) ? $params['title'] : ''; |
| 453 |
|
| 454 |
/** |
| 455 |
* Filter: mainwp_header_title |
| 456 |
* |
| 457 |
* Filter the MainWP page title in the header element. |
| 458 |
* |
| 459 |
* @since 4.0 |
| 460 |
*/ |
| 461 |
$title = apply_filters( 'mainwp_header_title', $title ); |
| 462 |
|
| 463 |
$show_menu = true; |
| 464 |
$show_new_items = true; |
| 465 |
|
| 466 |
if ( isset( $params['show_menu'] ) ) { |
| 467 |
$show_menu = $params['show_menu']; |
| 468 |
} |
| 469 |
|
| 470 |
/** |
| 471 |
* Filter: mainwp_header_left |
| 472 |
* |
| 473 |
* Filter the MainWP header element left side content. |
| 474 |
* |
| 475 |
* @since 4.0 |
| 476 |
*/ |
| 477 |
$left = apply_filters( 'mainwp_header_left', $title ); |
| 478 |
|
| 479 |
$right = self::render_header_actions(); |
| 480 |
|
| 481 |
/** |
| 482 |
* Filter: mainwp_header_right |
| 483 |
* |
| 484 |
* Filter the MainWP header element right side content. |
| 485 |
* |
| 486 |
* @since 4.0 |
| 487 |
*/ |
| 488 |
$right = apply_filters( 'mainwp_header_right', $right ); |
| 489 |
|
| 490 |
if ( $show_menu ) { |
| 491 |
MainWP_Menu::render_left_menu(); |
| 492 |
} |
| 493 |
|
| 494 |
$sidebarPosition = get_user_option( 'mainwp_sidebarPosition' ); |
| 495 |
if ( false === $sidebarPosition ) { |
| 496 |
$sidebarPosition = 1; |
| 497 |
} |
| 498 |
|
| 499 |
$websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); |
| 500 |
|
| 501 |
?> |
| 502 |
<div class="ui segment right sites sidebar" style="padding:0px" id="mainwp-sites-menu-sidebar"> |
| 503 |
<div class="ui segment" style="margin-bottom:0px"> |
| 504 |
<div class="ui header"><?php esc_html_e( 'Quick Site Shortcuts', 'mainwp' ); ?></div> |
| 505 |
</div> |
| 506 |
<div class="ui fitted divider"></div> |
| 507 |
<div class="ui segment" style="margin-bottom:0px"> |
| 508 |
<div class="ui mini fluid icon input" <?php echo $websites ? '' : 'style="display: none;"'; ?> > |
| 509 |
<input type="text" id="mainwp-sites-menu-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>" /> |
| 510 |
<i class="filter icon"></i> |
| 511 |
</div> |
| 512 |
</div> |
| 513 |
<div class="ui fluid vertical accordion menu" id="mainwp-sites-sidebar-menu" style="margin-top:0px;border-radius:0px;box-shadow:none;"> |
| 514 |
<?php foreach ( $websites as $website ) : ?> |
| 515 |
<div class="item mainwp-site-menu-item"> |
| 516 |
<a class="title"> |
| 517 |
<i class="dropdown icon"></i> |
| 518 |
<label><?php echo esc_html( $website['name'] ); ?></label> |
| 519 |
</a> |
| 520 |
<div class="content"> |
| 521 |
<div class="ui link tiny list"> |
| 522 |
<a class="item" href="<?php echo 'admin.php?page=managesites&dashboard=' . $website['id']; ?>"> |
| 523 |
<i class="grid layout icon"></i> |
| 524 |
<?php esc_html_e( 'Overview', 'mainwp' ); ?> |
| 525 |
</a> |
| 526 |
<a class="item" href="<?php echo 'admin.php?page=managesites&updateid=' . $website['id']; ?>"> |
| 527 |
<i class="sync alternate icon"></i> |
| 528 |
<?php esc_html_e( 'Updates', 'mainwp' ); ?> |
| 529 |
</a> |
| 530 |
<a class="item" href="<?php echo 'admin.php?page=managesites&id=' . $website['id']; ?>"> |
| 531 |
<i class="edit icon"></i> |
| 532 |
<?php esc_html_e( 'Edit Site', 'mainwp' ); ?> |
| 533 |
</a> |
| 534 |
<a class="item" href="<?php echo 'admin.php?page=managesites&scanid=' . $website['id']; ?>"> |
| 535 |
<i class="shield icon"></i> |
| 536 |
<?php esc_html_e( 'Security Scan', 'mainwp' ); ?> |
| 537 |
</a> |
| 538 |
<a class="item" href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $website['id']; ?>"> |
| 539 |
<i class="sign-in icon"></i> |
| 540 |
<?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?> |
| 541 |
</a> |
| 542 |
<a class="item" href="<?php echo esc_url( $website['url'] ); ?>"> |
| 543 |
<i class="globe icon"></i> |
| 544 |
<?php esc_html_e( 'Visit Site', 'mainwp' ); ?> |
| 545 |
</a> |
| 546 |
<?php |
| 547 |
/** |
| 548 |
* Action: mainwp_quick_sites_shortcut |
| 549 |
* |
| 550 |
* Adds a new shortcut item in the Quick Sites Shortcuts sidebar menu. |
| 551 |
* |
| 552 |
* @param array $website Array containing the child site data. |
| 553 |
* |
| 554 |
* Suggested HTML markup: |
| 555 |
* |
| 556 |
* <a class="item" href="your custom URL"> |
| 557 |
* <i class="your custom icon"></i> |
| 558 |
* Your custom label text |
| 559 |
* </a> |
| 560 |
* |
| 561 |
* @since 4.1 |
| 562 |
*/ |
| 563 |
do_action( 'mainwp_quick_sites_shortcut', $website ); |
| 564 |
?> |
| 565 |
</div> |
| 566 |
</div> |
| 567 |
</div> |
| 568 |
<?php endforeach; ?> |
| 569 |
</div> |
| 570 |
</div> |
| 571 |
<div class="ui segment right wide help sidebar" id="mainwp-documentation-sidebar"> |
| 572 |
<div class="ui header"><?php esc_html_e( 'MainWP Documenation', 'mainwp' ); ?></div> |
| 573 |
<div class="ui hidden divider"></div> |
| 574 |
<?php |
| 575 |
/** |
| 576 |
* Action: mainwp_help_sidebar_content |
| 577 |
* |
| 578 |
* Fires Help sidebar content |
| 579 |
* |
| 580 |
* @since 4.0 |
| 581 |
*/ |
| 582 |
do_action( 'mainwp_help_sidebar_content' ); |
| 583 |
?> |
| 584 |
<div class="ui hidden divider"></div> |
| 585 |
<a href="https://kb.mainwp.com/" class="ui big green fluid button"><?php esc_html_e( 'Help Documentation', 'mainwp' ); ?></a> |
| 586 |
<div class="ui hidden divider"></div> |
| 587 |
<div id="mainwp-sticky-help-button" class="" style="position: absolute; bottom: 1em; left: 1em; right: 1em;"> |
| 588 |
<a href="https://mainwp.com/my-account/get-support/" target="_blank" class="ui fluid button"><?php esc_html_e( 'Still Need Help?', 'mainwp' ); ?></a> |
| 589 |
</div> |
| 590 |
</div> |
| 591 |
<?php |
| 592 |
/** |
| 593 |
* Action: mainwp_before_mainwp_content_wrap |
| 594 |
* |
| 595 |
* Fires before the #mainwp-content-wrap element. |
| 596 |
* |
| 597 |
* @param array $websites Array containing the child site data. |
| 598 |
* |
| 599 |
* @since 4.1 |
| 600 |
*/ |
| 601 |
do_action( 'mainwp_before_mainwp_content_wrap', $websites ); |
| 602 |
?> |
| 603 |
<div class="mainwp-content-wrap <?php echo empty( $sidebarPosition ) ? 'mainwp-sidebar-left' : ''; ?>"> |
| 604 |
<?php |
| 605 |
/** |
| 606 |
* Action: mainwp_before_header |
| 607 |
* |
| 608 |
* Fires before the MainWP header element. |
| 609 |
* |
| 610 |
* @param array $websites Array containing the child site data. |
| 611 |
* |
| 612 |
* @since 4.0 |
| 613 |
*/ |
| 614 |
do_action( 'mainwp_before_header', $websites ); |
| 615 |
?> |
| 616 |
<div id="mainwp-top-header" class="ui sticky"> |
| 617 |
<div class="ui stackable grid"> |
| 618 |
<div class="two column row"> |
| 619 |
<div class="left floated column"><h4 class="mainwp-page-title"><?php echo $left; ?></h4></div> |
| 620 |
<div class="right floated column right aligned"><?php echo $right; ?></div> |
| 621 |
</div> |
| 622 |
</div> |
| 623 |
</div> |
| 624 |
<script type="text/javascript"> |
| 625 |
jQuery( document ).ready( function () { |
| 626 |
jQuery( '.ui.sticky' ).sticky(); |
| 627 |
jQuery( '#mainwp-help-sidebar' ).on( 'click', function() { |
| 628 |
jQuery( '.ui.help.sidebar' ).sidebar( { |
| 629 |
transition: 'overlay' |
| 630 |
} ); |
| 631 |
jQuery( '.ui.help.sidebar' ).sidebar( 'toggle' ); |
| 632 |
return false; |
| 633 |
} ); |
| 634 |
jQuery( '#mainwp-sites-sidebar' ).on( 'click', function() { |
| 635 |
jQuery( '.ui.sites.sidebar' ).sidebar( { |
| 636 |
transition: 'overlay' |
| 637 |
} ); |
| 638 |
jQuery( '.ui.sites.sidebar' ).sidebar( 'toggle' ); |
| 639 |
return false; |
| 640 |
} ); |
| 641 |
jQuery( '#mainwp-sites-sidebar-menu' ).accordion(); |
| 642 |
} ); |
| 643 |
</script> |
| 644 |
<?php |
| 645 |
/** |
| 646 |
* Action: mainwp_after_header |
| 647 |
* |
| 648 |
* Fires after the MainWP header element. |
| 649 |
* |
| 650 |
* @param array $websites Array containing the child site data. |
| 651 |
* |
| 652 |
* @since 4.0 |
| 653 |
*/ |
| 654 |
do_action( 'mainwp_after_header', $websites ); |
| 655 |
?> |
| 656 |
<?php |
| 657 |
} |
| 658 |
|
| 659 |
/** |
| 660 |
* Method render_second_top_header() |
| 661 |
* |
| 662 |
* Render second top header. |
| 663 |
* |
| 664 |
* @param string $which Current page. |
| 665 |
* |
| 666 |
* @return void Render second top header html. |
| 667 |
*/ |
| 668 |
public static function render_second_top_header( $which = '' ) { |
| 669 |
|
| 670 |
/** |
| 671 |
* Action: mainwp_before_subheader |
| 672 |
* |
| 673 |
* Fires before the MainWP sub-header element. |
| 674 |
* |
| 675 |
* @since 4.0 |
| 676 |
*/ |
| 677 |
do_action( 'mainwp_before_subheader' ); |
| 678 |
if ( has_action( 'mainwp_subheader_actions' ) || 'overview' === $which || 'managesites' === $which || 'monitoringsites' === $which ) { |
| 679 |
?> |
| 680 |
<div class="mainwp-sub-header"> |
| 681 |
<?php if ( 'overview' === $which ) : ?> |
| 682 |
<div class="ui stackable grid"> |
| 683 |
<div class="column full"> |
| 684 |
<?php self::gen_groups_sites_selection(); ?> |
| 685 |
</div> |
| 686 |
</div> |
| 687 |
<?php endif; ?> |
| 688 |
<?php if ( 'managesites' === $which || 'monitoringsites' === $which ) : ?> |
| 689 |
<?php |
| 690 |
/** |
| 691 |
* Action: mainwp_managesites_tabletop |
| 692 |
* |
| 693 |
* Fires at the table top on the Manage Sites and Monitoring page. |
| 694 |
* |
| 695 |
* @since 4.0 |
| 696 |
*/ |
| 697 |
do_action( 'mainwp_managesites_tabletop' ); |
| 698 |
?> |
| 699 |
<?php else : ?> |
| 700 |
<?php |
| 701 |
/** |
| 702 |
* Action: mainwp_subheader_actions |
| 703 |
* |
| 704 |
* Fires at the subheader element to hook available actions. |
| 705 |
* |
| 706 |
* @since 4.0 |
| 707 |
*/ |
| 708 |
do_action( 'mainwp_subheader_actions' ); |
| 709 |
?> |
| 710 |
<?php endif; ?> |
| 711 |
</div> |
| 712 |
<?php |
| 713 |
} |
| 714 |
/** |
| 715 |
* Action: mainwp_after_subheader |
| 716 |
* |
| 717 |
* Fires after the MainWP sub-header element. |
| 718 |
* |
| 719 |
* @since 4.0 |
| 720 |
*/ |
| 721 |
do_action( 'mainwp_after_subheader' ); |
| 722 |
} |
| 723 |
|
| 724 |
/** |
| 725 |
* Method gen_groups_sites_selection() |
| 726 |
* |
| 727 |
* Generate group sites selection box. |
| 728 |
* |
| 729 |
* @return void Render group sites selection box. |
| 730 |
*/ |
| 731 |
public static function gen_groups_sites_selection() { |
| 732 |
$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' ) ); |
| 733 |
$websites = MainWP_DB::instance()->query( $sql ); |
| 734 |
$g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; |
| 735 |
$s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; |
| 736 |
?> |
| 737 |
<div class="column full wide"> |
| 738 |
<select id="mainwp_top_quick_jump_group" class="ui dropdown"> |
| 739 |
<option value="" class="item"><?php esc_html_e( 'All Groups', 'mainwp' ); ?></option> |
| 740 |
<option <?php echo ( -1 === $g ) ? 'selected' : ''; ?> value="-1" class="item"><?php esc_html_e( 'All Groups', 'mainwp' ); ?></option> |
| 741 |
<?php |
| 742 |
$groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites(); |
| 743 |
foreach ( $groups as $group ) { |
| 744 |
?> |
| 745 |
<option class="item" <?php echo ( $g == $group->id ) ? 'selected' : ''; ?> value="<?php echo $group->id; ?>"><?php echo stripslashes( $group->name ); ?></option> |
| 746 |
<?php |
| 747 |
} |
| 748 |
?> |
| 749 |
</select> |
| 750 |
<select class="ui dropdown" id="mainwp_top_quick_jump_page"> |
| 751 |
<option value="" class="item"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option> |
| 752 |
<option <?php echo ( -1 === $s ) ? 'selected' : ''; ?> value="-1" class="item" ><?php esc_html_e( 'All Sites', 'mainwp' ); ?></option> |
| 753 |
<?php |
| 754 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 755 |
?> |
| 756 |
<option value="<?php echo intval( $website->id ); ?>" <?php echo ( $s == $website->id ) ? 'selected' : ''; ?> class="item" ><?php echo stripslashes( $website->name ); ?></option> |
| 757 |
<?php |
| 758 |
} |
| 759 |
?> |
| 760 |
</select> |
| 761 |
</div> |
| 762 |
<script type="text/javascript"> |
| 763 |
jQuery( document ).on( 'change', '#mainwp_top_quick_jump_group', function () { |
| 764 |
var jumpid = jQuery( this ).val(); |
| 765 |
window.location = 'admin.php?page=managesites&g=' + jumpid; |
| 766 |
} ); |
| 767 |
jQuery( document ).on( 'change', '#mainwp_top_quick_jump_page', function () { |
| 768 |
var jumpid = jQuery( this ).val(); |
| 769 |
if ( jumpid == -1 ) |
| 770 |
window.location = 'admin.php?page=managesites&s=' + jumpid; |
| 771 |
else |
| 772 |
window.location = 'admin.php?page=managesites&dashboard=' + jumpid; |
| 773 |
} ); |
| 774 |
</script> |
| 775 |
<?php |
| 776 |
MainWP_DB::free_result( $websites ); |
| 777 |
} |
| 778 |
|
| 779 |
/** |
| 780 |
* Method render_header_actions() |
| 781 |
* |
| 782 |
* Render header action buttons, |
| 783 |
* (Sync|Add|Options|Community|User|Updates). |
| 784 |
* |
| 785 |
* @return mixed $output Render header action buttons html. |
| 786 |
*/ |
| 787 |
public static function render_header_actions() { |
| 788 |
$sites_count = MainWP_DB::instance()->get_websites_count(); |
| 789 |
$website_id = ''; |
| 790 |
ob_start(); |
| 791 |
?> |
| 792 |
<button class="ui button green <?php echo ( 0 < $sites_count ? '' : 'disabled' ); ?>" id="mainwp-sync-sites" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Get fresh data from your child sites.', 'mainwp' ); ?>"> |
| 793 |
<?php |
| 794 |
/** |
| 795 |
* Filter: mainwp_main_sync_button_text |
| 796 |
* |
| 797 |
* Filters the Sync Dashboard with Child Sites button text. |
| 798 |
* |
| 799 |
* @since 4.1 |
| 800 |
*/ |
| 801 |
echo esc_html( apply_filters( 'mainwp_main_sync_button_text', __( 'Sync Dashboard with Child Sites', 'mainwp' ) ) ); |
| 802 |
?> |
| 803 |
</button> |
| 804 |
<div class="ui <?php echo ( 0 == $sites_count ? 'green' : '' ); ?> buttons" id="mainwp-add-new-buttons"> |
| 805 |
<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( 'Add New', 'mainwp' ); ?></a> |
| 806 |
<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' ); ?>"> |
| 807 |
<i class="dropdown icon"></i> |
| 808 |
<div class="menu"> |
| 809 |
<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_attr( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>"><?php esc_html_e( 'Website', 'mainwp' ); ?></a> |
| 810 |
<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> |
| 811 |
<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> |
| 812 |
<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> |
| 813 |
<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> |
| 814 |
<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> |
| 815 |
<?php |
| 816 |
/** |
| 817 |
* Action: mainwp_add_new_menu_option |
| 818 |
* |
| 819 |
* Fires at bottom of the Add New menu options list. |
| 820 |
* |
| 821 |
* Suggested HTML markup: |
| 822 |
* <a class="item" href="your custom URL">Your custom label</a> |
| 823 |
* |
| 824 |
* @since 4.1 |
| 825 |
*/ |
| 826 |
do_action( 'mainwp_add_new_menu_option' ); |
| 827 |
?> |
| 828 |
</div> |
| 829 |
</div> |
| 830 |
</div> |
| 831 |
<?php if ( isset( $_GET['dashboard'] ) ) : ?> |
| 832 |
<?php $website_id = intval( $_GET['dashboard'] ); ?> |
| 833 |
<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> |
| 834 |
<?php endif; ?> |
| 835 |
<?php if ( ( isset( $_GET['page'] ) && 'mainwp_tab' === $_GET['page'] ) || isset( $_GET['dashboard'] ) ) : ?> |
| 836 |
<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' ); ?>"> |
| 837 |
<i class="cog icon"></i> |
| 838 |
</a> |
| 839 |
<?php endif; ?> |
| 840 |
<?php |
| 841 |
/** |
| 842 |
* Filter: mainwp_header_actions_right |
| 843 |
* |
| 844 |
* Filters the MainWP header element actions. |
| 845 |
* |
| 846 |
* @since 4.0 |
| 847 |
*/ |
| 848 |
$actions = apply_filters( 'mainwp_header_actions_right', '' ); |
| 849 |
if ( ! empty( $actions ) ) { |
| 850 |
echo $actions; |
| 851 |
} |
| 852 |
?> |
| 853 |
<a class="ui button basic icon" id="mainwp-sites-sidebar" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Quick sites shortcuts', 'mainwp' ); ?>"> |
| 854 |
<i class="globe icon"></i> |
| 855 |
</a> |
| 856 |
|
| 857 |
<a class="ui button basic icon" id="mainwp-help-sidebar" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="<?php esc_attr_e( 'Need help?', 'mainwp' ); ?>"> |
| 858 |
<i class="life ring icon"></i> |
| 859 |
</a> |
| 860 |
|
| 861 |
<a class="ui button basic icon" data-inverted="" data-position="bottom right" href="https://meta.mainwp.com/" target="_blank" data-tooltip="<?php esc_attr_e( 'MainWP Community', 'mainwp' ); ?>"> |
| 862 |
<i class="discourse icon"></i> |
| 863 |
</a> |
| 864 |
|
| 865 |
<a class="ui button basic icon" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Go to your MainWP Account at MainWP.com', 'mainwp' ); ?>" target="_blank" href="https://mainwp.com/my-account/"> |
| 866 |
<i class="user icon"></i> |
| 867 |
</a> |
| 868 |
|
| 869 |
<?php |
| 870 |
$all_updates = wp_get_update_data(); |
| 871 |
if ( is_array( $all_updates ) && isset( $all_updates['counts']['total'] ) && 0 < $all_updates['counts']['total'] ) { |
| 872 |
?> |
| 873 |
<a class="ui red icon button" data-inverted="" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Your MainWP Dashboard sites needs your attention. Please check the available updates', 'mainwp' ); ?>" href="update-core.php"> |
| 874 |
<i class="exclamation triangle icon"></i> |
| 875 |
</a> |
| 876 |
<?php |
| 877 |
} |
| 878 |
?> |
| 879 |
<?php if ( get_option( 'mainwp_show_usersnap', false ) ) : ?> |
| 880 |
<a class="ui button black icon" id="usersnap-bug-report-button" data-position="bottom right" data-inverted="" data-tooltip="<?php esc_attr_e( 'Click here (or use Ctrl + U keyboard shortcut) to open the Bug reporting mode.', 'mainwp' ); ?>" target="_blank" href="#"> |
| 881 |
<i class="bug icon"></i> |
| 882 |
</a> |
| 883 |
<?php endif; ?> |
| 884 |
<?php |
| 885 |
$output = ob_get_clean(); |
| 886 |
return $output; |
| 887 |
} |
| 888 |
|
| 889 |
/** |
| 890 |
* Method render_page_navigation() |
| 891 |
* |
| 892 |
* Render page navigation. |
| 893 |
* |
| 894 |
* @param array $subitems [access, active, style]. |
| 895 |
* @param null $name_caller Menu Name. |
| 896 |
*/ |
| 897 |
public static function render_page_navigation( $subitems = array(), $name_caller = null ) { |
| 898 |
|
| 899 |
/** |
| 900 |
* Filter: mainwp_page_navigation |
| 901 |
* |
| 902 |
* Filters MainWP page navigation menu items. |
| 903 |
* |
| 904 |
* @since 4.0 |
| 905 |
*/ |
| 906 |
$subitems = apply_filters( 'mainwp_page_navigation', $subitems, $name_caller ); |
| 907 |
?> |
| 908 |
<div id="mainwp-page-navigation-wrapper"> |
| 909 |
<div class="ui secondary green pointing menu stackable mainwp-page-navigation"> |
| 910 |
<?php |
| 911 |
|
| 912 |
if ( is_array( $subitems ) ) { |
| 913 |
foreach ( $subitems as $item ) { |
| 914 |
|
| 915 |
if ( isset( $item['access'] ) && ! $item['access'] ) { |
| 916 |
continue; |
| 917 |
} |
| 918 |
|
| 919 |
$active = ''; |
| 920 |
if ( isset( $item['active'] ) && $item['active'] ) { |
| 921 |
$active = 'active'; |
| 922 |
} |
| 923 |
$style = ''; |
| 924 |
if ( isset( $item['style'] ) ) { |
| 925 |
$style = 'style="' . $item['style'] . '"'; |
| 926 |
} |
| 927 |
|
| 928 |
?> |
| 929 |
<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> |
| 930 |
<?php |
| 931 |
} |
| 932 |
} |
| 933 |
?> |
| 934 |
</div> |
| 935 |
</div> |
| 936 |
<?php |
| 937 |
} |
| 938 |
|
| 939 |
/** |
| 940 |
* Method render_header() |
| 941 |
* |
| 942 |
* Render page title. |
| 943 |
* |
| 944 |
* @param string $title Page title. |
| 945 |
* |
| 946 |
* @return void Render page title and hidden divider html. |
| 947 |
*/ |
| 948 |
public static function render_header( $title = '' ) { |
| 949 |
self::render_top_header( array( 'title' => $title ) ); |
| 950 |
echo '<div class="ui hidden clearing fitted divider"></div>'; |
| 951 |
echo '<div class="wrap">'; |
| 952 |
} |
| 953 |
|
| 954 |
/** |
| 955 |
* Method render_footer() |
| 956 |
* |
| 957 |
* Render page footer. |
| 958 |
* |
| 959 |
* @return void Render closing tags for page container. |
| 960 |
*/ |
| 961 |
public static function render_footer() { |
| 962 |
echo '</div>'; |
| 963 |
echo '</div>'; |
| 964 |
} |
| 965 |
|
| 966 |
/** |
| 967 |
* Method add_widget_box() |
| 968 |
* |
| 969 |
* Customize WordPress add_meta_box() function. |
| 970 |
* |
| 971 |
* @param mixed $id Widget ID parameter. |
| 972 |
* @param mixed $callback Callback function. |
| 973 |
* @param null $screen Current page. |
| 974 |
* @param string|null $context right|null. If 3 columns then = 'middle'. |
| 975 |
* @param null $title Widget title. |
| 976 |
* @param string $priority high|core|default|low, Default: default. |
| 977 |
* |
| 978 |
* @return void Sets Global $mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ]. |
| 979 |
*/ |
| 980 |
public static function add_widget_box( $id, $callback, $screen = null, $context = null, $title = null, $priority = 'default' ) { // phpcs:ignore -- complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 981 |
/** |
| 982 |
* MainWP widget boxes array. |
| 983 |
* |
| 984 |
* @global object |
| 985 |
*/ |
| 986 |
global $mainwp_widget_boxes; |
| 987 |
|
| 988 |
$page = MainWP_System_Utility::get_page_id( $screen ); |
| 989 |
|
| 990 |
if ( empty( $page ) ) { |
| 991 |
return; |
| 992 |
} |
| 993 |
|
| 994 |
$overviewColumns = get_option( 'mainwp_number_overview_columns', 2 ); |
| 995 |
$contexts = array( 'left', 'right' ); |
| 996 |
if ( 3 == $overviewColumns ) { |
| 997 |
$contexts[] = 'middle'; |
| 998 |
} |
| 999 |
|
| 1000 |
if ( null === $context || ! in_array( $context, $contexts ) ) { |
| 1001 |
$context = 'right'; |
| 1002 |
} |
| 1003 |
|
| 1004 |
if ( ! isset( $mainwp_widget_boxes ) ) { |
| 1005 |
$mainwp_widget_boxes = array(); |
| 1006 |
} |
| 1007 |
if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) { |
| 1008 |
$mainwp_widget_boxes[ $page ] = array(); |
| 1009 |
} |
| 1010 |
if ( ! isset( $mainwp_widget_boxes[ $page ][ $context ] ) ) { |
| 1011 |
$mainwp_widget_boxes[ $page ][ $context ] = array(); |
| 1012 |
} |
| 1013 |
|
| 1014 |
foreach ( array_keys( $mainwp_widget_boxes[ $page ] ) as $a_context ) { |
| 1015 |
foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) { |
| 1016 |
if ( ! isset( $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) { |
| 1017 |
continue; |
| 1018 |
} |
| 1019 |
|
| 1020 |
// If box previously deleted, don't add. |
| 1021 |
if ( false == $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) { |
| 1022 |
return; |
| 1023 |
} |
| 1024 |
|
| 1025 |
// If no priority given and id already present, use existing priority. |
| 1026 |
if ( empty( $priority ) ) { |
| 1027 |
$priority = $a_priority; |
| 1028 |
|
| 1029 |
/* |
| 1030 |
* Else, if we're adding to the sorted priority, we don't know the title |
| 1031 |
* or callback. Grab them from the previously added context/priority. |
| 1032 |
*/ |
| 1033 |
} elseif ( 'sorted' == $priority ) { |
| 1034 |
$title = $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title']; |
| 1035 |
$callback = $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback']; |
| 1036 |
} |
| 1037 |
|
| 1038 |
// An id can be in only one context. |
| 1039 |
if ( $priority != $a_priority || $context != $a_context ) { |
| 1040 |
unset( $mainwp_widget_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ); |
| 1041 |
} |
| 1042 |
} |
| 1043 |
} |
| 1044 |
|
| 1045 |
if ( ! isset( $mainwp_widget_boxes[ $page ][ $context ] ) ) { |
| 1046 |
$mainwp_widget_boxes[ $page ][ $context ] = array(); |
| 1047 |
} |
| 1048 |
|
| 1049 |
if ( empty( $priority ) ) { |
| 1050 |
$priority = 'default'; |
| 1051 |
} |
| 1052 |
|
| 1053 |
if ( empty( $title ) ) { |
| 1054 |
$title = 'No Title'; |
| 1055 |
} |
| 1056 |
$mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ] = array( |
| 1057 |
'id' => $id, |
| 1058 |
'title' => $title, |
| 1059 |
'callback' => $callback, |
| 1060 |
); |
| 1061 |
} |
| 1062 |
|
| 1063 |
/** |
| 1064 |
* Method do_widget_boxes() |
| 1065 |
* |
| 1066 |
* Customize WordPress do_meta_boxes() function. |
| 1067 |
* |
| 1068 |
* @param mixed $screen Current page. |
| 1069 |
* @param string|null $context right|null. If 3 columns then = 'middle'. |
| 1070 |
* @param string $object Empty string. |
| 1071 |
* |
| 1072 |
* @return void Renders widget container box. |
| 1073 |
*/ |
| 1074 |
public static function do_widget_boxes( $screen, $context = null, $object = '' ) { |
| 1075 |
global $mainwp_widget_boxes; |
| 1076 |
static $already_sorted = false; |
| 1077 |
|
| 1078 |
$page = MainWP_System_Utility::get_page_id( $screen ); |
| 1079 |
|
| 1080 |
if ( empty( $page ) ) { |
| 1081 |
return; |
| 1082 |
} |
| 1083 |
|
| 1084 |
$overviewColumns = get_option( 'mainwp_number_overview_columns', 2 ); |
| 1085 |
$contexts = array( 'left', 'right' ); |
| 1086 |
if ( 3 == $overviewColumns ) { |
| 1087 |
$contexts[] = 'middle'; |
| 1088 |
} |
| 1089 |
|
| 1090 |
if ( null == $context || ! in_array( $context, $contexts ) ) { |
| 1091 |
$context = 'right'; |
| 1092 |
} |
| 1093 |
$sorted = get_user_option( 'mainwp_widgets_sorted_' . $page ); |
| 1094 |
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose. |
| 1095 |
if ( ! $already_sorted && $sorted ) { |
| 1096 |
foreach ( explode( ',', $sorted ) as $val ) { |
| 1097 |
list( $widget_context, $id ) = explode( ':', $val ); |
| 1098 |
if ( ! empty( $widget_context ) && ! empty( $id ) ) { |
| 1099 |
self::add_widget_box( $id, null, $screen, $widget_context, null, $priority = 'sorted' ); |
| 1100 |
$already_sorted = true; |
| 1101 |
} |
| 1102 |
} |
| 1103 |
} |
| 1104 |
|
| 1105 |
$hide_widgets = get_user_option( 'mainwp_settings_hide_widgets' ); |
| 1106 |
if ( ! is_array( $hide_widgets ) ) { |
| 1107 |
$hide_widgets = array(); |
| 1108 |
} |
| 1109 |
|
| 1110 |
if ( isset( $mainwp_widget_boxes[ $page ][ $context ] ) ) { |
| 1111 |
foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { |
| 1112 |
if ( isset( $mainwp_widget_boxes[ $page ][ $context ][ $priority ] ) ) { |
| 1113 |
foreach ( (array) $mainwp_widget_boxes[ $page ][ $context ][ $priority ] as $box ) { |
| 1114 |
if ( false == $box || ! isset( $box['callback'] ) ) { |
| 1115 |
continue; |
| 1116 |
} |
| 1117 |
|
| 1118 |
// to avoid hidden widgets. |
| 1119 |
if ( in_array( $box['id'], $hide_widgets ) ) { |
| 1120 |
continue; |
| 1121 |
} |
| 1122 |
|
| 1123 |
echo '<div class="column grid-item" id="widget-' . esc_html( $box['id'] ) . '">' . "\n"; |
| 1124 |
echo '<div class="ui segment mainwp-widget" >' . "\n"; |
| 1125 |
|
| 1126 |
/** |
| 1127 |
* Action: mainwp_widget_content_top |
| 1128 |
* |
| 1129 |
* Fires at the top of widget content. |
| 1130 |
* |
| 1131 |
* @since 4.1 |
| 1132 |
*/ |
| 1133 |
do_action( 'mainwp_widget_content_top', $box, $page ); |
| 1134 |
|
| 1135 |
call_user_func( $box['callback'], $object, $box ); |
| 1136 |
|
| 1137 |
/** |
| 1138 |
* Action: mainwp_widget_content_bottom |
| 1139 |
* |
| 1140 |
* Fires at the bottom of widget content. |
| 1141 |
* |
| 1142 |
* @since 4.1 |
| 1143 |
*/ |
| 1144 |
do_action( 'mainwp_widget_content_bottom', $box, $page ); |
| 1145 |
|
| 1146 |
echo "</div>\n"; |
| 1147 |
echo "</div>\n"; |
| 1148 |
} |
| 1149 |
} |
| 1150 |
} |
| 1151 |
} |
| 1152 |
} |
| 1153 |
|
| 1154 |
/** |
| 1155 |
* Method render_empty_bulk_actions() |
| 1156 |
* |
| 1157 |
* Render empty bulk actions when drop down is disabled. |
| 1158 |
*/ |
| 1159 |
public static function render_empty_bulk_actions() { |
| 1160 |
?> |
| 1161 |
<?php esc_html_e( 'Bulk Actions: ', 'mainwp' ); ?> |
| 1162 |
<div class="ui disabled dropdown" id="mainwp-bulk-actions"> |
| 1163 |
<?php esc_html_e( 'Bulk Actions', 'mainwp' ); ?> <i class="dropdown icon"></i> |
| 1164 |
<div class="menu"></div> |
| 1165 |
</div> |
| 1166 |
<button class="ui tiny basic disabled button" href="javascript:void(0)" ><?php esc_html_e( 'Apply', 'mainwp' ); ?></button> |
| 1167 |
<?php |
| 1168 |
} |
| 1169 |
|
| 1170 |
/** |
| 1171 |
* Method render_modal_install_plugin_theme() |
| 1172 |
* |
| 1173 |
* Render modal window for installing plugins & themes. |
| 1174 |
* |
| 1175 |
* @param string $what Which window to render, plugin|theme. |
| 1176 |
*/ |
| 1177 |
public static function render_modal_install_plugin_theme( $what = 'plugin' ) { |
| 1178 |
?> |
| 1179 |
<div id="plugintheme-installation-progress-modal" class="ui modal"> |
| 1180 |
<div class="header"> |
| 1181 |
<?php |
| 1182 |
if ( 'plugin' === $what ) { |
| 1183 |
esc_html_e( 'Plugin Installation', 'mainwp' ); |
| 1184 |
} elseif ( 'theme' === $what ) { |
| 1185 |
esc_html_e( 'Theme Installation', 'mainwp' ); |
| 1186 |
} |
| 1187 |
?> |
| 1188 |
</div> |
| 1189 |
<div class="scrolling content"> |
| 1190 |
<?php |
| 1191 |
/** |
| 1192 |
* Action: mainwp_before_plugin_theme_install_progress |
| 1193 |
* |
| 1194 |
* Fires before the progress list in the install modal element. |
| 1195 |
* |
| 1196 |
* @since 4.1 |
| 1197 |
*/ |
| 1198 |
do_action( 'mainwp_before_plugin_theme_install_progress' ); |
| 1199 |
?> |
| 1200 |
<div id="plugintheme-installation-queue" ></div> |
| 1201 |
<?php |
| 1202 |
/** |
| 1203 |
* Action: mainwp_after_plugin_theme_install_progress |
| 1204 |
* |
| 1205 |
* Fires after the progress list in the install modal element. |
| 1206 |
* |
| 1207 |
* @since 4.1 |
| 1208 |
*/ |
| 1209 |
do_action( 'mainwp_after_plugin_theme_install_progress' ); |
| 1210 |
?> |
| 1211 |
</div> |
| 1212 |
<div class="actions"> |
| 1213 |
<div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div> |
| 1214 |
</div> |
| 1215 |
</div> |
| 1216 |
<?php |
| 1217 |
} |
| 1218 |
|
| 1219 |
/** |
| 1220 |
* Method render_show_all_updates_button() |
| 1221 |
* |
| 1222 |
* Render show all updates button. |
| 1223 |
* |
| 1224 |
* @return void Render Show All Updates button html. |
| 1225 |
*/ |
| 1226 |
public static function render_show_all_updates_button() { |
| 1227 |
?> |
| 1228 |
<a href="javascript:void(0)" class="ui mini button trigger-all-accordion"> |
| 1229 |
<?php |
| 1230 |
/** |
| 1231 |
* Filter: mainwp_show_all_updates_button_text |
| 1232 |
* |
| 1233 |
* Filters the Show All Updates button text. |
| 1234 |
* |
| 1235 |
* @since 4.1 |
| 1236 |
*/ |
| 1237 |
echo esc_html( apply_filters( 'mainwp_show_all_updates_button_text', __( 'Show All Updates', 'mainwp' ) ) ); |
| 1238 |
?> |
| 1239 |
</a> |
| 1240 |
<?php |
| 1241 |
} |
| 1242 |
|
| 1243 |
/** |
| 1244 |
* Method render_sorting_icons() |
| 1245 |
* |
| 1246 |
* Render sorting up & down icons. |
| 1247 |
* |
| 1248 |
* @return void Render Sort up & down incon html. |
| 1249 |
*/ |
| 1250 |
public static function render_sorting_icons() { |
| 1251 |
?> |
| 1252 |
<i class="sort icon"></i><i class="sort up icon"></i><i class="sort down icon"> |
| 1253 |
<?php |
| 1254 |
} |
| 1255 |
|
| 1256 |
/** |
| 1257 |
* Method render_modal_edit_notes() |
| 1258 |
* |
| 1259 |
* Render modal window for edit notes. |
| 1260 |
* |
| 1261 |
* @param string $what What modal window to render. Default = site. |
| 1262 |
* |
| 1263 |
* @return void |
| 1264 |
*/ |
| 1265 |
public static function render_modal_edit_notes( $what = 'site' ) { |
| 1266 |
?> |
| 1267 |
<div id="mainwp-notes" class="ui modal"> |
| 1268 |
<div class="header"><?php esc_html_e( 'Notes', 'mainwp' ); ?></div> |
| 1269 |
<div class="content" id="mainwp-notes-content"> |
| 1270 |
<?php |
| 1271 |
/** |
| 1272 |
* Action: mainwp_before_edit_site_note |
| 1273 |
* |
| 1274 |
* Fires before the site note content in the Edit Note modal element. |
| 1275 |
* |
| 1276 |
* @since 4.1 |
| 1277 |
*/ |
| 1278 |
do_action( 'mainwp_before_edit_site_note' ); |
| 1279 |
?> |
| 1280 |
<div id="mainwp-notes-html"></div> |
| 1281 |
<div id="mainwp-notes-editor" class="ui form" style="display:none;"> |
| 1282 |
<div class="field"> |
| 1283 |
<label><?php esc_html_e( 'Edit note', 'mainwp' ); ?></label> |
| 1284 |
<textarea id="mainwp-notes-note"></textarea> |
| 1285 |
</div> |
| 1286 |
<div><?php esc_html_e( 'Allowed HTML tags:', 'mainwp' ); ?> <p>, <strong>, <em>, <br>, <hr>, <a>, <ul>, <ol>, <li>, <h1>, <h2> </div> |
| 1287 |
</div> |
| 1288 |
<?php |
| 1289 |
/** |
| 1290 |
* Action: mainwp_after_edit_site_note |
| 1291 |
* |
| 1292 |
* Fires after the site note content in the Edit Note modal element. |
| 1293 |
* |
| 1294 |
* @since 4.1 |
| 1295 |
*/ |
| 1296 |
do_action( 'mainwp_after_edit_site_note' ); |
| 1297 |
?> |
| 1298 |
</div> |
| 1299 |
<div class="actions"> |
| 1300 |
<div class="ui grid"> |
| 1301 |
<div class="eight wide left aligned middle aligned column"> |
| 1302 |
<div id="mainwp-notes-status" class="left aligned"></div> |
| 1303 |
</div> |
| 1304 |
<div class="eight wide column"> |
| 1305 |
<input type="button" class="ui green button" id="mainwp-notes-save" value="<?php esc_attr_e( 'Save note', 'mainwp' ); ?>" style="display:none;"/> |
| 1306 |
<input type="button" class="ui basic green button" id="mainwp-notes-edit" value="<?php esc_attr_e( 'Edit', 'mainwp' ); ?>"/> |
| 1307 |
<input type="button" class="ui red button" id="mainwp-notes-cancel" value="<?php esc_attr_e( 'Close', 'mainwp' ); ?>"/> |
| 1308 |
<input type="hidden" id="mainwp-notes-websiteid" value=""/> |
| 1309 |
<input type="hidden" id="mainwp-notes-slug" value=""/> |
| 1310 |
<input type="hidden" id="mainwp-which-note" value="<?php echo esc_html( $what ); ?>"/> |
| 1311 |
</div> |
| 1312 |
</div> |
| 1313 |
</div> |
| 1314 |
</div> |
| 1315 |
|
| 1316 |
<?php |
| 1317 |
} |
| 1318 |
|
| 1319 |
/** |
| 1320 |
* Method usersnap_integration() |
| 1321 |
* |
| 1322 |
* Integrate UserSnap. |
| 1323 |
* |
| 1324 |
* @return bool True, Inject UserSnap meta data. False if $showtime is false. |
| 1325 |
*/ |
| 1326 |
public static function usersnap_integration() { |
| 1327 |
|
| 1328 |
$showtime = get_option( 'mainwp_show_usersnap', false ); |
| 1329 |
|
| 1330 |
if ( ! $showtime ) { |
| 1331 |
return false; |
| 1332 |
} |
| 1333 |
|
| 1334 |
if ( time() > ( $showtime + 24 * 60 * 60 ) ) { |
| 1335 |
MainWP_Utility::update_option( 'mainwp_show_usersnap', 0 ); |
| 1336 |
return false; |
| 1337 |
} |
| 1338 |
|
| 1339 |
echo '<script type="text/javascript"> |
| 1340 |
window.onUsersnapLoad = function(api) { |
| 1341 |
api.init(); |
| 1342 |
window.Usersnap = api; |
| 1343 |
} |
| 1344 |
var script = document.createElement(\'script\'); |
| 1345 |
script.async = 1; |
| 1346 |
script.src = \'https://api.usersnap.com/load/0e400c4c-d713-4c62-975a-4eba2a096375.js?onload=onUsersnapLoad\'; |
| 1347 |
document.getElementsByTagName(\'head\')[0].appendChild(script); |
| 1348 |
|
| 1349 |
jQuery(function() { |
| 1350 |
jQuery("#usersnap-bug-report-button").click(function() { |
| 1351 |
Usersnap.open(); |
| 1352 |
return false; |
| 1353 |
}); |
| 1354 |
}); |
| 1355 |
</script>'; |
| 1356 |
return true; |
| 1357 |
} |
| 1358 |
|
| 1359 |
/** |
| 1360 |
* Method render_screen_options() |
| 1361 |
* |
| 1362 |
* Render modal window for Screen Options. |
| 1363 |
* |
| 1364 |
* @param bool $setting_page Default: True. Widgets that you want to hide in the MainWP Overview page. |
| 1365 |
* |
| 1366 |
* @return void Render modal window for Screen Options html. |
| 1367 |
*/ |
| 1368 |
public static function render_screen_options( $setting_page = true ) { |
| 1369 |
|
| 1370 |
$default_widgets = array( |
| 1371 |
'overview' => __( 'Updates Overview', 'mainwp' ), |
| 1372 |
'recent_posts' => __( 'Recent Posts', 'mainwp' ), |
| 1373 |
'recent_pages' => __( 'Recent Pages', 'mainwp' ), |
| 1374 |
'plugins' => __( 'Plugins (Individual Site Overview page)', 'mainwp' ), |
| 1375 |
'themes' => __( 'Themes (Individual Site Overview page)', 'mainwp' ), |
| 1376 |
'connection_status' => __( 'Connection Status', 'mainwp' ), |
| 1377 |
'security_issues' => __( 'Security Issues', 'mainwp' ), |
| 1378 |
'notes' => __( 'Notes (Individual Site Overview page)', 'mainwp' ), |
| 1379 |
'child_site_info' => __( 'Child site info (Individual Site Overview page)', 'mainwp' ), |
| 1380 |
); |
| 1381 |
|
| 1382 |
$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. |
| 1383 |
|
| 1384 |
/** |
| 1385 |
* Filter: mainwp_widgets_screen_options |
| 1386 |
* |
| 1387 |
* Filters available widgets on the Overview page allowing users to unsent unwanted widgets. |
| 1388 |
* |
| 1389 |
* @since 4.0 |
| 1390 |
*/ |
| 1391 |
$custom_opts = apply_filters( 'mainwp_widgets_screen_options', $custom_opts ); |
| 1392 |
|
| 1393 |
if ( is_array( $custom_opts ) && 0 < count( $custom_opts ) ) { |
| 1394 |
$default_widgets = array_merge( $default_widgets, $custom_opts ); |
| 1395 |
} |
| 1396 |
|
| 1397 |
$hide_widgets = get_user_option( 'mainwp_settings_hide_widgets' ); |
| 1398 |
if ( ! is_array( $hide_widgets ) ) { |
| 1399 |
$hide_widgets = array(); |
| 1400 |
} |
| 1401 |
|
| 1402 |
/** |
| 1403 |
* Action: mainwp_screen_options_modal_top |
| 1404 |
* |
| 1405 |
* Fires at the top of the Screen Options modal element. |
| 1406 |
* |
| 1407 |
* @since 4.1 |
| 1408 |
*/ |
| 1409 |
do_action( 'mainwp_screen_options_modal_top' ); |
| 1410 |
?> |
| 1411 |
<div class="ui grid field"> |
| 1412 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Hide the Update Everything button', 'mainwp' ); ?></label> |
| 1413 |
<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"> |
| 1414 |
<input type="checkbox" name="hide_update_everything" <?php echo ( ( 1 == get_option( 'mainwp_hide_update_everything' ) ) ? 'checked="true"' : '' ); ?> /> |
| 1415 |
</div> |
| 1416 |
</div> |
| 1417 |
<?php |
| 1418 |
$overviewColumns = get_option( 'mainwp_number_overview_columns', 2 ); |
| 1419 |
if ( 2 != $overviewColumns && 3 != $overviewColumns ) { |
| 1420 |
$overviewColumns = 2; |
| 1421 |
} |
| 1422 |
|
| 1423 |
?> |
| 1424 |
<div class="ui grid field"> |
| 1425 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Widgets columns', 'mainwp' ); ?></label> |
| 1426 |
<div class="ten wide column"> |
| 1427 |
<div class="ui radio checkbox"> |
| 1428 |
<input type="radio" name="number_overview_columns" required="required" <?php echo ( 2 == $overviewColumns ? 'checked="true"' : '' ); ?> value="2"> |
| 1429 |
<label><?php esc_html_e( 'Show widgets in 2 columns', 'mainwp' ); ?></label> |
| 1430 |
</div> |
| 1431 |
<div class="ui fitted hidden divider"></div> |
| 1432 |
<div class="ui radio checkbox"> |
| 1433 |
<input type="radio" name="number_overview_columns" required="required" <?php echo ( 3 == $overviewColumns ? 'checked="true"' : '' ); ?> value="3"> |
| 1434 |
<label><?php esc_html_e( 'Show widgets in 3 columns', 'mainwp' ); ?></label> |
| 1435 |
</div> |
| 1436 |
</div> |
| 1437 |
</div> |
| 1438 |
|
| 1439 |
<div class="ui grid field"> |
| 1440 |
<label class="six wide column"><?php esc_html_e( 'Hide unwanted widgets', 'mainwp' ); ?></label> |
| 1441 |
<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"> |
| 1442 |
<ul class="mainwp_hide_wpmenu_checkboxes"> |
| 1443 |
<?php |
| 1444 |
foreach ( $default_widgets as $name => $title ) { |
| 1445 |
$_selected = ''; |
| 1446 |
if ( in_array( $name, $hide_widgets ) ) { |
| 1447 |
$_selected = 'checked'; |
| 1448 |
} |
| 1449 |
?> |
| 1450 |
<li> |
| 1451 |
<div class="ui checkbox"> |
| 1452 |
<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 ); ?>"> |
| 1453 |
<label for="mainwp_hide_widget_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label> |
| 1454 |
</div> |
| 1455 |
</li> |
| 1456 |
<?php |
| 1457 |
} |
| 1458 |
?> |
| 1459 |
</ul> |
| 1460 |
</div> |
| 1461 |
</div> |
| 1462 |
|
| 1463 |
<div class="ui grid field"> |
| 1464 |
<label class="six wide column middle aligned"></label> |
| 1465 |
<div class="ten wide column"> |
| 1466 |
<div class="ui info message"> |
| 1467 |
<div class="header"><?php esc_html_e( 'Privacy Notice', 'mainwp' ); ?></div> |
| 1468 |
<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> |
| 1469 |
<p><?php esc_html_e( 'Information recorded when you take a screen shot includes:', 'mainwp' ); ?></p> |
| 1470 |
<div class="ui bulleted list"> |
| 1471 |
<div class="item"><?php esc_html_e( 'Screenshot', 'mainwp' ); ?></div> |
| 1472 |
<div class="item"><?php esc_html_e( 'Page URL', 'mainwp' ); ?></div> |
| 1473 |
<div class="item"><?php esc_html_e( 'Browser', 'mainwp' ); ?></div> |
| 1474 |
<div class="item"><?php esc_html_e( 'Screen Size', 'mainwp' ); ?></div> |
| 1475 |
<div class="item"><?php esc_html_e( 'Operating System', 'mainwp' ); ?></div> |
| 1476 |
<div class="item"><?php esc_html_e( 'Full Console Logs', 'mainwp' ); ?></div> |
| 1477 |
</div> |
| 1478 |
<p> |
| 1479 |
<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> |
| 1480 |
</p> |
| 1481 |
</div> |
| 1482 |
</div> |
| 1483 |
</div> |
| 1484 |
|
| 1485 |
<div class="ui grid field"> |
| 1486 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Show Usersnap button', 'mainwp' ); ?></label> |
| 1487 |
<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"> |
| 1488 |
<input type="checkbox" name="mainwp_show_usersnap" <?php echo ( ( false != get_option( 'mainwp_show_usersnap' ) ) ? 'checked="true"' : '' ); ?> /> |
| 1489 |
</div> |
| 1490 |
</div> |
| 1491 |
<?php |
| 1492 |
/** |
| 1493 |
* Action: mainwp_screen_options_modal_bottom |
| 1494 |
* |
| 1495 |
* Fires at the bottom of the Screen Options modal element. |
| 1496 |
* |
| 1497 |
* @since 4.1 |
| 1498 |
*/ |
| 1499 |
do_action( 'mainwp_screen_options_modal_bottom' ); |
| 1500 |
} |
| 1501 |
} |
| 1502 |
|