Making WordPress.org


Ignore:
Timestamp:
12/12/2022 03:55:38 AM (20 months ago)
Author:
dd32
Message:

Plugin Directory: Simplify the 'sections' titles, as we don't need anything more than the title here.

This replaces [12315-12318] with simpler code, as the cause was a previous design choice interacting with unexpected data.

File:
1 edited

Legend:

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

    r12266 r12319  
    1313use WordPressdotorg\Plugin_Directory\Template;
    1414
    15 global $section, $section_slug, $section_content, $post;
     15global $section_slug, $section_title, $section_content, $post;
    1616
    1717$content   = Plugin_Directory::instance()->split_post_content_into_pages( get_the_content() );
     
    7979    <div class="entry-content">
    8080        <?php
    81         if ( get_query_var( 'plugin_advanced' ) ) :
     81        if ( get_query_var( 'plugin_advanced' ) ) {
    8282            get_template_part( 'template-parts/section-advanced' );
    83         else :
    84             $plugin_sections = Template::get_plugin_sections();
     83        } else {
     84            $plugin_sections_titles = Template::get_plugin_section_titles();
    8585
    86             foreach ( array( 'description', 'screenshots', 'blocks', 'installation', 'faq', 'reviews', 'developers', 'changelog' ) as $section_slug ) :
     86            foreach ( array( 'description', 'screenshots', 'blocks', 'installation', 'faq', 'reviews', 'developers', 'changelog' ) as $section_slug ) {
    8787                $section_content = '';
     88                $section_title   = $plugin_sections_titles[ $section_slug ] ?? '';
    8889
    89                 if ( 'description' === $section_slug && $is_closed ) {
     90                if ( $is_closed && in_array( $section_slug, [ 'screenshots', 'installation', 'faq', 'changelog' ], true ) ) {
     91                    // Don't show these sections when closed.
     92                    $section_content = '';
     93
     94                } elseif ( $is_closed && 'description' === $section_slug ) {
    9095                    // Don't show the description for closed plugins, show a notice instead.
    9196                    $section_content = get_closed_plugin_notice();
     
    9398                } elseif ( 'blocks' === $section_slug ) {
    9499                    $section_content = get_post_meta( get_the_ID(), 'all_blocks', true );
    95                 } elseif ( ! in_array( $section_slug, [ 'screenshots', 'installation', 'faq', 'changelog' ], true ) || ! $is_closed ) {
    96                     if ( isset( $content[ $section_slug ] ) ) {
    97                         $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) );
    98                     }
     100
     101                } elseif ( isset( $content[ $section_slug ] ) ) {
     102                    $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) );
    99103                }
    100104
     
    103107                }
    104108
    105                 $section = wp_list_filter( $plugin_sections, array( 'slug' => $section_slug ) );
    106                 $section = array_pop( $section );
    107 
    108                 if ( 'blocks' === $section_slug ) {
    109                     get_template_part( 'template-parts/section-blocks' );
    110                 } else {
    111                     get_template_part( 'template-parts/section' );
    112                 }
    113             endforeach;
    114         endif; // plugin_advanced.
     109                get_template_part( 'template-parts/section', $section_slug );
     110            }
     111        } // plugin_advanced.
    115112        ?>
    116113    </div><!-- .entry-content -->
Note: See TracChangeset for help on using the changeset viewer.