Changeset 639
- Timestamp:
- 05/23/2014 05:58:19 AM (10 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-reference.php
r591 r639 26 26 <?php 27 27 $source_file = get_source_file(); 28 if ( ! empty( $source_file ) ) : ?> 29 <section class="source"> 30 <p><strong><?php _e( 'Source:', 'wporg' ); ?></strong> <a href="<?php echo get_source_file_link( $source_file ); ?>"><?php echo esc_html( $source_file ); ?></a></p> 31 </section> 28 if ( ! empty( $source_file ) ) : 29 ?> 30 <section class="source"> 31 <p><strong><?php _e( 'Source file:', 'wporg' ); ?> </strong><a href="<?php echo get_source_file_archive_link( $source_file ); ?>"><?php echo esc_html( $source_file ); ?></a></p> 32 <p><a href="<?php echo get_source_file_link(); ?>"><?php _e( 'View source…', 'wporg' ); ?></a></p> 33 </section> 32 34 <?php endif; ?> 33 35 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/content-wp-parser-hook.php
r561 r639 4 4 5 5 <h1><a href="<?php the_permalink() ?>"><?php echo get_signature(); ?></a></h1> 6 7 6 <section class="description"> 8 7 <?php the_excerpt(); ?> … … 25 24 <?php 26 25 $source_file = get_source_file(); 27 if ( ! empty( $source_file ) ) : ?> 28 <section class="source"> 29 <p><strong><?php _e( 'Source:', 'wporg' ); ?></strong> <a href="<?php echo get_source_file_link( $source_file ); ?>"><?php echo esc_html( $source_file ); ?></a></p> 30 </section> 26 if ( ! empty( $source_file ) ) : 27 ?> 28 <section class="source"> 29 <p><strong><?php _e( 'Source file:', 'wporg' ); ?> </strong><a href="<?php echo get_source_file_archive_link( $source_file ); ?>"><?php echo esc_html( $source_file ); ?></a></p> 30 <p><a href="<?php echo get_source_file_link(); ?>"><?php _e( 'View source…', 'wporg' ); ?></a></p> 31 </section> 31 32 <?php endif; ?> 32 33 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r638 r639 558 558 559 559 /** 560 * Retrieve URL to source file archive 560 * Retrieve URL to source file archive. 561 561 * 562 562 * @param string $name … … 564 564 * @return string 565 565 */ 566 function get_source_file_ link( $name = null ) {566 function get_source_file_archive_link( $name = null ) { 567 567 568 568 $source_file_object = get_term_by( 'name', empty( $name ) ? get_source_file() : $name, 'wp-parser-source-file' ); … … 583 583 584 584 return empty( $source_file_object ) ? '' : esc_html( $source_file_object[0] ); 585 } 586 587 /** 588 * Retrieve the URL to the actual source file and line. 589 * 590 * @param null $post_id Post ID. 591 * @param bool $line_number Whether to append the line number to the URL. 592 * Default true. 593 * @return string Source file URL with or without line number. 594 */ 595 function get_source_file_link( $post_id = null, $line_number = true ) { 596 597 $post_id = empty( $post_id ) ? get_the_ID() : $post_id; 598 $url = ''; 599 600 // Source file. 601 $source_file = get_source_file( $post_id ); 602 if ( ! empty( $source_file ) ) { 603 $url = 'https://core.trac.wordpress.org/browser/tags/' . get_current_version() . '/src/' . $source_file; 604 // Line number. 605 if ( $line_number = get_post_meta( get_the_ID(), '_wp-parser_line_num', true ) ) { 606 $url .= "#L{$line_number}"; 607 } 608 } 609 610 return esc_url( $url ); 585 611 } 586 612
Note: See TracChangeset
for help on using the changeset viewer.