Making WordPress.org

Changeset 773


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

Code Reference: fixes for, and selective activation of, handbooks

  • Landing page:
    • Permit members of site to access the page
    • Set proper links to handbooks
    • Don't display the page content
  • Redirect naked '/handbook/' requests to home page
  • Remove 'Handbook' from handbook breadcrumbs
  • Base site section title for handbooks on is_post_type_archive()
Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
3 edited

Legend:

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

    r771 r773  
    4949        add_action( 'pre_get_posts', __NAMESPACE__ . '\\pre_get_posts' );
    5050        add_action( 'template_redirect', __NAMESPACE__ . '\\redirect_single_search_match' );
     51        add_action( 'template_redirect', __NAMESPACE__ . '\\redirect_handbook' );
    5152        add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' );
    5253        add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 10, 2 );
    … …  
    6364
    6465        add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_items', 10, 2 );
     66        add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_remove_handbook', 10, 2 );
    6567
    6668        treat_comments_as_examples();
    … …  
    9496        // Unset the last element since it shifted up in trail hierarchy
    9597        unset( $items[4] );
     98
     99        return $items;
     100}
     101
     102/**
     103 * Removes the 'Handbook' segment of the breakcrumb, when present.
     104 *
     105 * There is no handbook page or listing at present.
     106 *
     107 * @param  array $items The breadcrumb trail items
     108 * @param  array $args  Original arg
     109 * @return array
     110 */
     111function breadcrumb_trail_remove_handbook( $items, $args ) {
     112        if ( false !== strpos( $items[1], '>Handbook</a>' ) ) {
     113                array_splice( $items, 1, 1 );
     114        }
    96115
    97116        return $items;
    … …  
    474493
    475494/**
     495 * Redirects a naked handbook request to home.
     496 */
     497function redirect_handbook() {
     498        if ( 'handbook' == get_query_var( 'name' ) && ! get_query_var( 'post_type ' ) ) {
     499                wp_redirect( home_url() );
     500                exit();
     501        }
     502}
     503
     504/**
    476505 * Makes phpDoc @link references clickable.
    477506 *
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r771 r773  
    336336         */
    337337        function get_site_section_title() {
     338                if ( is_post_type_archive( array( 'plugin-handbook' ) ) ) {
     339                        return __( 'Plugin Handbook', 'wporg' );
     340                }
     341
     342                if ( is_post_type_archive( array ( 'theme-handbook' ) ) ) {
     343                        return __( 'Theme Handbook', 'wporg' );
     344                }
     345
    338346                $parts = explode( '/', $_SERVER['REQUEST_URI'] );
    339347                switch ( $parts[1] ) {
    340348                        case 'reference':
    341                                 return 'Code Reference';
    342                         case 'theme-handbook':
    343                                 return 'Theme Handbook';
    344                         case 'plugin-handbook':
    345                                 return 'Plugin Handbook';
     349                                return __( 'Code Reference', 'wporg' );
    346350                        default:
    347                                 return 'Developer Resources';
     351                                return __( 'Developer Resources', 'wporg' );
    348352                }
    349353        }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/page-home-landing.php

    r554 r773  
    99
    1010// Temporarily redirect to reference until other section become live, justifying a main landing page.
    11 wp_redirect( get_permalink( get_page_by_path( 'reference' ) ) );
    12 exit();
     11if ( ! is_user_member_of_blog() ) {
     12        wp_redirect( get_permalink( get_page_by_path( 'reference' ) ) );
     13        exit();
     14}
    1315
    1416get_header(); ?>
    … …  
    2325                                                <h3 class="widget-title"><div class="dashicons dashicons-welcome-widgets-menus"></div><?php _e( 'Themes', 'wporg' ); ?></h3>
    2426                                                <p class="widget-description"><?php _e( 'Want to know all there is to know about theming and WordPress?', 'wporg' ); ?></p>
    25                                                 <a href="#" class="themes-go get-started go button"><?php _e( 'Develop Themes ', 'wporg' ); ?><span class="dashicons dashicons-arrow-right-alt2"></span></a>
     27                                                <a href="<?php esc_attr_e( get_post_type_archive_link( 'theme-handbook' ) ); ?>" class="themes-go get-started go button"><?php _e( 'Develop Themes ', 'wporg' ); ?><span class="dashicons dashicons-arrow-right-alt2"></span></a>
    2628                                        </div>
    2729                                        <div class="widget box box-right transparent">
    2830                                                <h3 class="widget-title"><div class="dashicons dashicons-admin-plugins"></div><?php _e( 'Plugins', 'wporg' ); ?></h3>
    2931                                                <p class="widget-description"><?php _e( 'Ready to dive deep into the world of plugin authoring?', 'wporg' ); ?></p>
    30                                                 <a href="#" class="plugins-go get-started go button"><?php _e( 'Develop Plugins ', 'wporg' ); ?><span class="dashicons dashicons-arrow-right-alt2"></span></a>
     32                                                <a href="<?php esc_attr_e( get_post_type_archive_link( 'plugin-handbook' ) ); ?>" class="plugins-go get-started go button"><?php _e( 'Develop Plugins ', 'wporg' ); ?><span class="dashicons dashicons-arrow-right-alt2"></span></a>
    3133                                        </div>
    3234                                </div>
    … …  
    4749                        </div><!-- /new-in-guide -->
    4850
    49 
     51<?php /*
    5052                        <main id="main" class="site-main section" role="main">
    5153
    … …  
    7274
    7375                        </main><!-- #main -->
    74 
     76*/ ?>
    7577
    7678                        <div class="search-guide section light-gray clear">
Note: See TracChangeset for help on using the changeset viewer.