Changeset 13886 for trunk/src/bp-core/admin/bp-core-admin-optouts.php
- Timestamp:
- 06/01/2024 07:41:30 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-optouts.php
r13818 r13886 20 20 * @since 8.0.0 21 21 * 22 * @global $bp_optouts_list_table 22 * @global $bp_optouts_list_table BP_Optouts_List_Table List table instance for nonmember opt-outs admin page. 23 23 */ 24 24 function bp_core_optouts_admin_load() { … … 26 26 27 27 // Build redirection URL. 28 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] ); 29 $doaction = bp_admin_list_table_current_bulk_action(); 28 $redirect_to = remove_query_arg( 29 array( 30 'action', 31 'error', 32 'updated', 33 'activated', 34 'notactivated', 35 'deleted', 36 'notdeleted', 37 'resent', 38 'notresent', 39 'do_delete', 40 'do_resend', 41 'do_activate', 42 '_wpnonce', 43 'signup_ids', 44 ), 45 $_SERVER['REQUEST_URI'] 46 ); 47 48 $doaction = bp_admin_list_table_current_bulk_action(); 30 49 31 50 /** … … 46 65 * @param array $value Array of allowed actions to use. 47 66 */ 48 $allowed_actions = apply_filters( 'bp_optouts_admin_allowed_actions', array( 'do_delete', 49 50 if ( ! in_array( $doaction, $allowed_actions ) || ( -1== $doaction ) ) {51 52 require_once ( ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php' );67 $allowed_actions = apply_filters( 'bp_optouts_admin_allowed_actions', array( 'do_delete', 'do_resend' ) ); 68 69 if ( ! in_array( $doaction, $allowed_actions, true ) || ( -1 === $doaction ) ) { 70 71 require_once ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php'; 53 72 $bp_optouts_list_table = new BP_Optouts_List_Table(); 54 73 … … 101 120 102 121 } else { 103 if ( empty( $_REQUEST['optout_ids' 122 if ( empty( $_REQUEST['optout_ids'] ) ) { 104 123 return; 105 124 } 106 $optout_ids = wp_parse_id_list( $_REQUEST['optout_ids' 125 $optout_ids = wp_parse_id_list( $_REQUEST['optout_ids'] ); 107 126 108 127 // Handle optout deletion. 109 if ( 'do_delete' == $doaction ) {128 if ( 'do_delete' === $doaction ) { 110 129 111 130 // Nonce check. … … 115 134 foreach ( $optout_ids as $optout_id ) { 116 135 if ( bp_delete_optout_by_id( $optout_id ) ) { 117 $success++;136 ++$success; 118 137 } 119 138 } … … 134 153 bp_core_redirect( $redirect_to ); 135 154 136 // Plugins can update other stuff from here.155 // Plugins can update other stuff from here. 137 156 } else { 138 157 … … 153 172 } 154 173 } 155 add_action( "load-tools_page_bp-optouts", 'bp_core_optouts_admin_load' );174 add_action( 'load-tools_page_bp-optouts', 'bp_core_optouts_admin_load' ); 156 175 157 176 /** … … 171 190 $notice = array( 172 191 'class' => 'updated', 173 'message' => '' 192 'message' => '', 174 193 ); 175 194 … … 177 196 $deleted = absint( $_REQUEST['deleted'] ); 178 197 $notice['message'] .= sprintf( 198 /* translators: %s: number of deleted optouts */ 179 199 _nx( 180 /* translators: %s: number of deleted optouts */181 '%s opt-out successfully deleted!', '%s opt-outs successfully deleted!',200 '%s opt-out successfully deleted!', 201 '%s opt-outs successfully deleted!', 182 202 $deleted, 183 203 'nonmembers opt-out deleted', … … 191 211 $notdeleted = absint( $_REQUEST['notdeleted'] ); 192 212 $notice['message'] .= sprintf( 213 /* translators: %s: number of optouts that failed to be deleted */ 193 214 _nx( 194 /* translators: %s: number of optouts that failed to be deleted */195 '%s opt-out was not deleted.', '%s opt-outs were not deleted.',215 '%s opt-out was not deleted.', 216 '%s opt-outs were not deleted.', 196 217 $notdeleted, 197 218 'nonmembers opt-out not deleted', … … 241 262 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible"> 242 263 243 <?php else : ?>264 <?php else : ?> 244 265 245 266 <div class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible"> … … 250 271 </div> 251 272 252 <?php endif; 273 <?php 274 endif; 253 275 254 276 // Show the proper screen. 255 277 switch ( $doaction ) { 256 case 'delete' 278 case 'delete': 257 279 bp_core_optouts_admin_manage( $doaction ); 258 280 break; … … 270 292 * 271 293 * @global $plugin_page 272 * @global $bp_optouts_list_table 294 * @global $bp_optouts_list_table BP_Optouts_List_Table List table instance for nonmember opt-outs admin page. 273 295 */ 274 296 function bp_core_optouts_admin_index() { … … 312 334 'action2', 313 335 '_wpnonce', 314 'optout_ids' 336 'optout_ids', 315 337 ), 316 338 $_SERVER['REQUEST_URI'] … … 341 363 <?php $bp_optouts_list_table->views(); ?> 342 364 343 <form id="bp-optouts-search-form" action="<?php echo esc_url( $search_form_url ) ;?>">365 <form id="bp-optouts-search-form" action="<?php echo esc_url( $search_form_url ); ?>"> 344 366 <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" /> 345 367 <?php $bp_optouts_list_table->search_box( esc_html__( 'Search for a specific email address', 'buddypress' ), 'bp-optouts' ); ?> 346 368 </form> 347 369 348 <form id="bp-optouts-form" action="<?php echo esc_url( $form_url ); ?>" method="post">370 <form id="bp-optouts-form" action="<?php echo esc_url( $form_url ); ?>" method="post"> 349 371 <?php $bp_optouts_list_table->display(); ?> 350 372 </form> 351 373 </div> 352 <?php374 <?php 353 375 } 354 376 … … 381 403 382 404 // Query for matching optouts, and filter out bad IDs. 383 $args = array(384 'id' 405 $args = array( 406 'id' => $ids, 385 407 ); 386 408 $optouts = bp_get_optouts( $args ); … … 389 411 // Check optout IDs and set up strings. 390 412 switch ( $action ) { 391 case 'delete' 413 case 'delete': 392 414 if ( 0 === count( $optouts ) ) { 393 415 $helper_text = __( 'No opt-out requests were found.', 'buddypress' ); … … 404 426 $action_args = array( 405 427 'action' => 'do_' . $action, 406 'optout_ids' => implode( ',', $optout_ids ) 428 'optout_ids' => implode( ',', $optout_ids ), 407 429 ); 408 430 … … 430 452 431 453 <ol class="bp-optouts-list"> 432 <?php foreach ( $optouts as $optout ) : 454 <?php foreach ( $optouts as $optout ) : ?> 433 455 434 456 <li> 435 <strong><?php echo esc_html( $optout->email_address ) ?></strong>457 <strong><?php echo esc_html( $optout->email_address ); ?></strong> 436 458 <p class="description"> 437 459 <?php 438 460 $last_modified = mysql2date( 'Y/m/d g:i:s a', $optout->date_modified ); 439 461 /* translators: %s: modification date */ 440 printf( esc_html__( 'Date modified: %s', 'buddypress' ), esc_html( $last_modified ) );462 printf( esc_html__( 'Date modified: %s', 'buddypress' ), esc_html( $last_modified ) ); 441 463 ?> 442 464 </p> … … 448 470 <?php if ( 'delete' === $action && count( $optouts ) ) : ?> 449 471 450 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>451 452 <?php endif 472 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ); ?></strong></p> 473 474 <?php endif; ?> 453 475 454 476 <?php if ( count( $optouts ) ) : ?> … … 458 480 <?php endif; ?> 459 481 460 <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a>482 <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ); ?></a> 461 483 </div> 462 484
Note: See TracChangeset
for help on using the changeset viewer.