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