Changeset 11311 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
- Timestamp:
- 11/04/2021 03:25:50 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r10000 r11311 1159 1159 * 1160 1160 * @param null $post_id Post ID. 1161 * @param bool $line_number Whether to append the line number to the URL.1162 * Default true.1163 1161 * @return string Source file URL with or without line number. 1164 1162 */ 1165 function get_source_file_link( $post_id = null , $line_number = true) {1163 function get_source_file_link( $post_id = null ) { 1166 1164 1167 1165 $post_id = empty( $post_id ) ? get_the_ID() : $post_id; … … 1175 1173 if ( $line_number = get_post_meta( get_the_ID(), '_wp-parser_line_num', true ) ) { 1176 1174 $url .= "#L{$line_number}"; 1175 } 1176 } 1177 1178 return esc_url( $url ); 1179 } 1180 1181 /** 1182 * Retrieve the URL to the GitHub source file and line. 1183 * 1184 * @param null $post_id Post ID. 1185 * @return string Source file URL with or without line number. 1186 */ 1187 function get_github_source_file_link( $post_id = null ) { 1188 1189 $post_id = empty( $post_id ) ? get_the_ID() : $post_id; 1190 $url = ''; 1191 1192 // Source file. 1193 $source_file = get_source_file( $post_id ); 1194 if ( ! empty( $source_file ) ) { 1195 $url = 'https://github.com/WordPress/wordpress-develop/blob/' . get_current_version() . '/src/' . $source_file; 1196 // Line number. 1197 if ( $line_number = get_post_meta( get_the_ID(), '_wp-parser_line_num', true ) ) { 1198 $url .= "#L{$line_number}"; 1199 if ( $end_line_number = get_post_meta( get_the_ID(), '_wp-parser_end_line_num', true ) ) { 1200 $url .= "-L{$end_line_number}"; 1201 } 1177 1202 } 1178 1203 }
Note: See TracChangeset
for help on using the changeset viewer.