[wp-trac] [WordPress Trac] #49609: Minor code cleanup

WordPress Trac noreply at wordpress.org
Mon Mar 9 16:10:28 UTC 2020


#49609: Minor code cleanup
-------------------------------+-----------------------------
 Reporter:  dontdream          |      Owner:  (none)
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  minor              |   Keywords:  has-patch
  Focuses:                     |
-------------------------------+-----------------------------
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49609>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list