Changeset 3095 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 05/06/2016 10:17:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.