Changeset 938
- Timestamp:
- 10/26/2014 11:40:46 PM (10 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference.php
r874 r938 15 15 </section> 16 16 <section class="return"><p><strong>Return:</strong> <?php echo get_return(); ?></p></section> 17 18 <?php19 $since = get_since();20 if ( ! empty( $since ) ) : ?>21 <section class="since">22 <p><strong>Since:</strong> WordPress <a href="<?php echo get_since_link( $since ); ?>"><?php echo esc_html( $since ); ?></a></p>23 </section>24 <?php endif; ?>25 17 26 18 <?php … … 150 142 <?php endif; ?> 151 143 144 <?php 145 $changelog_data = get_changelog_data(); 146 if ( ! empty( $changelog_data ) ) : 147 ?> 148 <hr/> 149 <section class="changelog"> 150 <h2><?php _e( 'Changelog', 'wporg' ); ?></h2> 151 <ul> 152 <?php foreach ( $changelog_data as $version => $data ) : ?> 153 <li><?php _e( '<strong>Since:</strong> WordPress', 'wporg' ); ?> <a href="<?php echo esc_url( $data['since_url'] ); ?>"><?php echo esc_html( $version ); ?></a> <?php echo $data['description']; // escaped in get_changelog_data() ?></li> 154 <?php endforeach; ?> 155 </ul> 156 </section> 157 <?php endif; ?> 158 152 159 <?php if ( comments_open() || '0' != get_comments_number() ) : ?> 153 160 <hr/> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r936 r938 671 671 672 672 /** 673 * Retrieve URL to since version archive 674 * 675 * @param string $name 676 * 677 * @return string 673 * Retrieve changelog data for the current post. 674 * 675 * @param null $post_id Post ID, defaults to the ID of the global $post. 676 * 677 * @return array Associative array of changelog data. 678 */ 679 function get_changelog_data( $post_id = null ) { 680 $post_id = empty( $post_id ) ? get_the_ID() : $post_id; 681 682 // Since terms assigned to the post. 683 $since_terms = wp_get_post_terms( $post_id, 'wp-parser-since' ); 684 685 // Since data stored in meta. 686 $since_meta = get_post_meta( $post_id, '_wp-parser_tags', true ); 687 688 $data = array(); 689 690 // Pair the term data with meta data. 691 foreach ( $since_terms as $since_term ) { 692 foreach ( $since_meta as $meta ) { 693 if ( $since_term->name == $meta['content'] ) { 694 $description = empty( $meta['description'] ) ? '' : '<span class="since-description">' . esc_html( $meta['description'] ) . '</span>'; 695 696 $data[ $since_term->name ] = array( 697 'version' => $since_term->name, 698 'description' => $description, 699 'since_url' => get_term_link( $since_term ) 700 ); 701 } 702 } 703 } 704 return $data; 705 } 706 707 /** 708 * Retrieve URL to a since version archive. 709 * 710 * @param string $name Since version, e.g. 'x.x.x'. 711 * 712 * @return string Since term archive URL. 678 713 */ 679 714 function get_since_link( $name = null ) { … … 682 717 683 718 return empty( $since_object ) ? '' : esc_url( get_term_link( $since_object ) ); 684 }685 686 /**687 * Retrieve name of since version688 *689 * @param int $post_id690 *691 * @return string692 */693 function get_since( $post_id = null ) {694 695 $since_object = wp_get_post_terms( empty( $post_id ) ? get_the_ID() : $post_id, 'wp-parser-since', array( 'fields' => 'names' ) );696 697 return empty( $since_object ) ? '' : esc_html( $since_object[0] );698 719 } 699 720
Note: See TracChangeset
for help on using the changeset viewer.