Making WordPress.org


Ignore:
Timestamp:
10/10/2014 10:15:12 PM (12 years ago)
Author:
coffee2code
Message:

Code Reference: move redirect-related code into dedicated include file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php

    r876 r896  
    4040 */
    4141require __DIR__ . '/inc/user-content.php';
     42
     43/**
     44 * Redirects.
     45 */
     46require __DIR__ . '/inc/redirects.php';
    4247
    4348/**
    … …  
    5863        add_action( 'widgets_init', __NAMESPACE__ . '\\widgets_init' );
    5964        add_action( 'pre_get_posts', __NAMESPACE__ . '\\pre_get_posts' );
    60         add_action( 'template_redirect', __NAMESPACE__ . '\\redirect_single_search_match' );
    61         add_action( 'template_redirect', __NAMESPACE__ . '\\redirect_handbook' );
    62         add_action( 'template_redirect', __NAMESPACE__ . '\\redirect_resources' );
    6365        add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' );
    6466        add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 10, 2 );
    … …  
    384386
    385387/**
    386  * Redirects a search query with only one result directly to that result.
    387  */
    388 function redirect_single_search_match() {
    389         if ( is_search() && 1 == $GLOBALS['wp_query']->found_posts ) {
    390                 wp_redirect( get_permalink( get_post() ) );
    391                 exit();
    392         }
    393 }
    394 
    395 /**
    396  * Redirects a naked handbook request to home.
    397  */
    398 function redirect_handbook() {
    399         if (
    400                 // Naked /handbook/ request
    401                 ( 'handbook' == get_query_var( 'name' ) && ! get_query_var( 'post_type ' ) ) ||
    402                 // Temporary: Disable access to handbooks unless a member of the site
    403                 ( ! is_user_member_of_blog() && is_post_type_archive( array( 'plugin-handbook', 'theme-handbook' ) ) )
    404         ) {
    405                 wp_redirect( home_url() );
    406                 exit();
    407         }
    408 }
    409 
    410 /**
    411  * Redirects a naked /resources/ request to dashicons page.
    412  *
    413  * Temporary until a resource page other than dashicons is created.
    414  */
    415 function redirect_resources() {
    416         if ( is_page( 'resources' ) ) {
    417                 wp_redirect( get_permalink( get_page_by_title( 'dashicons' ) ) );
    418                 exit();
    419         }
    420 }
    421 
    422 /**
    423388 * Makes phpDoc @link references clickable.
    424389 *
Note: See TracChangeset for help on using the changeset viewer.