Changeset 44941 for trunk/src/wp-includes/post-template.php
- Timestamp:
- 03/20/2019 03:48:46 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/post-template.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r44471 r44941 254 254 * 255 255 * @since 0.71 256 * @since 5.2.0 Added the `$post` parameter. 256 257 * 257 258 * @global int $page Page number of a single post/page. … … 262 263 * @global int $multipage Boolean indicator for whether multiple pages are in play. 263 264 * 264 * @param string $more_link_text Optional. Content for when there is more text. 265 * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. 265 * @param string $more_link_text Optional. Content for when there is more text. 266 * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. 267 * @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default is null. 266 268 * @return string 267 269 */ 268 function get_the_content( $more_link_text = null, $strip_teaser = false ) {270 function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) { 269 271 global $page, $more, $preview, $pages, $multipage; 270 272 271 $post = get_post(); 273 $_post = get_post( $post ); 274 275 if ( ! ( $_post instanceof WP_Post ) ) { 276 return ''; 277 } 278 279 if ( null === $post ) { 280 $elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' ); 281 } else { 282 $elements = generate_postdata( $_post ); 283 } 272 284 273 285 if ( null === $more_link_text ) { … … 277 289 /* translators: %s: Name of current post */ 278 290 __( 'Continue reading %s' ), 279 the_title_attribute( array( 'echo' => false ) ) 291 the_title_attribute( 292 array( 293 'echo' => false, 294 'post' => $_post, 295 ) 296 ) 280 297 ), 281 298 __( '(more…)' ) … … 287 304 288 305 // If post password required and it doesn't match the cookie. 289 if ( post_password_required( $post ) ) { 290 return get_the_password_form( $post ); 291 } 292 293 if ( $page > count( $pages ) ) { // if the requested page doesn't exist 294 $page = count( $pages ); // give them the highest numbered page that DOES exist 295 } 296 297 $content = $pages[ $page - 1 ]; 306 if ( post_password_required( $_post ) ) { 307 return get_the_password_form( $_post ); 308 } 309 310 if ( $elements['page'] > count( $elements['pages'] ) ) { // if the requested page doesn't exist 311 $elements['page'] = count( $elements['pages'] ); // give them the highest numbered page that DOES exist 312 } 313 314 $page_no = $elements['page']; 315 $content = $elements['pages'][ $page_no - 1 ]; 298 316 if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { 299 317 $content = explode( $matches[0], $content, 2 ); … … 307 325 } 308 326 309 if ( false !== strpos( $ post->post_content, '<!--noteaser-->' ) && ( ! $multipage || $page== 1 ) ) {327 if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || $elements['page'] == 1 ) ) { 310 328 $strip_teaser = true; 311 329 } … … 313 331 $teaser = $content[0]; 314 332 315 if ( $ more&& $strip_teaser && $has_teaser ) {333 if ( $elements['more'] && $strip_teaser && $has_teaser ) { 316 334 $teaser = ''; 317 335 } … … 320 338 321 339 if ( count( $content ) > 1 ) { 322 if ( $ more) {323 $output .= '<span id="more-' . $ post->ID . '"></span>' . $content[1];340 if ( $elements['more'] ) { 341 $output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1]; 324 342 } else { 325 343 if ( ! empty( $more_link_text ) ) { … … 333 351 * @param string $more_link_text Read More text. 334 352 */ 335 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( ) . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );353 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); 336 354 } 337 355 $output = force_balance_tags( $output );
Note: See TracChangeset
for help on using the changeset viewer.