WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (2 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/twentyeleven/inc/widgets.php

    r37590 r42343  
    1919     */
    2020    function __construct() {
    21         parent::__construct( 'widget_twentyeleven_ephemera', __( 'Twenty Eleven Ephemera', 'twentyeleven' ), array(
    22             'classname'   => 'widget_twentyeleven_ephemera',
    23             'description' => __( 'Use this widget to list your recent Aside, Status, Quote, and Link posts', 'twentyeleven' ),
    24             'customize_selective_refresh' => true,
    25         ) );
     21        parent::__construct(
     22            'widget_twentyeleven_ephemera', __( 'Twenty Eleven Ephemera', 'twentyeleven' ), array(
     23                'classname'                   => 'widget_twentyeleven_ephemera',
     24                'description'                 => __( 'Use this widget to list your recent Aside, Status, Quote, and Link posts', 'twentyeleven' ),
     25                'customize_selective_refresh' => true,
     26            )
     27        );
    2628        $this->alt_option_name = 'widget_twentyeleven_ephemera';
    2729
     
    4749     * @param array $args     An array of standard parameters for widgets in this theme.
    4850     * @param array $instance An array of settings for this widget instance.
    49      **/
     51     */
    5052    function widget( $args, $instance ) {
    5153        $cache = wp_cache_get( 'widget_twentyeleven_ephemera', 'widget' );
    5254
    53         if ( ! is_array( $cache ) )
     55        if ( ! is_array( $cache ) ) {
    5456            $cache = array();
     57        }
    5558
    56         if ( ! isset( $args['widget_id'] ) )
     59        if ( ! isset( $args['widget_id'] ) ) {
    5760            $args['widget_id'] = null;
     61        }
    5862
    5963        if ( ! is_customize_preview() && isset( $cache[ $args['widget_id'] ] ) ) {
     
    6872        $args['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Ephemera', 'twentyeleven' ) : $instance['title'], $instance, $this->id_base );
    6973
    70         if ( ! isset( $instance['number'] ) )
     74        if ( ! isset( $instance['number'] ) ) {
    7175            $instance['number'] = '10';
     76        }
    7277
    73         if ( ! $args['number'] = absint( $instance['number'] ) )
     78        if ( ! $args['number'] = absint( $instance['number'] ) ) {
    7479            $args['number'] = 10;
     80        }
    7581
    7682        $ephemera_args = array(
     
    8995            ),
    9096        );
    91         $ephemera = new WP_Query( $ephemera_args );
     97        $ephemera      = new WP_Query( $ephemera_args );
    9298
    9399        if ( $ephemera->have_posts() ) :
     
    98104            ?>
    99105            <ol>
    100             <?php while ( $ephemera->have_posts() ) : $ephemera->the_post(); ?>
     106            <?php
     107            while ( $ephemera->have_posts() ) :
     108                $ephemera->the_post();
     109?>
    101110
    102111                <?php if ( 'link' != get_post_format() ) : ?>
     
    129138            wp_reset_postdata();
    130139
    131         // end check for ephemeral posts
     140            // end check for ephemeral posts
    132141        endif;
    133142
     
    146155     *
    147156     * @since Twenty Eleven 1.0
    148      **/
     157     */
    149158    function update( $new_instance, $old_instance ) {
    150         $instance = $old_instance;
    151         $instance['title'] = strip_tags( $new_instance['title'] );
     159        $instance           = $old_instance;
     160        $instance['title']  = strip_tags( $new_instance['title'] );
    152161        $instance['number'] = (int) $new_instance['number'];
    153162        $this->flush_widget_cache();
    154163
    155164        $alloptions = wp_cache_get( 'alloptions', 'options' );
    156         if ( isset( $alloptions['widget_twentyeleven_ephemera'] ) )
     165        if ( isset( $alloptions['widget_twentyeleven_ephemera'] ) ) {
    157166            delete_option( 'widget_twentyeleven_ephemera' );
     167        }
    158168
    159169        return $instance;
     
    175185     *
    176186     * @since Twenty Eleven 1.0
    177      **/
     187     */
    178188    function form( $instance ) {
    179         $title = isset( $instance['title']) ? esc_attr( $instance['title'] ) : '';
     189        $title  = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    180190        $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 10;
    181191?>
Note: See TracChangeset for help on using the changeset viewer.