Making WordPress.org

Changeset 2926


Ignore:
Timestamp:
04/11/2016 11:31:07 AM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Display custom post stati in list table.

See #1570.

File:
1 edited

Legend:

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

    r2834 r2926  
    3434        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
    3535        add_filter( 'admin_head-edit.php', array( $this, 'plugin_posts_list_table' ) );
     36        add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
    3637
    3738        add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
     
    183184            $wp_list_table = new Plugin_Posts();
    184185        }
     186    }
     187
     188    /**
     189     * Filter the default post display states used in the posts list table.
     190     *
     191     * @param array    $post_states An array of post display states.
     192     * @param \WP_Post $post        The current post object.
     193     */
     194    public function post_states( $post_states, $post ) {
     195        $post_status = '';
     196
     197        if ( isset( $_REQUEST['post_status'] ) ) {
     198            $post_status = $_REQUEST['post_status'];
     199        }
     200
     201        if ( 'disabled' == $post->post_status && 'disabled' != $post_status ) {
     202            $post_states['disabled'] = _x( 'Disabled', 'plugin status', 'wporg-plugins' );
     203        }
     204        if ( 'closed' == $post->post_status && 'closed' != $post_status ) {
     205            $post_states['closed'] = _x( 'Closed', 'plugin status', 'wporg-plugins' );
     206        }
     207        if ( 'rejected' == $post->post_status && 'rejected' != $post_status ) {
     208            $post_states['rejected'] = _x( 'Rejected', 'plugin status', 'wporg-plugins' );
     209        }
     210
     211        return $post_states;
    185212    }
    186213
Note: See TracChangeset for help on using the changeset viewer.