Making WordPress.org


Ignore:
Timestamp:
07/06/2016 07:16:58 PM (8 years ago)
Author:
drewapicture
Message:

developer.wordpress.org: Restructure reference pages to leverage a table of contents for the majority of the page output.

  • Splits large sections of content-reference.php into individual template parts captured via output buffering.
  • Introduces four top-level sections for any given reference page: Description, More Information (if an explanation exists), Related, and User Contributed Notes
  • Improves overall responsive styling for smaller viewports

See #1802.

File:
1 edited

Legend:

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

    r3563 r3626  
    550550            $delimiter = false !== strpos( $signature, '$' ) ? '"' : "'";
    551551            $signature = $delimiter . $signature . $delimiter;
    552             $signature = '<span class="hook-func">' . $hook_type . '</span> ( ' . $signature;
     552            $signature = '<span class="hook-func">' . $hook_type . '</span>( ' . $signature;
    553553            if ( $hook_args ) {
    554554                $signature .= ', ';
     
    580580        }
    581581
    582         $signature .= ' (';
     582        $signature .= '(';
    583583        if ( $args = implode( ', ', $args_strings ) ) {
    584584            $signature .= $args . '&nbsp;';
     
    13211321        $post_field = get_post_field( $field, $explanation, $context );
    13221322
    1323         // If retrieving the explanation content for display, add the TOC if available.
    1324         if ( 'post_content' === $field && 'display' === $context ) {
    1325             if ( class_exists( 'WPorg_Handbook_TOC' ) ) :
    1326                 $TOC = new \WPorg_Handbook_TOC( get_parsed_post_types() );
    1327 
    1328                 add_filter( 'the_content', array( $TOC, 'add_toc' ) );
    1329                 $post_field = apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) );
    1330                 remove_filter( 'the_content', array( $TOC, 'add_toc' ) );
    1331             else :
    1332                 $post_field = apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) );
    1333             endif;
    1334         }
    1335 
    1336         return $post_field;
     1323        return apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) );
    13371324    }
    13381325
     
    14401427        echo $form;
    14411428    }
     1429
     1430    /**
     1431     * Retrieves all content for reference template parts.
     1432     *
     1433     * @return string Template part markup retrieved via output buffering.
     1434     */
     1435    function get_reference_template_parts() {
     1436        // Order dictates order of display.
     1437        $templates = array(
     1438            'description',
     1439            'params',
     1440            'return',
     1441            'source',
     1442            'changelog',
     1443            'explanation',
     1444            'related',
     1445            'methods',
     1446            'notes'
     1447        );
     1448
     1449        ob_start();
     1450
     1451        foreach ( $templates as $part ) {
     1452            get_template_part( 'reference/template', $part );
     1453        }
     1454
     1455        return ob_get_clean();
     1456    }
    14421457}
    1443 
Note: See TracChangeset for help on using the changeset viewer.