Changeset 3157 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
- Timestamp:
- 05/17/2016 05:34:49 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r3131 r3157 30 30 add_action( 'save_post_plugin', array( $this, 'save_plugin_post' ) ); 31 31 32 add_action( 'load-edit.php', array( $this, 'bulk_reject_plugins' ) ); 32 33 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 33 34 add_filter( 'admin_head-edit.php', array( $this, 'plugin_posts_list_table' ) ); … … 226 227 $wp_list_table->prepare_items(); 227 228 } 229 } 230 231 /** 232 * Rejects plugins in bulk. 233 */ 234 public function bulk_reject_plugins() { 235 if ( empty( $_REQUEST['action'] ) || empty( $_REQUEST['action2'] ) || ! in_array( 'plugin_reject', array( $_REQUEST['action'], $_REQUEST['action2'] ) ) || 'plugin' !== $_REQUEST['post_type'] ) { 236 return; 237 } 238 239 check_admin_referer( 'bulk-posts' ); 240 241 $rejected = 0; 242 $plugins = get_posts( array( 243 'post_type' => 'plugin', 244 'post__in' => array_map( 'absint', $_REQUEST['post'] ), 245 'post_status' => array( 'draft', 'pending' ), 246 'posts_per_page' => count( $_REQUEST['post'] ), 247 ) ); 248 249 foreach ( $plugins as $plugin ) { 250 if ( ! current_user_can( 'plugin_reject', $plugin ) ) { 251 wp_die( __( 'You are not allowed to reject this plugin.', 'wporg-plugins' ), '', array( 'back_link' => true ) ); 252 } 253 254 $updated = wp_update_post( array( 255 'ID' => $plugin->ID, 256 'post_status' => 'rejected', 257 ) ); 258 259 if ( $updated && ! is_wp_error( $updated ) ) { 260 $rejected++; 261 } 262 } 263 264 if ( $rejected ) { 265 set_transient( 'settings_errors', array( array( 266 'setting' => 'wporg-plugins', 267 'code' => 'plugins-bulk-rejected', 268 'message' => sprintf( _n( '1 plugin rejected.', '%d plugins rejected.', $rejected, 'wporg-plugins' ), $rejected ), 269 'type' => 'updated', 270 ) ) ); 271 } 272 273 $send_back = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'locked', 'ids', 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), wp_get_referer() ); 274 wp_redirect( add_query_arg( array( 'settings-updated' => true ), $send_back ) ); 275 exit; 228 276 } 229 277
Note: See TracChangeset
for help on using the changeset viewer.