Changeset 2996 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
- Timestamp:
- 04/21/2016 10:01:04 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
r2995 r2996 27 27 add_action( 'publish_plugin', array( $this, 'publish' ), 10, 2 ); 28 28 add_action( 'rejected_plugin', array( $this, 'rejected' ), 10, 2 ); 29 } 30 31 /** 32 * Checks permissions before allowing a post_status change for plugins. 33 * 34 * @param array $data An array of slashed post data. 35 * @param array $postarr An array of sanitized, but otherwise unmodified post data. 36 * @return array 37 */ 38 public static function can_change_post_status( $data, $postarr ) { 39 $old_status = get_post_field( 'post_status', $postarr['ID'] ); 40 41 // Keep going if this is not a plugin... 42 if ( 'plugin' !== $postarr['post_type'] ) { 43 return $data; 44 } 45 46 // ...or the status never changed... 47 if ( $old_status === $postarr['post_status'] ) { 48 return $data; 49 } 50 51 // ...or it's a plugin admin... 52 if ( current_user_can( 'plugin_approve', $postarr['ID'] ) ) { 53 return $data; 54 } 55 56 // ...or it's a white-listed status for plugin reviewers. 57 if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array( $postarr['post_status'], array( 'draft', 'pending' ) ) ) { 58 return $data; 59 } 60 61 // ...DIE!!!!! 62 wp_die( __( 'You do not have permission to assign this post status to a plugin.', 'wporg-plugins' ), '', array( 63 'back_link' => true, 64 ) ); 29 65 } 30 66
Note: See TracChangeset
for help on using the changeset viewer.