Making WordPress.org


Ignore:
Timestamp:
02/26/2018 06:38:19 PM (8 years ago)
Author:
iandunn
Message:

WordCamp Post Types: Apply coding standards.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/inc/widgets.php

    r3602 r6764  
    44 */
    55
    6 if ( ! class_exists( 'WCB_Widget_Sponsors' ) ) :
    76/**
    87 * Sponsors widget class.
     
    1110 */
    1211class WCB_Widget_Sponsors extends WP_Widget {
    13 
    1412    function __construct() {
    1513        $widget_ops = array(
    16             'classname' => 'wcb_widget_sponsors',
     14            'classname'   => 'wcb_widget_sponsors',
    1715            'description' => __( 'Your WordCamp’s Sponsors', 'wordcamporg' ),
    1816        );
     
    2826
    2927        echo $before_widget;
    30         if ( $title )
     28
     29        if ( $title ) {
    3130            echo $before_title . $title . $after_title;
     31        }
    3232
    3333        // Fetch sponsor levels
     
    5353        <?php foreach ( $terms as $term ) : ?>
    5454            <?php
    55                 $sponsors = new WP_Query( array(
    56                     'post_type' => 'wcb_sponsor',
    57                     'posts_per_page' => -1,
    58                     'order' => 'ASC',
    59                     'taxonomy' => $term->taxonomy,
    60                     'term' => $term->slug,
    61                 ) );
    62 
    63                 if ( ! $sponsors->have_posts() )
    64                     continue;
     55
     56            $sponsors = new WP_Query( array(
     57                'post_type'      => 'wcb_sponsor',
     58                'posts_per_page' => -1,
     59                'order'          => 'ASC',
     60                'taxonomy'       => $term->taxonomy,
     61                'term'           => $term->slug,
     62            ) );
     63
     64            if ( ! $sponsors->have_posts() ) {
     65                continue;
     66            }
     67
    6568            ?>
    6669
     
    6871                <h4 class="sponsor-level-title"><?php echo esc_html( $term->name ); ?></h4>
    6972
    70                 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?>
     73                <?php while ( $sponsors->have_posts() ) :
     74                    $sponsors->the_post(); ?>
    7175
    7276                    <a class="sponsor-logo" href="<?php the_permalink(); ?>">
     
    8690    function form( $instance ) {
    8791        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    88         $title = $instance['title'];
     92        $title    = $instance['title'];
    8993        ?>
    9094        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <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 ); ?>" /></label></p>
     
    9397
    9498    function update( $new_instance, $old_instance ) {
    95         $instance = $old_instance;
    96         $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) );
     99        $instance          = $old_instance;
     100        $new_instance      = wp_parse_args( (array) $new_instance, array( 'title' => '' ) );
    97101        $instance['title'] = strip_tags( $new_instance['title'] );
    98102        return $instance;
    99103    }
    100104}
    101 endif; // class_exists
    102105
    103106/**
     
    111114 */
    112115class WCPT_Widget_Speakers extends WP_Widget {
    113 
    114116    protected $cache_time = 3600; // seconds
    115117
    116118    function __construct() {
    117119        $widget_ops = array(
    118             'classname' => 'wcpt_widget_speakers',
     120            'classname'   => 'wcpt_widget_speakers',
    119121            'description' => __( 'Your WordCamp&#8217;s Speakers', 'wordcamporg' ),
    120122        );
     
    126128        global $wcpt_plugin;
    127129
    128         $transient_key = 'wcpt-' . md5( $args['widget_id'] );
     130        $transient_key     = 'wcpt-' . md5( $args['widget_id'] );
    129131        $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    130132
    131133        echo $args['before_widget'];
    132         if ( $instance['title'] )
     134        if ( $instance['title'] ) {
    133135            echo $args['before_title'] . $instance['title'] . $args['after_title'];
     136        }
    134137
    135138        if ( false === ( $widget_content = get_transient( $transient_key ) ) ) {
     
    137140            $attr = array();
    138141
    139             if ( $instance['count'] )
     142            if ( $instance['count'] ) {
    140143                $attr['posts_per_page'] = $instance['count'];
    141 
    142             if ( $instance['random'] )
     144            }
     145
     146            if ( $instance['random'] ) {
    143147                $attr['orderby'] = 'rand';
     148            }
    144149
    145150            $attr_str = array();
    146             foreach ( $attr as $key => $value )
     151            foreach ( $attr as $key => $value ) {
    147152                $attr_str[ $key ] = sprintf( '%s="%s"', $key, esc_attr( $value ) );
     153            }
    148154            $attr_str = implode( ' ', $attr_str );
    149155
     
    156162
    157163        $speakers_permalink = $wcpt_plugin->get_wcpt_permalink( 'speakers' );
    158         if ( ! empty( $speakers_permalink ) )
     164        if ( ! empty( $speakers_permalink ) ) {
    159165            printf( '<a class="wcpt-speakers-link" href="%s">%s</a>', esc_url( $speakers_permalink ), esc_html( __( 'View all speakers &rarr;', 'wordcamporg' ) ) );
     166        }
    160167
    161168        echo $args['after_widget'];
     
    165172
    166173    function form( $instance ) {
    167         $instance = wp_parse_args( (array) $instance, array(
    168             'title' => '',
    169             'count' => 3,
    170             'random' => false,
    171         ) );
    172 
    173         $title = $instance['title'];
    174         $count = absint( $instance['count'] );
     174        $instance = wp_parse_args(
     175            (array) $instance,
     176            array(
     177                'title'  => '',
     178                'count'  => 3,
     179                'random' => false,
     180            )
     181        );
     182
     183        $title  = $instance['title'];
     184        $count  = absint( $instance['count'] );
    175185        $random = (bool) $instance['random'];
     186
    176187        ?>
     188
    177189        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <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 ); ?>" /></label></p>
    178190        <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of speakers to show:', 'wordcamporg' ); ?> <input type="text" size="3" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo esc_attr( $count ); ?>" /></label></p>
     
    186198
    187199    function update( $new_instance, $old_instance ) {
    188         $instance = $old_instance;
    189         $new_instance = wp_parse_args( (array) $new_instance, array(
    190             'title' => '',
    191             'count' => 3,
    192             'random' => false,
    193         ) );
    194 
    195         $instance['title'] = strip_tags( $new_instance['title'] );
    196         $instance['count'] = absint( $new_instance['count'] );
     200        $instance     = $old_instance;
     201        $new_instance = wp_parse_args(
     202            (array) $new_instance,
     203            array(
     204                'title'  => '',
     205                'count'  => 3,
     206                'random' => false,
     207            )
     208        );
     209
     210        $instance['title']  = strip_tags( $new_instance['title'] );
     211        $instance['count']  = absint( $new_instance['count'] );
    197212        $instance['random'] = (bool) $new_instance['random'];
    198213
     
    213228 */
    214229class WCPT_Widget_Sessions extends WP_Widget {
    215 
    216230    protected $cache_time = 3600; // seconds
    217231
    218232    function __construct() {
    219233        $widget_ops = array(
    220             'classname' => 'wcpt_widget_sessions',
     234            'classname'   => 'wcpt_widget_sessions',
    221235            'description' => __( 'Show off your WordCamp sessions', 'wordcamporg' ),
    222236        );
     
    228242        global $wcpt_plugin;
    229243
    230         $transient_key = 'wcpt-' . md5( $args['widget_id'] );
     244        $transient_key     = 'wcpt-' . md5( $args['widget_id'] );
    231245        $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    232246
    233247        echo $args['before_widget'];
    234         if ( $instance['title'] )
     248        if ( $instance['title'] ) {
    235249            echo $args['before_title'] . $instance['title'] . $args['after_title'];
     250        }
    236251
    237252        if ( false === ( $widget_content = get_transient( $transient_key ) ) ) {
     
    239254            $attr = array(
    240255                'show_avatars' => 'true',
    241                 'show_meta' => 'true',
     256                'show_meta'    => 'true',
    242257                'speaker_link' => 'anchor',
    243258            );
    244259
    245             if ( $instance['count'] )
     260            if ( $instance['count'] ) {
    246261                $attr['posts_per_page'] = $instance['count'];
    247 
    248             if ( $instance['random'] )
     262            }
     263
     264            if ( $instance['random'] ) {
    249265                $attr['orderby'] = 'rand';
     266            }
    250267
    251268            $attr_str = array();
    252             foreach ( $attr as $key => $value )
     269            foreach ( $attr as $key => $value ) {
    253270                $attr_str[ $key ] = sprintf( '%s="%s"', $key, esc_attr( $value ) );
     271            }
    254272            $attr_str = implode( ' ', $attr_str );
    255273
     
    262280
    263281        $sessions_permalink = $wcpt_plugin->get_wcpt_permalink( 'sessions' );
    264         if ( ! empty( $sessions_permalink ) )
     282        if ( ! empty( $sessions_permalink ) ) {
    265283            printf( '<a class="wcpt-sessions-link" href="%s">%s</a>', esc_url( $sessions_permalink ), esc_html( __( 'View all sessions &rarr;', 'wordcamporg' ) ) );
     284        }
    266285
    267286        echo $args['after_widget'];
     
    271290
    272291    function form( $instance ) {
    273         $instance = wp_parse_args( (array) $instance, array(
    274             'title' => '',
    275             'count' => 3,
    276             'random' => false,
    277         ) );
    278 
    279         $title = $instance['title'];
    280         $count = absint( $instance['count'] );
     292        $instance = wp_parse_args(
     293            (array) $instance,
     294            array(
     295                'title'  => '',
     296                'count'  => 3,
     297                'random' => false,
     298            )
     299        );
     300
     301        $title  = $instance['title'];
     302        $count  = absint( $instance['count'] );
    281303        $random = (bool) $instance['random'];
     304
    282305        ?>
     306
    283307        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <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 ); ?>" /></label></p>
    284308        <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of speakers to show:', 'wordcamporg' ); ?> <input type="text" size="3" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo esc_attr( $count ); ?>" /></label></p>
     
    292316
    293317    function update( $new_instance, $old_instance ) {
    294         $instance = $old_instance;
    295         $new_instance = wp_parse_args( (array) $new_instance, array(
    296             'title' => '',
    297             'count' => 3,
    298             'random' => false,
    299         ) );
    300 
    301         $instance['title'] = strip_tags( $new_instance['title'] );
    302         $instance['count'] = absint( $new_instance['count'] );
     318        $instance     = $old_instance;
     319        $new_instance = wp_parse_args(
     320            (array) $new_instance,
     321            array(
     322                'title'  => '',
     323                'count'  => 3,
     324                'random' => false,
     325            )
     326        );
     327
     328        $instance['title']  = strip_tags( $new_instance['title'] );
     329        $instance['count']  = absint( $new_instance['count'] );
    303330        $instance['random'] = (bool) $new_instance['random'];
    304331
     
    323350    function __construct() {
    324351        $widget_ops = array(
    325             'classname' => 'wcpt_widget_organizers',
     352            'classname'   => 'wcpt_widget_organizers',
    326353            'description' => __( 'Display your organizing team in the sidebar', 'wordcamporg' ),
    327354        );
     
    333360        global $wcpt_plugin;
    334361
    335         $transient_key = 'wcpt-' . md5( $args['widget_id'] );
     362        $transient_key     = 'wcpt-' . md5( $args['widget_id'] );
    336363        $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    337364
    338365        echo $args['before_widget'];
    339         if ( $instance['title'] )
     366        if ( $instance['title'] ) {
    340367            echo $args['before_title'] . $instance['title'] . $args['after_title'];
     368        }
    341369
    342370        if ( false === ( $widget_content = get_transient( $transient_key ) ) ) {
     
    344372            $attr = array();
    345373
    346             if ( $instance['count'] )
     374            if ( $instance['count'] ) {
    347375                $attr['posts_per_page'] = $instance['count'];
    348 
    349             if ( $instance['random'] )
     376            }
     377
     378            if ( $instance['random'] ) {
    350379                $attr['orderby'] = 'rand';
     380            }
    351381
    352382            $attr_str = array();
    353             foreach ( $attr as $key => $value )
     383            foreach ( $attr as $key => $value ) {
    354384                $attr_str[ $key ] = sprintf( '%s="%s"', $key, esc_attr( $value ) );
     385            }
    355386            $attr_str = implode( ' ', $attr_str );
    356387
     
    363394
    364395        $organizers_permalink = $wcpt_plugin->get_wcpt_permalink( 'organizers' );
    365         if ( ! empty( $organizers_permalink ) )
     396        if ( ! empty( $organizers_permalink ) ) {
    366397            printf( '<a class="wcpt-organizers-link" href="%s">%s</a>', esc_url( $organizers_permalink ), esc_html( __( 'Organizing team &rarr;', 'wordcamporg' ) ) );
     398        }
    367399
    368400        echo $args['after_widget'];
     
    372404
    373405    function form( $instance ) {
    374         $instance = wp_parse_args( (array) $instance, array(
    375             'title' => '',
    376             'count' => 3,
    377             'random' => false,
    378         ) );
    379 
    380         $title = $instance['title'];
    381         $count = absint( $instance['count'] );
     406        $instance = wp_parse_args(
     407            (array) $instance,
     408            array(
     409                'title'  => '',
     410                'count'  => 3,
     411                'random' => false,
     412            )
     413        );
     414
     415        $title  = $instance['title'];
     416        $count  = absint( $instance['count'] );
    382417        $random = (bool) $instance['random'];
     418
    383419        ?>
     420
    384421        <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wordcamporg' ); ?> <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 ); ?>" /></label></p>
    385422        <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of organizers to show:', 'wordcamporg' ); ?> <input type="text" size="3" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo esc_attr( $count ); ?>" /></label></p>
     
    393430
    394431    function update( $new_instance, $old_instance ) {
    395         $instance = $old_instance;
    396         $new_instance = wp_parse_args( (array) $new_instance, array(
    397             'title' => '',
    398             'count' => 3,
    399             'random' => false,
    400         ) );
    401 
    402         $instance['title'] = strip_tags( $new_instance['title'] );
    403         $instance['count'] = absint( $new_instance['count'] );
     432        $instance     = $old_instance;
     433        $new_instance = wp_parse_args(
     434            (array) $new_instance,
     435            array(
     436                'title'  => '',
     437                'count'  => 3,
     438                'random' => false,
     439            )
     440        );
     441
     442        $instance['title']  = strip_tags( $new_instance['title'] );
     443        $instance['count']  = absint( $new_instance['count'] );
    404444        $instance['random'] = (bool) $new_instance['random'];
    405445
     
    407447        $transient_key = 'wcpt-' . md5( $this->id );
    408448        delete_transient( $transient_key );
     449
    409450        return $instance;
    410451    }
Note: See TracChangeset for help on using the changeset viewer.