Changeset 3095
- Timestamp:
- 05/06/2016 10:17:09 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r3093 r3095 25 25 */ 26 26 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 27 41 // Admin Metaboxes 28 42 add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ), 10, 2 ); 29 43 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 );41 44 42 45 add_filter( 'postbox_classes_plugin_internal-notes', array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) ); … … 221 224 $wp_list_table->prepare_items(); 222 225 } 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' ); 223 286 } 224 287 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3084 r3095 29 29 add_filter( 'rest_api_allowed_post_types', array( $this, 'filter_allowed_post_types' ) ); 30 30 add_filter( 'pre_update_option_jetpack_options', array( $this, 'filter_jetpack_options' ) ); 31 32 add_filter( 'map_meta_cap', array( __NAMESPACE__ . '\Capabilities', 'map_meta_cap' ), 10, 4 ); 31 add_action( 'template_redirect', array( $this, 'redirect_hidden_plugins' ) ); 33 32 34 33 // Shim in postmeta support for data which doesn't yet live in postmeta 35 34 add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 3 ); 35 36 add_filter( 'map_meta_cap', array( __NAMESPACE__ . '\Capabilities', 'map_meta_cap' ), 10, 4 ); 36 37 37 38 // Load the API routes … … 434 435 } 435 436 437 /** 438 * Redirects Committers and Admins to a plugin's edit page if it's disabled or closed. 439 */ 440 public function redirect_hidden_plugins() { 441 if ( ! is_404() ) { 442 return; 443 } 444 445 $post = self::get_plugin_post( get_query_var( 'name', false ) ); 446 447 if ( $post instanceof \WP_Post && in_array( $post->post_status, array( 'disabled', 'closed' ), true ) && current_user_can( 'edit_post', $post ) ) { 448 wp_safe_redirect( add_query_arg( array( 'post' => $post->ID, 'action' => 'edit' ), admin_url( 'post.php' ) ) ); 449 } 450 } 436 451 437 452 /**
Note: See TracChangeset
for help on using the changeset viewer.