[wp-trac] [WordPress Trac] #49609: Minor code cleanup
WordPress Trac
noreply at wordpress.org
Tue Mar 10 14:02:58 UTC 2020
#49609: Minor code cleanup
-------------------------------+-----------------------
Reporter: dontdream | Owner: (none)
Type: enhancement | Status: reopened
Priority: normal | Milestone:
Component: Posts, Post Types | Version:
Severity: minor | Resolution:
Keywords: has-patch | Focuses:
-------------------------------+-----------------------
Changes (by dontdream):
* status: closed => reopened
* resolution: invalid =>
Comment:
Hi ocean90,
Yes, the patch is practically the same but my explanation in #49591 was
wrong, so I closed that ticket and submitted a new one - sorry for the
confusion!
To rephrase my explanation above, let's focus on the lines:
{{{
1 if ( ! ( $_post instanceof WP_Post ) ) {
2 return '';
3 }
4
5 if ( null === $post ) {
6 $elements = compact( 'page', 'more', 'preview', 'pages',
'multipage' );
7 } else {
8 $elements = generate_postdata( $_post );
9 }
}}}
When the `$post` argument is null (line 5) the `$_post` instance (coming
from the `global $post`) is also available (otherwise `get_the_content()`
returns, line 2), so it's not necessary to build the `$elements` array
with `compact()`, we can use `generate_postdata( $_post )` as well.
Reopening this ticket for further consideration. Thank you!
Andrea
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49609#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list