Making WordPress.org


Ignore:
Timestamp:
08/12/2014 06:37:14 AM (10 years ago)
Author:
coffee2code
Message:

Code Reference: fix section titles and links

  • Add get_site_section_url() to get appropriate section home URL
  • Fix get_site_section_title() for plugin and theme handbooks
  • Condense markup creation
File:
1 edited

Legend:

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

    r781 r785  
    331331
    332332    /**
    333      * Get site section from url path
     333     * Get site section root URL based on URL path.
     334     *
     335     * @return string
     336     */
     337    function get_site_section_url() {
     338        $parts = explode( '/', $_SERVER['REQUEST_URI'] );
     339        switch ( $parts[1] ) {
     340            case 'reference':
     341            case 'plugin':
     342            case 'theme':
     343                return home_url( '/' . $parts[1] . '/' );
     344            default:
     345                return home_url( '/' );
     346        }
     347    }
     348
     349    /**
     350     * Get site section title based on URL path.
    334351     *
    335352     * @return string
    336353     */
    337354    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 
    346355        $parts = explode( '/', $_SERVER['REQUEST_URI'] );
    347356        switch ( $parts[1] ) {
    348357            case 'reference':
    349358                return __( 'Code Reference', 'wporg' );
     359            case 'plugin':
     360                return __( 'Plugin Handbook', 'wporg' );
     361            case 'theme':
     362                return __( 'Theme Handbook', 'wporg' );
    350363            default:
    351364                return __( 'Developer Resources', 'wporg' );
Note: See TracChangeset for help on using the changeset viewer.