WordPress.org

Make WordPress Core

Opened 2 hours ago

Closed 2 hours ago

#49609 closed enhancement (invalid)

Minor code cleanup

Reported by: dontdream Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

In the initial lines of get_the_content():

function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
	global $page, $more, $preview, $pages, $multipage;

	$_post = get_post( $post );

	if ( ! ( $_post instanceof WP_Post ) ) {
		return '';
	}

	if ( null === $post ) {
		$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
	} else {
		$elements = generate_postdata( $_post );
	}

when the $post argument is null, two cases are possible:

1) get_post() finds a post
2) get_post() doesn't find a post

In case 2) get_the_content() will immediately return, so the remaining lines to set $elements can be simplified for clarity.

	$elements = generate_postdata( $_post );

See the attached patch.

Attachments (1)

49609.diff (1.7 KB) - added by dontdream 2 hours ago.

Download all attachments as: .zip

Change History (2)

@dontdream
2 hours ago

#1 @ocean90
2 hours ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This seems to be same as you have previously submitted in #49591.

Note that there are two similar named variables, $_post (with underscore) and $post. Depending on the context they are not the same. This was introduced in [44941].

Note: See TracTickets for help on using tickets.