WordPress.org

Making WordPress.org

Changeset 6204


Ignore:
Timestamp:
12/03/2017 04:35:29 PM (8 months ago)
Author:
Otto42
Message:

Plugins: Add date to postmeta when plugins are closed or disabled. Useful for historical needs. See #2860

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r6198 r6204  
    340340            'label_count'               => _n_noop( 'Rejected <span class="count">(%s)</span>', 'Rejected <span class="count">(%s)</span>', 'wporg-plugins' ),
    341341        ) );
     342
     343        add_action( 'transition_post_status', array( $this, 'plugin_close_date' ), 10, 3 );
    342344
    343345        /**
     
    13111313        return $result;
    13121314    }
     1315
     1316    /**
     1317     * Save the date a plugin was closed and delete that date when it's reopened.
     1318     *
     1319     * @param string  $new_status The new plugin status.
     1320     * @param string  $old_status The old plugin status.
     1321     * @param WP_Post $post Post data.
     1322     */
     1323    public function plugin_close_date( $new_status, $old_status, $post ) {
     1324        if ( in_array( $new_status, array( 'closed', 'disabled' ) ) ) {
     1325            update_post_meta( $post->ID, 'plugin_closed_date', current_time( 'mysql' ) );
     1326        }
     1327        if ( 'publish' === $new_status && in_array( $old_status, array( 'closed', 'disabled' ) ) ) {
     1328            delete_post_meta( $post->ID, 'plugin_closed_date' );
     1329        }
     1330    }
    13131331}
Note: See TracChangeset for help on using the changeset viewer.