Changeset 2996
- Timestamp:
- 04/21/2016 10:01:04 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 3 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 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
r2994 r2996 43 43 $statuses = array( 'draft', 'pending' ); 44 44 if ( current_user_can( 'plugin_approve', $post ) ) { 45 $statuses = array_merge( $statuses, array( 'publish', 'disabled', 'closed', 'rejected' ) ); 45 if ( in_array( $post->post_status, array( 'draft', 'pending', 'rejected' ) ) ) { 46 $statuses = array_merge( $statuses, array( 'publish', 'rejected' ) ); 47 } else { 48 $statuses = array( 'publish', 'disabled', 'closed' ); 49 } 46 50 } 47 51 ?> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r2994 r2996 42 42 Customizations::instance(); 43 43 44 add_action( 'wp_insert_post_data', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'can_change_post_status' ), 10, 2 ); 44 45 add_action( 'transition_post_status', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'instance' ) ); 45 46 }
Note: See TracChangeset
for help on using the changeset viewer.