Making WordPress.org


Ignore:
Timestamp:
07/24/2018 05:27:23 PM (8 years ago)
Author:
obenland
Message:

DevHub: Add short descriptions to Related section

Props keesiemeijer, kevinwhoffman.
Fixes #1847.

File:
1 edited

Legend:

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

    r5597 r7491  
    1414        $has_used_by = ( post_type_has_usage_info() && ( $used_by = get_used_by() ) && $used_by->have_posts() );
    1515
     16        $uses_to_show    = 5;
     17        $used_by_to_show = 5;
     18
    1619        if ( $has_uses || $has_used_by ) :
    1720        ?>
    … …  
    2326                        <article class="uses">
    2427                                <h3><?php _e( 'Uses', 'wporg' ); ?></h3>
    25                                 <ul>
    26                                         <?php
    27                                         $uses_to_show = 5;
    28                                         while ( $uses->have_posts() ) : $uses->the_post()
    29                                                 ?>
    30                                                 <li>
    31                                                         <span><?php echo esc_attr( get_source_file() ); ?>:</span>
    32                                                         <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( ! in_array( get_post_type(), array( 'wp-parser-class', 'wp-parser-hook' ) ) ) : ?>()<?php endif; ?></a>
    33                                                 </li>
    34                                         <?php endwhile; wp_reset_postdata(); ?>
    35                                         <?php if ( $uses->post_count > $uses_to_show ) : ?>
    36                                                 <a href="#" class="show-more"><?php
    37                                                         /* translators: %d: remaining 'uses' count */
    38                                                         printf( _n( 'Show %d more use', 'Show %d more uses', $uses->post_count - $uses_to_show, 'wporg' ),
    39                                                                 number_format_i18n( $uses->post_count - $uses_to_show )
    40                                                         );
    41                                                         ?></a>
    42                                                 <a href="#" class="hide-more"><?php _e( 'Hide more uses', 'wporg' ); ?></a>
    43                                         <?php endif; ?>
    44                                 </ul>
     28                                <table id="uses-table">
     29                                        <caption class="screen-reader-text"><?php esc_html_e( 'Uses', 'wporg' ); ?></caption>
     30                                        <thead>
     31                                                <tr>
     32                                                        <th><?php esc_html_e( 'Uses', 'wporg' ); ?></th>
     33                                                        <th class="related-desc"><?php esc_html_e( 'Description', 'wporg' ); ?></th>
     34                                                </tr>
     35                                        </thead>
     36                                        <tbody>
     37                                                <?php while ( $uses->have_posts() ) : $uses->the_post(); ?>
     38                                                <tr>
     39                                                        <td>
     40                                                                <span><?php echo esc_attr( get_source_file() ); ?>:</span>
     41                                                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( ! in_array( get_post_type(), array( 'wp-parser-class', 'wp-parser-hook' ), true ) ) : ?>()<?php endif; ?></a>
     42                                                        </td>
     43                                                        <td class="related-desc">
     44                                                                <?php echo get_summary(); ?>
     45                                                        </td>
     46                                                </tr>
     47                                                <?php endwhile; wp_reset_postdata(); ?>
     48                                        <tbody>
     49                                </table>
     50
     51                                <?php if ( $uses->post_count > $uses_to_show ) : ?>
     52                                <a href="#" class="show-more"><?php
     53                                        /* translators: %d: remaining 'uses' count */
     54                                        printf( _n( 'Show %d more use', 'Show %d more uses', $uses->post_count - $uses_to_show, 'wporg' ),
     55                                                number_format_i18n( $uses->post_count - $uses_to_show )
     56                                        );
     57                                        ?></a>
     58                                <a href="#" class="hide-more"><?php esc_html_e( 'Hide more uses', 'wporg' ); ?></a>
     59                                <?php endif; ?>
    4560                        </article>
    4661                <?php endif; ?>
    4762
    4863                <?php if ( $has_used_by ) : ?>
     64                        <?php if ( $has_uses && $uses->post_count > $uses_to_show ) : ?><hr /><?php endif; ?>
    4965
    50                 <?php if ( $has_uses ) { ?><hr /><?php } ?>
     66                        <article class="used-by">
     67                                <h3><?php esc_html_e( 'Used By', 'wporg' ); ?></h3>
     68                                <table id="used-by-table">
     69                                        <caption class="screen-reader-text"><?php esc_html_e( 'Used By', 'wporg' ); ?></caption>
     70                                        <thead>
     71                                                <tr>
     72                                                        <th><?php esc_html_e( 'Used By', 'wporg' ); ?></th>
     73                                                        <th class="related-desc"><?php esc_html_e( 'Description', 'wporg' ); ?></th>
     74                                                </tr>
     75                                        </thead>
     76                                        <tbody>
     77                                                <?php while ( $used_by->have_posts() ) : $used_by->the_post(); ?>
     78                                                <tr>
     79                                                        <td>
     80                                                                <span><?php echo esc_attr( get_source_file() ); ?>:</span>
     81                                                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( ! in_array( get_post_type(), array( 'wp-parser-class', 'wp-parser-hook' ), true ) ) : ?>()<?php endif; ?></a>
     82                                                        </td>
     83                                                        <td class="related-desc">
     84                                                                <?php echo get_summary(); ?>
     85                                                        </td>
     86                                                </tr>
     87                                                <?php endwhile; wp_reset_postdata(); ?>
     88                                        <tbody>
     89                                </table>
    5190
    52                 <article class="used-by">
    53                         <h3><?php _e( 'Used By', 'wporg' ); ?></h3>
    54                         <ul>
    55                                 <?php
    56                                 $used_by_to_show = 5;
    57                                 while ( $used_by->have_posts() ) : $used_by->the_post();
    58                                         ?>
    59                                         <li>
    60                                                 <span><?php echo esc_attr( get_source_file() ); ?>:</span>
    61                                                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( ! in_array( get_post_type(), array( 'wp-parser-class', 'wp-parser-hook' ) ) ) : ?>()<?php endif; ?></a>
    62                                         </li>
    63                                 <?php endwhile; wp_reset_postdata(); ?>
    6491                                <?php if ( $used_by->post_count > $used_by_to_show ) : ?>
    65                                         <a href="#" class="show-more"><?php
    66                                                 /* translators: %d: remaining 'used by' count */
    67                                                 printf( _n( 'Show %d more used by', 'Show %d more used by', $used_by->post_count - $used_by_to_show, 'wporg' ),
    68                                                         number_format_i18n( $used_by->post_count - $used_by_to_show )
    69                                                 );
    70                                                 ?></a>
    71                                         <a href="#" class="hide-more"><?php _e( 'Hide more used by', 'wporg' ); ?></a>
     92                                <a href="#" class="show-more"><?php
     93                                        /* translators: %d: remaining 'used by' count */
     94                                        printf( _n( 'Show %d more used by', 'Show %d more used by', $used_by->post_count - $used_by_to_show, 'wporg' ),
     95                                                number_format_i18n( $used_by->post_count - $used_by_to_show )
     96                                        );
     97                                        ?></a>
     98                                <a href="#" class="hide-more"><?php esc_html_e( 'Hide more used by', 'wporg' ); ?></a>
    7299                                <?php endif; ?>
    73                         </ul>
    74                 </article>
     100                        </article>
    75101                <?php endif; ?>
    76 
    77102        </section>
    78103        <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.