diff --git content-reference.php content-reference.php
index 43c9baf..75f2dac 100644
|
|
|
if ( ! empty( $since ) ) : ?>
|
| 25 | 25 | |
| 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:', 'wporg-developer' ); ?> </strong><a href="<?php echo get_source_file_link(); ?>"><?php echo esc_html( $source_file ); ?></a></p> |
| | 32 | <p><a href="<?php echo get_source_file_archive_link( $source_file ); ?>"><?php _e( 'More in this file.', 'wporg-developer' ); ?></a></p> |
| | 33 | </section> |
| 32 | 34 | <?php endif; ?> |
| 33 | 35 | |
| 34 | 36 | <?php /* if ( is_archive() ) : ?> |
diff --git content-wp-parser-hook.php content-wp-parser-hook.php
index 6a1bd9f..5ec99c2 100644
|
|
|
|
| 3 | 3 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
| 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(); ?> |
| 9 | 8 | </section> |
| … |
… |
|
| 24 | 23 | |
| 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:', 'wporg-developer' ); ?> </strong><a href="<?php echo get_source_file_link(); ?>"><?php echo esc_html( $source_file ); ?></a></p> |
| | 30 | <p><a href="<?php echo get_source_file_archive_link( $source_file ); ?>"><?php _e( 'More in this file.', 'wporg-developer' ); ?></a></p> |
| | 31 | </section> |
| 31 | 32 | <?php endif; ?> |
| 32 | 33 | |
| 33 | 34 | <?php /* if ( is_archive() ) : ?> |
diff --git inc/template-tags.php inc/template-tags.php
index b419f33..f02cb7a 100755
|
|
|
namespace DevHub {
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | | * Retrieve URL to source file archive |
| | 534 | * Retrieve URL to source file archive. |
| 535 | 535 | * |
| 536 | 536 | * @param string $name |
| 537 | 537 | * |
| 538 | 538 | * @return string |
| 539 | 539 | */ |
| 540 | | function get_source_file_link( $name = null ) { |
| | 540 | function get_source_file_archive_link( $name = null ) { |
| 541 | 541 | |
| 542 | 542 | $source_file_object = get_term_by( 'name', empty( $name ) ? get_source_file() : $name, 'wp-parser-source-file' ); |
| 543 | 543 | |
| … |
… |
namespace DevHub {
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | /** |
| | 562 | * Retrieve the URL to the actual source file and line. |
| | 563 | * |
| | 564 | * @param null $post_id Post ID. |
| | 565 | * @param bool $line_number Whether to append the line number to the URL. |
| | 566 | * Default true. |
| | 567 | * @return string Source file URL with or without line number. |
| | 568 | */ |
| | 569 | function get_source_file_link( $post_id = null, $line_number = true ) { |
| | 570 | $post_id = empty( $post_id ) ? get_the_ID() : $post_id; |
| | 571 | $url = ''; |
| | 572 | |
| | 573 | // Source file. |
| | 574 | $source_file = get_source_file( $post_id ); |
| | 575 | if ( ! empty( $source_file ) ) { |
| | 576 | $url = 'https://core.trac.wordpress.org/browser/trunk/src/' . $source_file; |
| | 577 | |
| | 578 | // Line number. |
| | 579 | if ( $line_number = get_post_meta( get_the_ID(), '_wp-parser_line_num', true ) ) { |
| | 580 | $url .= "#L{$line_number}"; |
| | 581 | } |
| | 582 | } |
| | 583 | return esc_url( $url ); |
| | 584 | } |
| | 585 | |
| | 586 | /** |
| 562 | 587 | * Compare two objects by name for sorting. |
| 563 | 588 | * |
| 564 | 589 | * @param WP_Post $a Post A |