Changeset 3157
- Timestamp:
- 05/17/2016 05:34:49 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin
- Files:
-
- 2 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 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r3093 r3157 62 62 'per_page' => $per_page 63 63 ) ); 64 } 65 66 /** 67 * 68 * @return array 69 */ 70 protected function get_bulk_actions() { 71 $actions = array(); 72 $post_type_obj = get_post_type_object( $this->screen->post_type ); 73 74 if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { 75 if ( $this->is_trash ) { 76 $actions['untrash'] = __( 'Restore' ); 77 } else { 78 $actions['edit'] = __( 'Edit' ); 79 } 80 } 81 82 if ( current_user_can( 'plugin_reject' ) && ( empty( $_REQUEST['post_status'] ) || in_array( $_REQUEST['post_status'], array( 'draft', 'pending' ) ) ) ) { 83 $actions['plugin_reject'] = __( 'Reject', 'wporg-plugins' ); 84 } 85 86 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { 87 if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { 88 $actions['delete'] = __( 'Delete Permanently' ); 89 } else { 90 $actions['trash'] = __( 'Move to Trash' ); 91 } 92 } 93 94 return $actions; 64 95 } 65 96
Note: See TracChangeset
for help on using the changeset viewer.