Making WordPress.org


Ignore:
Timestamp:
01/27/2015 12:39:51 AM (10 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Add 'Used By' and 'Uses' sections to parsed content permalink pages.

Basically the UI surfacing of the P2P relationships.

Fixes #323.
Props atimmer.

File:
1 edited

Legend:

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

    r1104 r1196  
    4444        </section>
    4545    <?php endif; ?>
    46 
    47     <?php /*
    48     <?php if ( is_archive() ) : ?>
    49     <section class="meta">Used by TODO | Uses TODO | TODO Examples</section>
    50     <?php endif; ?>
    51     */ ?>
    5246
    5347    <?php if ( $params = get_params() ) : ?>
     
    130124    endif; ?>
    131125
     126    <?php if ( show_usage_info() ) : ?>
     127        <hr id="usage" />
     128        <section class="usage">
     129            <article class="used-by">
     130                <h2><?php _e( 'Used by', 'wporg' ); ?></h2>
     131                <ul>
     132                    <?php
     133                        $used_by = get_used_by();
     134                        while ( $used_by->have_posts() ) : $used_by->the_post();
     135                            ?>
     136                            <li>
     137                                <span><?php echo esc_attr( get_source_file() ); ?>:</span>
     138                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( 'wp-parser-hook' !== get_post_type() ) : ?>()<?php endif; ?></a>
     139                            </li>
     140                        <?php endwhile; wp_reset_postdata(); ?>
     141                        <?php if ( $used_by->post_count > 5 ) : ?>
     142                            <a href="#" class="show-more"><?php printf( _n( 'Show 1 more used by', 'Show %d more used by', $used_by->post_count, 'wporg' ), $used_by->post_count ); ?></a>
     143                            <a href="#" class="hide-more"><?php _e( 'Hide more used by', 'wporg' ); ?></a>
     144                        <?php endif; ?>
     145                </ul>
     146            </article>
     147            <?php if ( post_type_has_uses_info() ) : ?>
     148                <article class="uses">
     149                    <h2><?php _e( 'Uses', 'wporg' ); ?></h2>
     150                    <ul>
     151                        <?php
     152                        $uses = get_uses();
     153                        while ( $uses->have_posts() ) : $uses->the_post()
     154                            ?>
     155                            <li>
     156                                <span><?php echo esc_attr( get_source_file() ); ?>:</span>
     157                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( 'wp-parser-hook' !== get_post_type() ) : ?>()<?php endif; ?></a>
     158                            </li>
     159                        <?php endwhile; wp_reset_postdata(); ?>
     160                        <?php if ( $uses->post_count > 5 ) : ?>
     161                            <a href="#" class="show-more"><?php printf( _n( 'Show 1 more use', 'Show %d more uses', $uses->post_count, 'wporg' ), $uses->post_count ); ?></a>
     162                            <a href="#" class="hide-more"><?php _e( 'Hide more uses', 'wporg' ); ?></a>
     163                        <?php endif; ?>
     164                    </ul>
     165                </article>
     166            <?php endif; ?>
     167        </section>
     168    <?php endif; ?>
     169
    132170    <?php if ( post_type_has_source_code() ) : ?>
    133171        <hr />
Note: See TracChangeset for help on using the changeset viewer.