Opened 2 hours ago
Closed 2 hours ago
#49609 closed enhancement (invalid)
Minor code cleanup
| Reported by: |
|
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)
Change History (2)
Note: See
TracTickets for help on using
tickets.
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].