Making WordPress.org


Ignore:
Timestamp:
11/24/2016 01:38:06 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Clean up the section templates, bring some custom functionality into their respective shortcodes and shifting the read-more logic from CSS/JS to PHP/HTML.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php

    r4335 r4410  
    1212use WordPressdotorg\Plugin_Directory\Template;
    1313use WordPressdotorg\Plugin_Directory\Tools;
    14 global $section, $section_slug, $section_content;
     14global $section, $section_slug, $section_content, $section_read_more;
    1515
    1616$content = Plugin_Directory::instance()->split_post_content_into_pages( get_the_content() );
     
    114114        <?php
    115115        if ( get_query_var( 'plugin_admin' ) ) :
    116             get_template_part( 'template-parts/section', 'admin' );
     116            get_template_part( 'template-parts/section-admin' );
    117117        else:
    118118            $plugin_sections = Template::get_plugin_sections();
    119119
    120120            foreach ( array( 'description', 'screenshots', 'faq', 'reviews', 'changelog', 'developers' ) as $section_slug ) :
    121                 if ( ! array_key_exists( $section_slug, $content ) || in_array( $section_slug, array( 'installation', 'other_notes' ) ) ) :
     121                if ( ! isset( $content[ $section_slug ] ) ) {
    122122                    continue;
    123                 endif;
     123                }
    124124
    125125                $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) );
    126                 if ( empty( $section_content ) ) :
     126                if ( empty( $section_content ) ) {
    127127                    continue;
    128                 endif;
     128                }
    129129
    130130                $section = wp_list_filter( $plugin_sections, array( 'slug' => $section_slug ) );
    131131                $section = array_pop( $section );
    132132
    133                 get_template_part( 'template-parts/section', $section_slug );
     133                $section_no_read_mores = array( 'screenshots', 'reviews' );
     134                // If the FAQ section is the newer `<dl>` form, no need to do read-more for it.
     135                if ( false !== stripos( $section_content, '<dl>' ) ) {
     136                    $section_no_read_mores[] = 'faq';
     137                }
     138               
     139                $section_read_more = ! in_array( $section_slug, $section_no_read_mores );
     140
     141                get_template_part( 'template-parts/section' );
    134142            endforeach;
    135143        endif; // plugin_admin
Note: See TracChangeset for help on using the changeset viewer.