Make WordPress Core


Ignore:
Timestamp:
10/02/2020 12:35:34 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Make checks for an empty post in wp-includes/post.php more consistent.

See #50767.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r49084 r49086  
    31913191         */
    31923192        $check = apply_filters( 'pre_trash_post', null, $post );
     3193
    31933194        if ( null !== $check ) {
    31943195                return $check;
     
    33173318
    33183319        $post = get_post( $post );
    3319         if ( empty( $post ) ) {
     3320
     3321        if ( ! $post ) {
    33203322                return;
    33213323        }
     
    33333335
    33343336        $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
    3335         if ( empty( $comments ) ) {
     3337
     3338        if ( ! $comments ) {
    33363339                return;
    33373340        }
     
    33763379
    33773380        $post = get_post( $post );
    3378         if ( empty( $post ) ) {
     3381
     3382        if ( ! $post ) {
    33793383                return;
    33803384        }
     
    33843388        $statuses = get_post_meta( $post_id, '_wp_trash_meta_comments_status', true );
    33853389
    3386         if ( empty( $statuses ) ) {
     3390        if ( ! $statuses ) {
    33873391                return true;
    33883392        }
     
    43714375
    43724376        $post = get_post( $post );
     4377
    43734378        if ( ! $post ) {
    43744379                return;
     
    44434448        $post = get_post( $post_id );
    44444449
    4445         if ( empty( $post ) ) {
     4450        if ( ! $post ) {
    44464451                return;
    44474452        }
     
    48984903
    48994904        $post = get_post( $post_id );
     4905
    49004906        if ( ! $post ) {
    49014907                return false;
     
    49744980function get_pung( $post_id ) {
    49754981        $post = get_post( $post_id );
     4982
    49764983        if ( ! $post ) {
    49774984                return false;
     
    59956002        $data = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
    59966003
    5997         if ( empty( $data ) ) {
     6004        if ( ! $data ) {
    59986005                return false;
    59996006        }
     
    60286035
    60296036        $post = get_post( $attachment_id );
     6037
    60306038        if ( ! $post ) {
    60316039                return false;
     
    60626070
    60636071        $post = get_post( $attachment_id );
     6072
    60646073        if ( ! $post ) {
    60656074                return false;
     
    60956104         * not recommended to rely upon this.
    60966105         */
    6097         if ( empty( $url ) ) {
     6106        if ( ! $url ) {
    60986107                $url = get_the_guid( $post->ID );
    60996108        }
     
    61146123        $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
    61156124
    6116         if ( empty( $url ) ) {
     6125        if ( ! $url ) {
    61176126                return false;
    61186127        }
     
    61326141        $post_id = (int) $post_id;
    61336142        $post    = get_post( $post_id );
     6143
    61346144        if ( ! $post ) {
    61356145                return false;
     
    61646174        $post_id = (int) $post_id;
    61656175        $post    = get_post( $post_id );
     6176
    61666177        if ( ! $post ) {
    61676178                return false;
     
    62036214        $post_id = (int) $post_id;
    62046215        $post    = get_post( $post_id );
     6216
    62056217        if ( ! $post ) {
    62066218                return false;
     
    62466258function wp_attachment_is( $type, $post = null ) {
    62476259        $post = get_post( $post );
     6260
    62486261        if ( ! $post ) {
    62496262                return false;
     
    62516264
    62526265        $file = get_attached_file( $post->ID );
     6266
    62536267        if ( ! $file ) {
    62546268                return false;
     
    62606274
    62616275        $check = wp_check_filetype( $file );
     6276
    62626277        if ( empty( $check['ext'] ) ) {
    62636278                return false;
     
    68306845
    68316846        $post = get_post( $post );
    6832         if ( empty( $post ) ) {
     6847
     6848        if ( ! $post ) {
    68336849                return;
    68346850        }
     
    71277143
    71287144        // New post can't cause a loop.
    7129         if ( empty( $post_ID ) ) {
     7145        if ( ! $post_ID ) {
    71307146                return $post_parent;
    71317147        }
     
    74767492        $image_url = wp_get_attachment_url( $attachment_id );
    74777493
    7478         if ( empty( $image_url ) ) {
     7494        if ( ! $image_url ) {
    74797495                return false;
    74807496        }
Note: See TracChangeset for help on using the changeset viewer.