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/widgets/class-wp-widget-archives.php

    r41867 r42343  
    2424    public function __construct() {
    2525        $widget_ops = array(
    26             'classname' => 'widget_archive',
    27             'description' => __( 'A monthly archive of your site’s Posts.' ),
     26            'classname'                   => 'widget_archive',
     27            'description'                 => __( 'A monthly archive of your site’s Posts.' ),
    2828            'customize_selective_refresh' => true,
    2929        );
    30         parent::__construct('archives', __('Archives'), $widget_ops);
     30        parent::__construct( 'archives', __( 'Archives' ), $widget_ops );
    3131    }
    3232
     
    7272             * @param array $instance Settings for the current Archives widget instance.
    7373             */
    74             $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array(
    75                 'type'            => 'monthly',
    76                 'format'          => 'option',
    77                 'show_post_count' => $c
    78             ), $instance );
     74            $dropdown_args = apply_filters(
     75                'widget_archives_dropdown_args', array(
     76                    'type'            => 'monthly',
     77                    'format'          => 'option',
     78                    'show_post_count' => $c,
     79                ), $instance
     80            );
    7981
    8082            switch ( $dropdown_args['type'] ) {
     
    115117         * @param array $instance Array of settings for the current widget.
    116118         */
    117         wp_get_archives( apply_filters( 'widget_archives_args', array(
    118             'type'            => 'monthly',
    119             'show_post_count' => $c
    120         ), $instance ) );
     119        wp_get_archives(
     120            apply_filters(
     121                'widget_archives_args', array(
     122                    'type'            => 'monthly',
     123                    'show_post_count' => $c,
     124                ), $instance
     125            )
     126        );
    121127        ?>
    122128        </ul>
    123129        <?php
    124         }
     130}
    125131
    126132        echo $args['after_widget'];
     
    138144     */
    139145    public function update( $new_instance, $old_instance ) {
    140         $instance = $old_instance;
    141         $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
    142         $instance['title'] = sanitize_text_field( $new_instance['title'] );
    143         $instance['count'] = $new_instance['count'] ? 1 : 0;
     146        $instance             = $old_instance;
     147        $new_instance         = wp_parse_args(
     148            (array) $new_instance, array(
     149                'title'    => '',
     150                'count'    => 0,
     151                'dropdown' => '',
     152            )
     153        );
     154        $instance['title']    = sanitize_text_field( $new_instance['title'] );
     155        $instance['count']    = $new_instance['count'] ? 1 : 0;
    144156        $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
    145157
     
    155167     */
    156168    public function form( $instance ) {
    157         $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
    158         $title = sanitize_text_field( $instance['title'] );
     169        $instance = wp_parse_args(
     170            (array) $instance, array(
     171                'title'    => '',
     172                'count'    => 0,
     173                'dropdown' => '',
     174            )
     175        );
     176        $title    = sanitize_text_field( $instance['title'] );
    159177        ?>
    160         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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>
     178        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <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>
    161179        <p>
    162             <input class="checkbox" type="checkbox"<?php checked( $instance['dropdown'] ); ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label>
     180            <input class="checkbox" type="checkbox"<?php checked( $instance['dropdown'] ); ?> id="<?php echo $this->get_field_id( 'dropdown' ); ?>" name="<?php echo $this->get_field_name( 'dropdown' ); ?>" /> <label for="<?php echo $this->get_field_id( 'dropdown' ); ?>"><?php _e( 'Display as dropdown' ); ?></label>
    163181            <br/>
    164             <input class="checkbox" type="checkbox"<?php checked( $instance['count'] ); ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label>
     182            <input class="checkbox" type="checkbox"<?php checked( $instance['count'] ); ?> id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" /> <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Show post counts' ); ?></label>
    165183        </p>
    166184        <?php
Note: See TracChangeset for help on using the changeset viewer.