Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42228 r42343  
    1818 * @property-read int    $post_category
    1919 * @property-read string $tag_input
    20  *
    2120 */
    2221final class WP_Post {
     
    244243            $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) );
    245244
    246             if ( ! $_post )
     245            if ( ! $_post ) {
    247246                return false;
     247            }
    248248
    249249            $_post = sanitize_post( $_post, 'raw' );
     
    264264     */
    265265    public function __construct( $post ) {
    266         foreach ( get_object_vars( $post ) as $key => $value )
     266        foreach ( get_object_vars( $post ) as $key => $value ) {
    267267            $this->$key = $value;
     268        }
    268269    }
    269270
     
    277278     */
    278279    public function __isset( $key ) {
    279         if ( 'ancestors' == $key )
     280        if ( 'ancestors' == $key ) {
    280281            return true;
    281 
    282         if ( 'page_template' == $key )
     282        }
     283
     284        if ( 'page_template' == $key ) {
    283285            return true;
    284 
    285         if ( 'post_category' == $key )
     286        }
     287
     288        if ( 'post_category' == $key ) {
    286289            return true;
    287 
    288         if ( 'tags_input' == $key )
     290        }
     291
     292        if ( 'tags_input' == $key ) {
    289293            return true;
     294        }
    290295
    291296        return metadata_exists( 'post', $this->ID, $key );
     
    306311
    307312        if ( 'post_category' == $key ) {
    308             if ( is_object_in_taxonomy( $this->post_type, 'category' ) )
     313            if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) {
    309314                $terms = get_the_terms( $this, 'category' );
    310 
    311             if ( empty( $terms ) )
     315            }
     316
     317            if ( empty( $terms ) ) {
    312318                return array();
     319            }
    313320
    314321            return wp_list_pluck( $terms, 'term_id' );
     
    316323
    317324        if ( 'tags_input' == $key ) {
    318             if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) )
     325            if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) {
    319326                $terms = get_the_terms( $this, 'post_tag' );
    320 
    321             if ( empty( $terms ) )
     327            }
     328
     329            if ( empty( $terms ) ) {
    322330                return array();
     331            }
    323332
    324333            return wp_list_pluck( $terms, 'name' );
     
    326335
    327336        // Rest of the values need filtering.
    328         if ( 'ancestors' == $key )
     337        if ( 'ancestors' == $key ) {
    329338            $value = get_post_ancestors( $this );
    330         else
     339        } else {
    331340            $value = get_post_meta( $this->ID, $key, true );
    332 
    333         if ( $this->filter )
     341        }
     342
     343        if ( $this->filter ) {
    334344            $value = sanitize_post_field( $key, $value, $this->ID, $this->filter );
     345        }
    335346
    336347        return $value;
     
    346357     */
    347358    public function filter( $filter ) {
    348         if ( $this->filter == $filter )
     359        if ( $this->filter == $filter ) {
    349360            return $this;
    350 
    351         if ( $filter == 'raw' )
     361        }
     362
     363        if ( $filter == 'raw' ) {
    352364            return self::get_instance( $this->ID );
     365        }
    353366
    354367        return sanitize_post( $this, $filter );
     
    366379
    367380        foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) {
    368             if ( $this->__isset( $key ) )
     381            if ( $this->__isset( $key ) ) {
    369382                $post[ $key ] = $this->__get( $key );
     383            }
    370384        }
    371385
Note: See TracChangeset for help on using the changeset viewer.