Changeset 4224 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 10/12/2016 01:03:26 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
r4214 r4224 46 46 add_filter( 'pre_update_option_jetpack_options', array( $this, 'filter_jetpack_options' ) ); 47 47 add_action( 'template_redirect', array( $this, 'prevent_canonical_for_plugins' ), 9 ); 48 add_action( 'template_redirect', array( $this, ' redirect_old_plugin_urls' ) );48 add_action( 'template_redirect', array( $this, 'custom_redirects' ) ); 49 49 add_filter( 'query_vars', array( $this, 'filter_query_vars' ) ); 50 50 add_filter( 'single_term_title', array( $this, 'filter_single_term_title' ) ); … … 293 293 add_rewrite_rule( '^browse/favorites/([^/]+)$', 'index.php?browse=favorites&favorites_user=$matches[1]', 'top' ); 294 294 295 // Handle plugin admin requests 296 add_rewrite_rule( '^([^/]+)/admin/?$', 'index.php?name=$matches[1]&plugin_admin=1', 'top' ); 297 295 298 // Add duplicate search rule which will be hit before the following old-plugin tab rules 296 299 add_rewrite_rule( '^search/([^/]+)/?$', 'index.php?s=$matches[1]', 'top' ); … … 588 591 } 589 592 593 // TODO: Switch this to the capabilities systems 590 594 $restricted_access_statii = array_diff( $wp_query->query_vars['post_status'], array( 'publish' ) ); 591 595 foreach ( $posts as $i => $post ) { … … 777 781 $vars[] = 'favorites_user'; 778 782 $vars[] = 'redirect_plugin_tab'; 783 $vars[] = 'plugin_admin'; 779 784 780 785 return $vars; … … 828 833 829 834 /** 830 * Handles a redirect for the old /$plugin/$tab_name/ URLs and search.php831 */ 832 function redirect_old_plugin_urls() {835 * Handles all the custom redirects needed in the Plugin Directory. 836 */ 837 function custom_redirects() { 833 838 834 839 // Handle a redirect for /$plugin/$tab_name/ to /$plugin/#$tab_name. … … 880 885 wp_safe_redirect( site_url( '/search/' . urlencode( get_query_var( 's' ) ) . '/' ) ); 881 886 die(); 887 } 888 889 // TODO: Switch this to the capabilities systems, check if post_author should access 890 // Filter access to the plugin administration area. Only certain users are allowed access. 891 if ( get_query_var( 'plugin_admin' ) && ! current_user_can( 'plugin_review' ) ) { 892 $post = Plugin_Directory::get_plugin_post( get_query_var( 'name' ) ); 893 if ( 894 // Logged out users can't access plugin admin 895 ! is_user_logged_in() || 896 // Allow access to Committers OR Contributors. 897 ! ( 898 // Committers can access plugin admin 899 in_array( wp_get_current_user()->user_login, (array) Tools::get_plugin_committers( $post->post_name ), true ) || 900 // Contributors can access plugin admin (but will have a more limited access) 901 in_array( wp_get_current_user()->user_nicename, (array) wp_list_pluck( get_the_terms( $post, 'plugin_contributors' ), 'slug' ), true ) 902 ) 903 ) { 904 wp_safe_redirect( get_permalink( $post ) ); 905 die(); 906 } 882 907 } 883 908 }
Note: See TracChangeset
for help on using the changeset viewer.