WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (4 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/widgets/class-wp-widget-categories.php

    r41867 r42343  
    2424    public function __construct() {
    2525        $widget_ops = array(
    26             'classname' => 'widget_categories',
    27             'description' => __( 'A list or dropdown of categories.' ),
     26            'classname'                   => 'widget_categories',
     27            'description'                 => __( 'A list or dropdown of categories.' ),
    2828            'customize_selective_refresh' => true,
    2929        );
     
    6868        if ( $d ) {
    6969            echo sprintf( '<form action="%s" method="get">', esc_url( home_url() ) );
    70             $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
     70            $dropdown_id    = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
    7171            $first_dropdown = false;
    7272
     
    7474
    7575            $cat_args['show_option_none'] = __( 'Select Category' );
    76             $cat_args['id'] = $dropdown_id;
     76            $cat_args['id']               = $dropdown_id;
    7777
    7878            /**
     
    142142     */
    143143    public function update( $new_instance, $old_instance ) {
    144         $instance = $old_instance;
    145         $instance['title'] = sanitize_text_field( $new_instance['title'] );
    146         $instance['count'] = !empty($new_instance['count']) ? 1 : 0;
    147         $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
    148         $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
     144        $instance                 = $old_instance;
     145        $instance['title']        = sanitize_text_field( $new_instance['title'] );
     146        $instance['count']        = ! empty( $new_instance['count'] ) ? 1 : 0;
     147        $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0;
     148        $instance['dropdown']     = ! empty( $new_instance['dropdown'] ) ? 1 : 0;
    149149
    150150        return $instance;
     
    160160    public function form( $instance ) {
    161161        //Defaults
    162         $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
    163         $title = sanitize_text_field( $instance['title'] );
    164         $count = isset($instance['count']) ? (bool) $instance['count'] :false;
     162        $instance     = wp_parse_args( (array) $instance, array( 'title' => '' ) );
     163        $title        = sanitize_text_field( $instance['title'] );
     164        $count        = isset( $instance['count'] ) ? (bool) $instance['count'] : false;
    165165        $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
    166         $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
     166        $dropdown     = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
    167167        ?>
    168         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
    169         <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
     168        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
     169        <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    170170
    171         <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
    172         <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
     171        <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'dropdown' ); ?>" name="<?php echo $this->get_field_name( 'dropdown' ); ?>"<?php checked( $dropdown ); ?> />
     172        <label for="<?php echo $this->get_field_id( 'dropdown' ); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
    173173
    174         <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
    175         <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
     174        <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>"<?php checked( $count ); ?> />
     175        <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Show post counts' ); ?></label><br />
    176176
    177         <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
    178         <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
     177        <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'hierarchical' ); ?>" name="<?php echo $this->get_field_name( 'hierarchical' ); ?>"<?php checked( $hierarchical ); ?> />
     178        <label for="<?php echo $this->get_field_id( 'hierarchical' ); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
    179179        <?php
    180180    }
Note: See TracChangeset for help on using the changeset viewer.