PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | class/class-mainwp-ui-select-sites.php +100 -38 5.2 → 6.2.2 View file →
@@ -6,8 +6,13 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_UI_Select_Sites
12 17 *
13 18 * @package MainWP\Dashboard
@@ -167,8 +172,12 @@
167 172 $enableSuspendedClients = isset( $params['enable_suspended_clients'] ) ? $params['enable_suspended_clients'] : false;
168 173 $selected_clients = isset( $params['selected_clients'] ) ? $params['selected_clients'] : array();
169 174 $add_edit_client_id = isset( $params['add_edit_client_id'] ) ? $params['add_edit_client_id'] : false;
170 175
176 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_clients' ) ) {
177 + $show_client = false;
178 + }
179 +
171 180 if ( 'all' !== $selected_sites && ! is_array( $selected_sites ) ) {
172 181 $selected_sites = array();
173 182 }
174 183
@@ -209,27 +218,41 @@
209 218 $select_all_disconnected = '<div onClick="return mainwp_ss_select_disconnected( this, true )" class="mainwp-ss-select-disconnected"><i class="square outline icon"></i> ' . esc_attr__( 'Select All Disconnected', 'mainwp' ) . '</div>';
210 219 $select_all_disconnected .= '<div onClick="return mainwp_ss_select_disconnected( this, false )" class="mainwp-ss-deselect-disconnected" style="display:none;padding-top:0;"><i class="check square outline icon"></i> ' . esc_attr__( 'Deselect All Disconnected', 'mainwp' ) . '</div>';
211 220 }
212 221
213 - if ( $show_select_all || $show_selectall_disc || $show_new_tag ) :
214 - ?>
215 - <div id="mainwp-select-sites-select-all-actions" class="ui two columns grid">
216 - <div class="ui middle aligned column">
217 - <?php if ( $show_select_all ) : ?>
218 - <button onClick="return mainwp_ss_select( this, true )" onKeyUp="" class="mainwp-ss-select mainwp-sites-select-deselect-button"><i class="square outline icon"></i> <?php esc_attr_e( 'Select All', 'mainwp' ); ?></button>
219 - <button onClick="return mainwp_ss_select( this, false )" onKeyUp="" class="mainwp-ss-deselect mainwp-sites-select-deselect-button" style="display:none;padding-top:0;"><i class="check square outline icon"></i> <?php esc_attr_e( 'Deselect All', 'mainwp' ); ?></button>
220 - <?php endif; ?>
221 - <?php echo $select_all_disconnected; //phpcs:ignore WordPress.Security.EscapeOutput ?>
222 - </div>
223 - <div class="ui right aligned middle aligned column">
224 - <?php if ( $show_new_tag ) { ?>
225 - <a class="ui mini basic icon button" href="javascript:void(0)" id="mainwp-create-new-tag-button" aria-label="<?php esc_attr_e( 'Create a tag with selected sites.', 'mainwp' ); ?>" data-tooltip="<?php esc_attr_e( 'Create a tag with selected sites.', 'mainwp' ); ?>" data-position="left center" data-inverted=""><i class="tag icon"></i></a>
226 - <?php } ?>
222 + static $rendered_count = 0;
223 +
224 + $rand_id_prefix = '';
225 +
226 + if ( ! empty( $rendered_count ) ) {
227 + $rand_id_prefix = '-' . MainWP_Utility::gen_rand_id();
228 + }
229 +
230 + ++$rendered_count;
231 +
232 + ?>
233 + <div id="mainwp-select-sites-select-all-actions<?php echo esc_attr( $rand_id_prefix ); ?>" class="mainwp-select-sites-select-all-actions">
234 + <div class="ui grid">
235 + <div class="ten wide middle aligned column">
236 + <span class="ui small grey text"><?php esc_html_e( 'Select:', 'mainwp' ); ?></span>
237 + <?php if ( $show_select_all ) : ?>
238 + <a href="javascript:void(0)" onClick="return mainwp_ss_select( this, true )" class="mainwp-ss-select"><span class="ui small green text"><?php esc_html_e( 'All', 'mainwp' ); ?></span></a>
239 + <span class="mainwp-ss-select ui small grey text"> · </span>
240 + <a href="javascript:void(0)" onClick="return mainwp_ss_select( this, false )" class="mainwp-ss-deselect"><span class="ui small green text"><?php esc_html_e( 'None', 'mainwp' ); ?></span></a>
241 + <?php endif; ?>
227 242 </div>
243 + <div class="six wide right aligned middle aligned column">
244 + <?php if ( $show_new_tag ) : ?>
245 + <span class="mainwp-selection-counter-wrapper" id="mainwp-selection-counter-wrapper<?php echo esc_attr( $rand_id_prefix ); ?>" style="cursor:default;">
246 + <span class="mainwp-sites-selection-counter ui small grey text">0</span> <span class="ui small grey text mainwp-selected-text"><?php esc_html_e( 'selected', 'mainwp' ); ?></span>
247 + </span>
248 + <?php else : ?>
249 + <span class="mainwp-sites-selection-counter ui small grey text">0</span> <span class="ui small grey text"><?php esc_html_e( 'selected', 'mainwp' ); ?></span>
250 + <?php endif; ?>
251 + </div>
228 252 </div>
229 - <div class="ui hidden divider"></div>
230 - <?php
231 - endif;
253 + </div>
254 + <?php
232 255 ?>
233 256 <div class="ui tab <?php echo 'site' === $selectedby ? 'active' : ''; ?>" data-tab="mainwp-select-sites-<?php echo esc_attr( $tab_id ); ?>" id="mainwp-select-sites">
234 257 <?php
235 258 MainWP_UI::render_select_sites( $websites, $type, $selected_sites, $enableOfflineSites, $edit_site_id, $show_select_all, $add_edit_client_id, $show_selectall_disc );
@@ -276,20 +299,12 @@
276 299 }
277 300 ?>
278 301 <script type="text/javascript">
279 302 jQuery( document ).ready( function () {
280 - jQuery( '#mainwp-create-new-tag-button' ).on( 'click', function() {
281 - jQuery( '#mainwp-create-group-sites-modal' ).modal( {
282 - onHide: function () {
283 - window.location.href = location.href;
284 - return false;
285 - },
286 - } ).modal( 'show' );
287 - } );
288 303 // Create a new group (Select Sites UI)
289 - jQuery( document ).on( 'click', '#mainwp-save-new-tag-button', function () {
290 - let newName = jQuery( '#mainwp-create-group-sites-modal' ).find( '#mainwp-group-name' ).val().trim();
291 - let newColor = jQuery( '#mainwp-create-group-sites-modal' ).find( '#mainwp-group-color' ).val();
304 + jQuery( document ).on( 'click', '.mainwp-save-new-tag-button', function () {
305 + let newName = jQuery( '.mainwp-create-group-sites-modal' ).find( 'input[name="mainwp-group-name"]' ).val().trim();
306 + let newColor = jQuery( '.mainwp-create-group-sites-modal' ).find( 'input[name="mainwp-group-color"]' ).val();
292 307 if('' == newName ){
293 308 return false;
294 309 }
295 310 jQuery(this).attr('disabled', 'disabled');
@@ -305,18 +320,43 @@
305 320 } );
306 321 jQuery.post( ajaxurl, data, function ( response ) {
307 322 try {
308 323 if ( response.error != undefined ){
309 - jQuery('#mainwp-message-zone-tag').show().find('.ui.message').html(response.error);
324 + jQuery('.mainwp-message-zone-tag').show().find('.ui.message').html(response.error);
310 325 return;
311 326 }
312 327 } catch ( err ) {
313 328 // to fix js error.
314 329 }
315 - jQuery( '#mainwp-create-group-sites-modal' ).modal( 'hide' );
330 + jQuery( '.mainwp-create-group-sites-modal' ).modal( 'hide' );
316 331 }, 'json' );
317 332 return false;
318 333 } );
334 +
335 + if ( typeof mainwp_update_selection_counter === 'function' ) {
336 + mainwp_update_selection_counter();
337 + }
338 +
339 + jQuery( document ).on( 'click', '.mainwp-selection-counter-wrapper', function() {
340 + let counter = jQuery( this ).find( '.mainwp-sites-selection-counter' );
341 + let count = Number.parseInt( counter.text() );
342 + if ( count > 0 ) {
343 + jQuery( '.mainwp-create-group-sites-modal' ).modal( {
344 + onHide: function () {
345 + mainwp_forceReload();
346 + return false;
347 + },
348 + } ).modal( 'show' );
349 + }
350 + } );
351 +
352 + jQuery( '#mainwp-select-sites-menu .item.tab' ).on( 'click', function() {
353 + setTimeout( function() {
354 + if ( typeof mainwp_update_selection_counter === 'function' ) {
355 + mainwp_update_selection_counter();
356 + }
357 + }, 100 );
358 + } );
319 359 } );
320 360 </script>
321 361 <?php
322 362 }
@@ -361,11 +401,22 @@
361 401 *
362 402 * @since 4.1
363 403 */
364 404 do_action( 'mainwp_before_select_clients_list', $clients );
405 +
406 + static $rendered_count = 0;
407 +
408 + $rand_id_prefix = '';
409 +
410 + if ( ! empty( $rendered_count ) ) {
411 + $rand_id_prefix = '-' . MainWP_Utility::gen_rand_id();
412 + }
413 +
414 + ++$rendered_count;
415 +
365 416 ?>
366 - <div id="mainwp-select-sites-body">
367 - <div class="ui relaxed divided list" id="mainwp-select-clients-list">
417 + <div id="mainwp-select-sites-body<?php echo esc_attr( $rand_id_prefix ); ?>" class="mainwp-select-sites-items-body">
418 + <div class="ui relaxed selection list" id="mainwp-select-clients-list">
368 419 <?php if ( ! $clients ) : ?>
369 420 <h2 class="ui icon header">
370 421 <i class="folder open outline icon"></i>
371 422 <div class="content"><?php esc_html_e( 'No Clients!', 'mainwp' ); ?></div>
@@ -419,24 +470,35 @@
419 470 *
420 471 * Renders the Create Tag modal.
421 472 */
422 473 public static function render_create_tag_modal() {
474 +
475 + static $rendered_count = 0;
476 +
477 + $rand_id_prefix = '';
478 +
479 + if ( ! empty( $rendered_count ) ) {
480 + $rand_id_prefix = '-' . MainWP_Utility::gen_rand_id();
481 + }
482 +
483 + ++$rendered_count;
484 +
423 485 ?>
424 - <div class="ui mini modal" id="mainwp-create-group-sites-modal">
486 + <div class="ui mini modal mainwp-create-group-sites-modal" id="mainwp-create-group-sites-modal<?php echo esc_attr( $rand_id_prefix ); ?>">
425 487 <i class="close icon"></i>
426 488 <div class="header"><?php echo esc_html__( 'Create Tag', 'mainwp' ); ?></div>
427 489 <div class="content">
428 - <div id="mainwp-message-zone-tag" style="display: none;">
490 + <div class="mainwp-message-zone-tag" style="display: none;">
429 491 <div class="ui message red"></div>
430 492 </div>
431 493 <div class="ui form">
432 494 <div class="field">
433 495 <label><?php esc_html_e( 'Enter tag name', 'mainwp' ); ?></label>
434 - <input type="text" value="" name="mainwp-group-name" id="mainwp-group-name">
496 + <input type="text" value="" name="mainwp-group-name" id="mainwp-group-name<?php echo esc_attr( $rand_id_prefix ); ?>">
435 497 </div>
436 498 <div class="field">
437 499 <label><?php esc_html_e( 'Select tag color', 'mainwp' ); ?></label>
438 - <input type="color" name="mainwp-group-color" class="mainwp-color-picker-input" id="mainwp-group-color" value="" />
500 + <input type="color" name="mainwp-group-color" class="mainwp-color-picker-input mainwp-group-color-picker" id="mainwp-group-color<?php echo esc_attr( $rand_id_prefix ); ?>" value="#ffffff" />
439 501 </div>
440 502 </div>
441 503 </div>
442 504 <div class="actions">
@@ -444,9 +506,9 @@
444 506 <div class="left aligned column">
445 507
446 508 </div>
447 509 <div class="right aligned column">
448 - <a class="ui green button" id="mainwp-save-new-tag-button" href="javascript:void(0);"><?php echo esc_html__( 'Create Tag', 'mainwp' ); ?></a>
510 + <a class="ui green button mainwp-save-new-tag-button" href="javascript:void(0);"><?php echo esc_html__( 'Create Tag', 'mainwp' ); ?></a>
449 511 </div>
450 512 </div>
451 513 </div>
452 514 <style>
@@ -452,9 +514,9 @@
452 514 <style>
453 515 .mainwp-ui .ui.modal .wp-picker-clear {
454 516 display:none;
455 517 }
456 - .mainwp-ui .ui.modal #mainwp-group-color {
518 + .mainwp-ui .ui.modal .mainwp-group-color-picker {
457 519 height: 28px;
458 520 margin-left: 5px;
459 521 }
460 522 </style>