wp/wp-admin/includes/class-wp-users-list-table.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    52 		);
    52 		);
    53 
    53 
    54 		$this->is_site_users = 'site-users-network' === $this->screen->id;
    54 		$this->is_site_users = 'site-users-network' === $this->screen->id;
    55 
    55 
    56 		if ( $this->is_site_users ) {
    56 		if ( $this->is_site_users ) {
    57 			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    57 			$this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
    58 		}
    58 		}
    59 	}
    59 	}
    60 
    60 
    61 	/**
    61 	/**
    62 	 * Check the current user's permissions.
    62 	 * Check the current user's permissions.
   257 	/**
   257 	/**
   258 	 * Retrieve an associative array of bulk actions available on this table.
   258 	 * Retrieve an associative array of bulk actions available on this table.
   259 	 *
   259 	 *
   260 	 * @since 3.1.0
   260 	 * @since 3.1.0
   261 	 *
   261 	 *
   262 	 * @return string[] Array of bulk action labels keyed by their action.
   262 	 * @return array Array of bulk action labels keyed by their action.
   263 	 */
   263 	 */
   264 	protected function get_bulk_actions() {
   264 	protected function get_bulk_actions() {
   265 		$actions = array();
   265 		$actions = array();
   266 
   266 
   267 		if ( is_multisite() ) {
   267 		if ( is_multisite() ) {
   270 			}
   270 			}
   271 		} else {
   271 		} else {
   272 			if ( current_user_can( 'delete_users' ) ) {
   272 			if ( current_user_can( 'delete_users' ) ) {
   273 				$actions['delete'] = __( 'Delete' );
   273 				$actions['delete'] = __( 'Delete' );
   274 			}
   274 			}
       
   275 		}
       
   276 
       
   277 		// Add a password reset link to the bulk actions dropdown.
       
   278 		if ( current_user_can( 'edit_users' ) ) {
       
   279 			$actions['resetpassword'] = __( 'Send password reset' );
   275 		}
   280 		}
   276 
   281 
   277 		return $actions;
   282 		return $actions;
   278 	}
   283 	}
   279 
   284 
   293 		<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
   298 		<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
   294 		<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to&hellip;' ); ?></label>
   299 		<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to&hellip;' ); ?></label>
   295 		<select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
   300 		<select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
   296 			<option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
   301 			<option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
   297 			<?php wp_dropdown_roles(); ?>
   302 			<?php wp_dropdown_roles(); ?>
       
   303 			<option value="none"><?php _e( '&mdash; No role for this site &mdash;' ); ?></option>
   298 		</select>
   304 		</select>
   299 			<?php
   305 			<?php
   300 			submit_button( __( 'Change' ), '', $button_id, false );
   306 			submit_button( __( 'Change' ), '', $button_id, false );
   301 		endif;
   307 		endif;
   302 
   308 
   333 	 * @since 3.1.0
   339 	 * @since 3.1.0
   334 	 *
   340 	 *
   335 	 * @return string The bulk action required.
   341 	 * @return string The bulk action required.
   336 	 */
   342 	 */
   337 	public function current_action() {
   343 	public function current_action() {
   338 		if ( ( isset( $_REQUEST['changeit'] ) || isset( $_REQUEST['changeit2'] ) ) &&
   344 		if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
   339 			( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) {
       
   340 			return 'promote';
   345 			return 'promote';
   341 		}
   346 		}
   342 
   347 
   343 		return parent::current_action();
   348 		return parent::current_action();
   344 	}
   349 	}
   466 					esc_url( $author_posts_url ),
   471 					esc_url( $author_posts_url ),
   467 					/* translators: %s: Author's display name. */
   472 					/* translators: %s: Author's display name. */
   468 					esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ),
   473 					esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ),
   469 					__( 'View' )
   474 					__( 'View' )
   470 				);
   475 				);
       
   476 			}
       
   477 
       
   478 			// Add a link to send the user a reset password link by email.
       
   479 			if ( get_current_user_id() !== $user_object->ID && current_user_can( 'edit_user', $user_object->ID ) ) {
       
   480 				$actions['resetpassword'] = "<a class='resetpassword' href='" . wp_nonce_url( "users.php?action=resetpassword&amp;users=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Send password reset' ) . '</a>';
   471 			}
   481 			}
   472 
   482 
   473 			/**
   483 			/**
   474 			 * Filters the action links displayed under each user in the Users list table.
   484 			 * Filters the action links displayed under each user in the Users list table.
   475 			 *
   485 			 *
   519 
   529 
   520 			if ( in_array( $column_name, $hidden, true ) ) {
   530 			if ( in_array( $column_name, $hidden, true ) ) {
   521 				$classes .= ' hidden';
   531 				$classes .= ' hidden';
   522 			}
   532 			}
   523 
   533 
   524 			$data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
   534 			$data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"';
   525 
   535 
   526 			$attributes = "class='$classes' $data";
   536 			$attributes = "class='$classes' $data";
   527 
   537 
   528 			if ( 'cb' === $column_name ) {
   538 			if ( 'cb' === $column_name ) {
   529 				$r .= "<th scope='row' class='check-column'>$checkbox</th>";
   539 				$r .= "<th scope='row' class='check-column'>$checkbox</th>";