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-content/themes/twentyfourteen/inc/featured-content.php

    r36709 r42343  
    8484        }
    8585
    86         add_filter( $filter,                              array( __CLASS__, 'get_featured_posts' )    );
    87         add_action( 'customize_register',                 array( __CLASS__, 'customize_register' ), 9 );
    88         add_action( 'admin_init',                         array( __CLASS__, 'register_setting'   )    );
    89         add_action( 'switch_theme',                       array( __CLASS__, 'delete_transient'   )    );
    90         add_action( 'save_post',                          array( __CLASS__, 'delete_transient'   )    );
    91         add_action( 'delete_post_tag',                    array( __CLASS__, 'delete_post_tag'    )    );
    92         add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts'    )    );
    93         add_action( 'pre_get_posts',                      array( __CLASS__, 'pre_get_posts'      )    );
    94         add_action( 'wp_loaded',                          array( __CLASS__, 'wp_loaded'          )    );
     86        add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) );
     87        add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 );
     88        add_action( 'admin_init', array( __CLASS__, 'register_setting' ) );
     89        add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) );
     90        add_action( 'save_post', array( __CLASS__, 'delete_transient' ) );
     91        add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) );
     92        add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
     93        add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
     94        add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) );
    9595    }
    9696
     
    107107    public static function wp_loaded() {
    108108        if ( self::get_setting( 'hide-tag' ) ) {
    109             add_filter( 'get_terms',     array( __CLASS__, 'hide_featured_term'    ), 10, 3 );
     109            add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 );
    110110            add_filter( 'get_the_terms', array( __CLASS__, 'hide_the_featured_term' ), 10, 3 );
    111111        }
     
    129129        }
    130130
    131         $featured_posts = get_posts( array(
    132             'include'        => $post_ids,
    133             'posts_per_page' => count( $post_ids ),
    134         ) );
     131        $featured_posts = get_posts(
     132            array(
     133                'include'        => $post_ids,
     134                'posts_per_page' => count( $post_ids ),
     135            )
     136        );
    135137
    136138        return $featured_posts;
     
    161163            if ( $term ) {
    162164                // Query for featured posts.
    163                 $featured_ids = get_posts( array(
    164                     'fields'           => 'ids',
    165                     'numberposts'      => self::$max_posts,
    166                     'suppress_filters' => false,
    167                     'tax_query'        => array(
    168                         array(
    169                             'field'    => 'term_id',
    170                             'taxonomy' => 'post_tag',
    171                             'terms'    => $term->term_id,
     165                $featured_ids = get_posts(
     166                    array(
     167                        'fields'           => 'ids',
     168                        'numberposts'      => self::$max_posts,
     169                        'suppress_filters' => false,
     170                        'tax_query'        => array(
     171                            array(
     172                                'field'    => 'term_id',
     173                                'taxonomy' => 'post_tag',
     174                                'terms'    => $term->term_id,
     175                            ),
    172176                        ),
    173                     ),
    174                 ) );
     177                    )
     178                );
    175179            }
    176180
     
    284288
    285289        $settings['tag-id'] = 0;
    286         $settings = self::validate_settings( $settings );
     290        $settings           = self::validate_settings( $settings );
    287291        update_option( 'featured-content', $settings );
    288292    }
     
    400404     */
    401405    public static function customize_register( $wp_customize ) {
    402         $wp_customize->add_section( 'featured_content', array(
    403             'title'          => __( 'Featured Content', 'twentyfourteen' ),
    404             'description'    => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ),
    405                 esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ),
    406                 admin_url( 'edit.php?show_sticky=1' )
    407             ),
    408             'priority'       => 130,
    409             'theme_supports' => 'featured-content',
    410         ) );
     406        $wp_customize->add_section(
     407            'featured_content', array(
     408                'title'          => __( 'Featured Content', 'twentyfourteen' ),
     409                'description'    => sprintf(
     410                    __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ),
     411                    esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ),
     412                    admin_url( 'edit.php?show_sticky=1' )
     413                ),
     414                'priority'       => 130,
     415                'theme_supports' => 'featured-content',
     416            )
     417        );
    411418
    412419        // Add Featured Content settings.
    413         $wp_customize->add_setting( 'featured-content[tag-name]', array(
    414             'default'              => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ),
    415             'type'                 => 'option',
    416             'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
    417         ) );
    418         $wp_customize->add_setting( 'featured-content[hide-tag]', array(
    419             'default'              => true,
    420             'type'                 => 'option',
    421             'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
    422         ) );
     420        $wp_customize->add_setting(
     421            'featured-content[tag-name]', array(
     422                'default'              => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ),
     423                'type'                 => 'option',
     424                'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
     425            )
     426        );
     427        $wp_customize->add_setting(
     428            'featured-content[hide-tag]', array(
     429                'default'              => true,
     430                'type'                 => 'option',
     431                'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ),
     432            )
     433        );
    423434
    424435        // Add Featured Content controls.
    425         $wp_customize->add_control( 'featured-content[tag-name]', array(
    426             'label'    => __( 'Tag Name', 'twentyfourteen' ),
    427             'section'  => 'featured_content',
    428             'priority' => 20,
    429         ) );
    430         $wp_customize->add_control( 'featured-content[hide-tag]', array(
    431             'label'    => __( 'Don&rsquo;t display tag on front end.', 'twentyfourteen' ),
    432             'section'  => 'featured_content',
    433             'type'     => 'checkbox',
    434             'priority' => 30,
    435         ) );
     436        $wp_customize->add_control(
     437            'featured-content[tag-name]', array(
     438                'label'    => __( 'Tag Name', 'twentyfourteen' ),
     439                'section'  => 'featured_content',
     440                'priority' => 20,
     441            )
     442        );
     443        $wp_customize->add_control(
     444            'featured-content[hide-tag]', array(
     445                'label'    => __( 'Don&rsquo;t display tag on front end.', 'twentyfourteen' ),
     446                'section'  => 'featured_content',
     447                'type'     => 'checkbox',
     448                'priority' => 30,
     449            )
     450        );
    436451    }
    437452
Note: See TracChangeset for help on using the changeset viewer.