Posts, Post Types: Avoid a PHP warning when `get_the_content()` is called outside of the loop.
This ensures that `$pages` and other globals are only used after they have been set up in `setup_postdata()`. Follow-up to [44941]. Props tessawatkinsllc, dontdream, spacedmonkey, squarecandy, davidbaumwald, SergeyBiryukov. Fixes #47824. See #42814. Built from https://develop.svn.wordpress.org/trunk@48114 git-svn-id: http://core.svn.wordpress.org/trunk@47883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
08d4e7dd69
commit
e0d440f77f
|
@ -4275,7 +4275,7 @@ class WP_Query {
|
||||||
$numpages = $elements['numpages'];
|
$numpages = $elements['numpages'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires once the post data has been setup.
|
* Fires once the post data has been set up.
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
* @since 4.1.0 Introduced `$this` parameter.
|
* @since 4.1.0 Introduced `$this` parameter.
|
||||||
|
|
|
@ -282,7 +282,9 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( null === $post ) {
|
// Use the globals if the $post parameter was not specified,
|
||||||
|
// but only after they have been set up in setup_postdata().
|
||||||
|
if ( null === $post && did_action( 'the_post' ) ) {
|
||||||
$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
|
$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
|
||||||
} else {
|
} else {
|
||||||
$elements = generate_postdata( $_post );
|
$elements = generate_postdata( $_post );
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-48113';
|
$wp_version = '5.5-alpha-48114';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue