Making WordPress.org

Changeset 3811


Ignore:
Timestamp:
08/15/2016 07:52:04 PM (10 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Don't show the 'Related' section, or either the 'Uses' or the 'Used By' subsections, if nothing would be listed.

Fixes #1907.

File:
1 edited

Legend:

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

    r3809 r3811  
    1010
    1111if ( show_usage_info() ) :
     12
     13        $has_uses    = ( post_type_has_uses_info()  && ( $uses    = get_uses()    ) && $uses->have_posts()    );
     14        $has_used_by = ( post_type_has_usage_info() && ( $used_by = get_used_by() ) && $used_by->have_posts() );
     15
     16        if ( $has_uses || $has_used_by ) :
    1217        ?>
    1318        <hr />
     
    1520                <h2><?php _e( 'Related', 'wporg' ); ?></h2>
    1621
    17                 <?php if ( post_type_has_uses_info() ) : ?>
     22                <?php if ( $has_uses ) : ?>
    1823                        <article class="uses">
    1924                                <h3><?php _e( 'Uses', 'wporg' ); ?></h3>
    2025                                <ul>
    2126                                        <?php
    22                                         $uses = get_uses();
    2327                                        $uses_to_show = 5;
    24                                         if ( $uses ) : while ( $uses->have_posts() ) : $uses->the_post()
     28                                        while ( $uses->have_posts() ) : $uses->the_post()
    2529                                                ?>
    2630                                                <li>
     
    3741                                                        ?></a>
    3842                                                <a href="#" class="hide-more"><?php _e( 'Hide more uses', 'wporg' ); ?></a>
    39                                         <?php endif; endif; ?>
     43                                        <?php endif; ?>
    4044                                </ul>
    4145                        </article>
    4246                <?php endif; ?>
    4347
    44                 <hr />
     48                <?php if ( $has_used_by ) : ?>
     49
     50                <?php if ( $has_uses ) { ?><hr /><?php } ?>
     51
    4552                <article class="used-by">
    4653                        <h3><?php _e( 'Used By', 'wporg' ); ?></h3>
    4754                        <ul>
    4855                                <?php
    49                                 $used_by = get_used_by();
    5056                                $used_by_to_show = 5;
    5157                                while ( $used_by->have_posts() ) : $used_by->the_post();
     
    6773                        </ul>
    6874                </article>
     75                <?php endif; ?>
     76
    6977        </section>
     78        <?php endif; ?>
    7079<?php endif; ?>
    71 
Note: See TracChangeset for help on using the changeset viewer.