mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@48114 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -282,7 +282,9 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
|
||||
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' );
|
||||
} else {
|
||||
$elements = generate_postdata( $_post );
|
||||
|
||||
Reference in New Issue
Block a user