Changeset 3376 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 06/15/2016 06:07:50 AM (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
r3375 r3376 32 32 add_action( 'template_redirect', array( $this, 'redirect_hidden_plugins' ) ); 33 33 add_action( 'template_redirect', array( $this, 'prevent_canonical_for_plugins' ), 9 ); 34 add_action( 'template_redirect', array( $this, 'redirect_old_plugin_tabs' ) ); 35 add_filter( 'query_vars', array( $this, 'filter_query_vars' ) ); 34 36 35 37 // Shim in postmeta support for data which doesn't yet live in postmeta … … 204 206 205 207 // Add the browse/* views. 206 // TODO: browse/favorites/$user207 208 add_rewrite_tag( '%browse%', '(featured|popular|beta|new|favorites)' ); 208 209 add_permastruct( 'browse', 'browse/%browse%' ); 210 211 // /browse/ should be the popular archive view. 212 add_rewrite_rule( '^browse$', 'index.php?browse=popular', 'top' ); 213 // Create an archive for a users favorites too. 214 add_rewrite_rule( '^browse/favorites/([^/]+)$', 'index.php?browse=favorites&favorites_user=$matches[1]', 'top' ); 215 216 // Handle the old plugin tabs URLs 217 add_rewrite_rule( '^([^/]+)/(installation|faq|screenshots|changelog|stats|developers|other_notes)$', 'index.php?redirect_plugin_tab=$matches[1]/#$matches[2]', 'top' ); 209 218 210 219 // If changing capabilities around, uncomment this. … … 517 526 518 527 /** 528 * Filters the available public query vars to add our custom parameters. 529 */ 530 public function filter_query_vars( $vars ) { 531 $vars[] = 'favorites_user'; 532 $vars[] = 'redirect_plugin_tab'; 533 return $vars; 534 } 535 536 /** 519 537 * Filter for pre_update_option_jetpack_options to ensure CPT posts are seen as public and searchable by TP 520 538 * … … 541 559 if ( $post instanceof \WP_Post && in_array( $post->post_status, array( 'disabled', 'closed' ), true ) && current_user_can( 'edit_post', $post ) ) { 542 560 wp_safe_redirect( add_query_arg( array( 'post' => $post->ID, 'action' => 'edit' ), admin_url( 'post.php' ) ) ); 561 die(); 543 562 } 544 563 } … … 550 569 if ( is_404() ) { 551 570 remove_action( 'template_redirect', 'redirect_canonical' ); 571 } 572 } 573 574 /** 575 * Handles a redirect for the old /$plugin/$tab_name/ URLs 576 */ 577 function redirect_old_plugin_tabs() { 578 if ( get_query_var( 'redirect_plugin_tab' ) ) { 579 wp_safe_redirect( site_url( get_query_var( 'redirect_plugin_tab' ) ) ); 580 die(); 552 581 } 553 582 }
Note: See TracChangeset
for help on using the changeset viewer.