Changeset 12591 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
- Timestamp:
- 05/17/2023 08:38:01 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r12520 r12591 64 64 add_action( 'wp_ajax_plugin-author-lookup', array( __NAMESPACE__ . '\Metabox\Author', 'lookup_author' ) ); 65 65 add_action( 'wp_ajax_plugin-svn-sync', array( __NAMESPACE__ . '\Metabox\Review_Tools', 'svn_sync' ) ); 66 add_action( 'wp_ajax_plugin-set-reviewer', array( __NAMESPACE__ . '\Metabox\Reviewer', 'xhr_set_reviewer' ) ); 66 67 67 68 add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Release_Confirmation', 'save_post' ) ); 68 69 add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Author_Notice', 'save_post' ) ); 70 add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Reviewer', 'save_post' ) ); 71 72 // Audit logs 73 add_action( 'updated_postmeta', array( $this, 'updated_postmeta' ), 10, 4 ); 69 74 } 70 75 … … 212 217 } 213 218 219 // Filter by reviewer. 220 if ( ! empty( $_REQUEST['reviewer'] ) ) { 221 $meta_query = $query->get( 'meta_query' ) ?: []; 222 $meta_query[] = [ 223 'key' => 'assigned_reviewer', 224 'value' => intval( $_GET['reviewer'] ), 225 ]; 226 227 $query->set( 'meta_query', $meta_query ); 228 } 229 214 230 } 215 231 … … 242 258 243 259 $action = array_intersect( 244 [ 'plugin_open', 'plugin_close', 'plugin_disable', 'plugin_reject' ],260 [ 'plugin_open', 'plugin_close', 'plugin_disable', 'plugin_reject', 'plugin_assign' ], 245 261 [ $_REQUEST['action'], $_REQUEST['action2'] ] 246 262 ); … … 251 267 252 268 check_admin_referer( 'bulk-posts' ); 269 270 $new_status = false; 271 $from_state = false; 272 $meta_data = false; 253 273 254 274 switch( $action ) { … … 277 297 $from_state = [ 'new', 'pending' ]; 278 298 break; 299 case 'plugin_assign': 300 if ( ! isset( $_REQUEST['reviewer'] ) ) { 301 return; 302 } 303 304 $capability = 'plugin_review'; 305 $from_state = 'any'; 306 $message = _n_noop( '%s plugin assigned.', '%s plugins assigned.', 'wporg-plugins' ); 307 $meta_data = array( 308 'assigned_reviewer' => intval( $_REQUEST['reviewer'] ), 309 'assigned_reviewer_time' => time(), 310 ); 311 break; 279 312 default: 280 313 return; … … 282 315 283 316 $closed = 0; 284 $ plugins = get_posts(array(317 $args = array( 285 318 'post_type' => 'plugin', 286 319 'post__in' => array_map( 'absint', $_REQUEST['post'] ), 287 'post_status' => $from_state,288 320 'posts_per_page' => count( $_REQUEST['post'] ), 289 ) ); 321 ); 322 if ( $from_state ) { 323 $args['post_status'] = $from_state; 324 } 325 $plugins = get_posts( $args ); 290 326 291 327 foreach ( $plugins as $plugin ) { … … 293 329 continue; 294 330 } 295 296 $updated = wp_update_post( array( 297 'ID' => $plugin->ID, 298 'post_status' => $new_status, 299 ) ); 331 $updated = false; 332 333 if ( $new_status ) { 334 $updated = wp_update_post( array( 335 'ID' => $plugin->ID, 336 'post_status' => $new_status, 337 ) ); 338 } 339 if ( $meta_data ) { 340 foreach ( $meta_data as $key => $value ) { 341 $updated = update_post_meta( $plugin->ID, $key, $value ); 342 } 343 } 300 344 301 345 if ( $updated && ! is_wp_error( $updated ) ) { … … 545 589 __( 'Plugin Controls', 'wporg-plugins' ), 546 590 array( __NAMESPACE__ . '\Metabox\Controls', 'display' ), 591 'plugin', 'side', 'high' 592 ); 593 594 add_meta_box( 595 'reviewerdiv', 596 __( 'Reviewer', 'wporg-plugins' ), 597 array( __NAMESPACE__ . '\Metabox\Reviewer', 'display' ), 547 598 'plugin', 'side', 'high' 548 599 ); … … 807 858 return $keys; 808 859 } 860 861 /** 862 * Watch for post_meta updates and log accordingly. 863 */ 864 public function updated_postmeta( $meta_id, $post_id, $meta_key, $meta_value ) { 865 if ( 'assigned_reviewer' === $meta_key && $meta_value ) { 866 $reviewer = get_user_by( 'id', $meta_value ); 867 Tools::audit_log( 868 sprintf( 869 'Assigned to <a href="%s">%s</a>.', 870 esc_url( 'https://profiles.wordpress.org/' . $reviewer->user_nicename . '/' ), 871 $reviewer->display_name ?: $reviewer->user_login 872 ), 873 get_post( $post_id ) 874 ); 875 } elseif ( 'assigned_reviewer' === $meta_key && ! $meta_value ) { 876 Tools::audit_log( 'Unassigned.', get_post( $post_id ) ); 877 } 878 } 809 879 }
Note: See TracChangeset
for help on using the changeset viewer.