Ticket #653: 653.diff
File 653.diff, 3.5 KB (added by , 5 years ago) |
---|
-
content-reference.php
16 16 <section class="return"><p><strong>Return:</strong> <?php echo get_return(); ?></p></section> 17 17 18 18 <?php 19 $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; ?> 19 $changelog_data = get_changelog_data(); 20 if ( ! empty( $changelog_data ) ) : 21 ?> 22 <section class="changelog"> 23 <h4><?php _e( 'Changelog', 'wporg' ); ?></h4> 24 <ul> 25 <?php foreach ( $changelog_data as $version => $data ) : ?> 26 <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> 27 <?php endforeach; ?> 28 </ul> 29 </section> 30 <?php endif; 25 31 26 <?php27 32 $source_file = get_source_file(); 28 33 if ( ! empty( $source_file ) ) : 29 34 ?> -
inc/template-tags.php
591 591 } 592 592 593 593 /** 594 * Retrieve URL to since version archive594 * Retrieve changelog data for the current post. 595 595 * 596 * @param string $name596 * @param null $post_id Post ID, defaults to the ID of the global $post. 597 597 * 598 * @return string598 * @return array Associative array of changelog data. 599 599 */ 600 function get_since_link( $name = null ) { 600 function get_changelog_data( $post_id = null ) { 601 $post_id = empty( $post_id ) ? get_the_ID() : $post_id; 601 602 602 $since_object = get_term_by( 'name', empty( $name ) ? get_since() : $name, 'wp-parser-since' ); 603 // Since terms assigned to the post. 604 $since_terms = wp_get_post_terms( $post_id, 'wp-parser-since' ); 603 605 604 return empty( $since_object ) ? '' : esc_url( get_term_link( $since_object ) ); 606 // Since data stored in meta. 607 $since_meta = get_post_meta( $post_id, '_wp-parser_tags', true ); 608 609 $data = array(); 610 611 // Pair the term data with meta data. 612 foreach ( $since_terms as $since_term ) { 613 foreach ( $since_meta as $meta ) { 614 if ( $since_term->name == $meta['content'] ) { 615 $description = empty( $meta['description'] ) ? '' : '<span class="since-description">' . esc_html( $meta['description'] ) . '</span>'; 616 617 $data[ $since_term->name ] = array( 618 'version' => $since_term->name, 619 'description' => $description, 620 'since_url' => get_term_link( $since_term ) 621 ); 622 } 623 } 624 } 625 return $data; 605 626 } 606 627 607 628 /** 608 * Retrieve name of since version629 * Retrieve URL to a since version archive. 609 630 * 610 * @param int $post_id631 * @param string $name Since version, e.g. 'x.x.x'. 611 632 * 612 * @return string 633 * @return string Since term archive URL. 613 634 */ 614 function get_since ( $post_id= null ) {635 function get_since_link( $name = null ) { 615 636 616 $since_object = wp_get_post_terms( empty( $post_id ) ? get_the_ID() : $post_id, 'wp-parser-since', array( 'fields' => 'names' ));637 $since_object = get_term_by( 'name', empty( $name ) ? get_since() : $name, 'wp-parser-since' ); 617 638 618 return empty( $since_object ) ? '' : esc_ html( $since_object[0]);639 return empty( $since_object ) ? '' : esc_url( get_term_link( $since_object ) ); 619 640 } 620 641 621 642 /**