Making WordPress.org

Changeset 954


Ignore:
Timestamp:
10/29/2014 08:07:38 PM (12 years ago)
Author:
coffee2code
Message:

Code Reference: override default handbook configuration (and other affected areas) to make the canonical post type slug plural

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc
Files:
3 edited

Legend:

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

    r953 r954  
    3838
    3939                add_filter( 'the_content', array( __CLASS__, 'autolink_credits' ) );
     40
     41                add_filter( 'handbook_post_type_defaults', array( __CLASS__, 'filter_handbook_post_type_defaults' ), 10, 2 );
    4042
    4143                // Add the handbook's 'Watch' action link.
    … …  
    116118
    117119        /**
     120         * Overrides default handbook post type configuration.
     121         *
     122         * Specifically, uses a plural slug while retaining pre-existing singular post
     123         * type name.
     124         *
     125         * @access public
     126         *
     127         * @param  array  $defaults  The default post type configuration.
     128         * @param  string $post_type The post type name.
     129         * @return array
     130         */
     131        public static function filter_handbook_post_type_defaults( $defaults, $post_type ) {
     132                $defaults['rewrite'] = array(
     133                        'feeds'      => false,
     134                        'slug'       => $post_type . 's',
     135                        'with_front' => false,
     136                );
     137
     138                return $defaults;
     139        }
     140
     141        /**
    118142         * For specific credit pages, link @usernames references to their profiles on
    119143         * profiles.wordpress.org.
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/redirects.php

    r898 r954  
    2525                add_action( 'template_redirect', array( __CLASS__, 'redirect_handbook' ) );
    2626                add_action( 'template_redirect', array( __CLASS__, 'redirect_resources' ) );
    27                 add_action( 'template_redirect', array( __CLASS__, 'redirect_pluralized_handbooks' ), 1 );
     27                add_action( 'template_redirect', array( __CLASS__, 'redirect_singularized_handbooks' ), 1 );
    2828                add_action( 'template_redirect', array( __CLASS__, 'redirect_pluralized_reference_post_types' ), 1 );
    2929        }
    … …  
    6767
    6868        /**
    69          * Redirects requests for the pluralized slugs of the handbooks.
    70          *
    71          * Note: this is a convenience redirect of just the naked slugs and not a
    72          * fix for any deployed links.
     69         * Redirects requests for the singularized form of handbook slugs to the
     70         * pluralized version.
    7371         */
    74         public static function redirect_pluralized_handbooks() {
    75                 $name = get_query_var( 'name' );
     72        public static function redirect_singularized_handbooks() {
     73                $path = trailingslashit( $_SERVER['REQUEST_URI'] );
    7674
    77                 // '/plugins' => '/plugin'
    78                 if ( 'plugins' == $name ) {
    79                         wp_redirect( get_post_type_archive_link( 'plugin-handbook' ), 301 );
     75                // '/plugin' => '/plugins'
     76                if ( 0 === strpos( $path, '/plugin/' ) ) {
     77                        $path = get_post_type_archive_link( 'plugin-handbook' ) . substr( $path, 8 );
     78                        wp_redirect( $path, 301 );
    8079                        exit();
    8180                }
    8281
    83                 // '/themes' => '/theme'
    84                 if ( 'themes' == $name ) {
    85                         wp_redirect( get_post_type_archive_link( 'theme-handbook' ), 301 );
     82                // '/theme' => '/themes'
     83                if ( 0 === strpos( $path, '/theme/' ) ) {
     84                        $path = get_post_type_archive_link( 'theme-handbook' ) . substr( $path, 7 );
     85                        wp_redirect( $path, 301 );
    8686                        exit();
    8787                }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r943 r954  
    438438                        case 'reference':
    439439                                return __( 'Code Reference', 'wporg' );
    440                         case 'plugin':
     440                        case 'plugins':
    441441                                return __( 'Plugin Handbook', 'wporg' );
    442                         case 'theme':
     442                        case 'themes':
    443443                                return __( 'Theme Handbook', 'wporg' );
    444444                        default:
Note: See TracChangeset for help on using the changeset viewer.