Changeset 5996
- Timestamp:
- 10/04/2017 02:45:22 AM (6 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
r5918 r5996 25 25 */ 26 26 private function __construct() { 27 add_action( 'transition_post_status', array( $this, 'record_status_change' ), 11, 3 ); 28 29 add_action( 'approved_plugin', array( $this, 'approved' ), 10, 2 ); 30 add_action( 'rejected_plugin', array( $this, 'rejected' ), 10, 2 ); 27 add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 11, 3 ); 31 28 } 32 29 … … 107 104 108 105 /** 109 * Records the time a plugin was transitioned into a specific status. 106 * Calls the methods that should fire when a plugin is transitioned 107 * to a specific status. 110 108 * 111 109 * @param string $new_status New post status. … … 113 111 * @param \WP_Post $post Post object. 114 112 */ 115 public function record_status_change( $new_status, $old_status, $post ) { 116 if ( 'plugin' === $post->post_type ) { 117 update_post_meta( $post->ID, "_{$new_status}", strtotime( $post->post_modified_gmt ) ); 118 } 113 public function transition_post_status( $new_status, $old_status, $post ) { 114 if ( 'plugin' !== $post->post_type ) { 115 return; 116 } 117 118 // Bail if no status change. 119 if ( $old_status === $new_status ) { 120 return; 121 } 122 123 switch ( $new_status ) { 124 case 'approved': 125 $this->approved( $post->ID, $post ); 126 break; 127 case 'rejected': 128 $this->rejected( $post->ID, $post ); 129 break; 130 } 131 132 // Record the time a plugin was transitioned into a specific status. 133 update_post_meta( $post->ID, "_{$new_status}", strtotime( $post->post_modified_gmt ) ); 119 134 } 120 135 … … 216 231 } 217 232 218 // Prevent recursive calling via wp_update_post().219 remove_action( 'rejected_plugin', array( $this, 'rejected' ), 10 );220 221 233 // Change slug to 'rejected-plugin-name-rejected' to free up 'plugin-name'. 222 234 wp_update_post( array( … … 224 236 'post_name' => sprintf( 'rejected-%s-rejected', $post->post_name ) 225 237 ) ); 226 227 // Re-add action.228 add_action( 'rejected_plugin', array( $this, 'rejected' ), 10, 2 );229 238 230 239 // Send email.
Note: See TracChangeset
for help on using the changeset viewer.