WordPress.org

Making WordPress.org


Ignore:
Timestamp:
05/06/2016 10:17:09 PM (3 years ago)
Author:
obenland
Message:

Plugin Directory: Show banners to provide a clearer status for plugins.

Redirects users who can edit a particular plugin that is closed or disabled
from the front-end to the edit page of that plugin and adds admin notices to
give more context about the current status of a plugin.

Fixes #1689.

File:
1 edited

Legend:

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

    r3093 r3095  
    2525     */
    2626    private function __construct() {
     27        add_filter( 'dashboard_glance_items', array( $this, 'plugin_glance_items' ) );
     28
     29        add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
     30        add_action( 'save_post_plugin', array( $this, 'save_plugin_post' ) );
     31
     32        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
     33        add_filter( 'admin_head-edit.php', array( $this, 'plugin_posts_list_table' ) );
     34        add_action( 'admin_notices', array( $this, 'add_post_status_notice' ) );
     35        add_action( 'all_admin_notices', array( $this, 'admin_notices' ) );
     36        add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
     37
     38        add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
     39        add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 );
     40
    2741        // Admin Metaboxes
    2842        add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ), 10, 2 );
    2943        add_action( 'do_meta_boxes', array( $this, 'replace_title_global' ) );
    30         add_filter( 'dashboard_glance_items', array( $this, 'plugin_glance_items' ) );
    31 
    32         add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
    33         add_action( 'save_post_plugin', array( $this, 'save_plugin_post' ) );
    34 
    35         add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
    36         add_filter( 'admin_head-edit.php', array( $this, 'plugin_posts_list_table' ) );
    37         add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
    38 
    39         add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
    40         add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 );
    4144
    4245        add_filter( 'postbox_classes_plugin_internal-notes',    array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) );
     
    221224            $wp_list_table->prepare_items();
    222225        }
     226    }
     227
     228    /**
     229     * Adds banners to provide a clearer status for a plugin.
     230     *
     231     * This is being displayed in the edit screen for a particular plugin,
     232     * providing more context about the current status of a plugin for both
     233     * Committers and Reviewers/Admins.
     234     */
     235    public function add_post_status_notice() {
     236        if ( 'post.php' !== $GLOBALS['pagenow'] ) {
     237            return;
     238        }
     239
     240        $message  = '';
     241        $post     = get_post();
     242        $is_admin = current_user_can( 'plugin_approve' );
     243
     244        switch ( $post->post_status ) {
     245            case 'draft':
     246            case 'pending':
     247                $message = __( 'This plugin is requested and not visible to the public yet.', 'wporg-plugins' );
     248                if ( ! $is_admin ) {
     249                    $message .= ' ' . __( 'Please be patient as your plugin gets reviewed.', 'wporg-plugins' );
     250                }
     251                break;
     252
     253            case 'rejected':
     254                $message = __( 'This plugin is rejected and is not visible to the public.', 'wporg-plugins' );
     255                break;
     256
     257            case 'approved':
     258                $message = __( 'This plugin is approved and awaiting data upload but not visible to the public yet.', 'wporg-plugins' );
     259                if ( ! $is_admin ) {
     260                    $message .= ' ' . __( 'Once you make your first commit, the plugin will become public.', 'wporg-plugins' );
     261                }
     262                break;
     263
     264            case 'closed':
     265                $message = __( 'This plugin is closed and is not visible to the public.', 'wporg-plugins' );
     266                break;
     267
     268            case 'disabled':
     269                $message = __( 'This plugin is closed and is not visible to the public.', 'wporg-plugins' );
     270                if ( $is_admin ) {
     271                    $message = __( 'This plugin is disabled (closed, but actively serving updates) and is not visible to the public.', 'wporg-plugins' );
     272                }
     273                break;
     274        }
     275
     276        if ( $message ) {
     277            add_settings_error( 'wporg-plugins', 'status-notice', $message, 'updated' );
     278        }
     279    }
     280
     281    /**
     282     * Displays all admin notices registered to `wporg-plugins`.
     283     */
     284    public function admin_notices() {
     285        settings_errors( 'wporg-plugins' );
    223286    }
    224287
Note: See TracChangeset for help on using the changeset viewer.