Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 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-text.php

    r42185 r42343  
    3131         */
    3232        public function __construct() {
    33                 $widget_ops = array(
    34                         'classname' => 'widget_text',
    35                         'description' => __( 'Arbitrary text.' ),
     33                $widget_ops  = array(
     34                        'classname'                   => 'widget_text',
     35                        'description'                 => __( 'Arbitrary text.' ),
    3636                        'customize_selective_refresh' => true,
    3737                );
    3838                $control_ops = array(
    39                         'width' => 400,
     39                        'width'  => 400,
    4040                        'height' => 350,
    4141                );
     
    9696                }
    9797
    98                 $wpautop = ! empty( $instance['filter'] );
     98                $wpautop         = ! empty( $instance['filter'] );
    9999                $has_line_breaks = ( false !== strpos( trim( $instance['text'] ), "\n" ) );
    100100
     
    117117
    118118                $doc = new DOMDocument();
    119                 @$doc->loadHTML( sprintf(
    120                         '<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
    121                         esc_attr( get_bloginfo( 'charset' ) ),
    122                         $instance['text']
    123                 ) );
     119                @$doc->loadHTML(
     120                        sprintf(
     121                                '<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
     122                                esc_attr( get_bloginfo( 'charset' ) ),
     123                                $instance['text']
     124                        )
     125                );
    124126                $body = $doc->getElementsByTagName( 'body' )->item( 0 );
    125127
    126128                // See $allowedposttags.
    127129                $safe_elements_attributes = array(
    128                         'strong' => array(),
    129                         'em' => array(),
    130                         'b' => array(),
    131                         'i' => array(),
    132                         'u' => array(),
    133                         's' => array(),
    134                         'ul' => array(),
    135                         'ol' => array(),
    136                         'li' => array(),
    137                         'hr' => array(),
    138                         'abbr' => array(),
     130                        'strong'  => array(),
     131                        'em'      => array(),
     132                        'b'       => array(),
     133                        'i'       => array(),
     134                        'u'       => array(),
     135                        's'       => array(),
     136                        'ul'      => array(),
     137                        'ol'      => array(),
     138                        'li'      => array(),
     139                        'hr'      => array(),
     140                        'abbr'    => array(),
    139141                        'acronym' => array(),
    140                         'code' => array(),
    141                         'dfn' => array(),
    142                         'a' => array(
     142                        'code'    => array(),
     143                        'dfn'     => array(),
     144                        'a'       => array(
    143145                                'href' => true,
    144146                        ),
    145                         'img' => array(
     147                        'img'     => array(
    146148                                'src' => true,
    147149                                'alt' => true,
    148150                        ),
    149151                );
    150                 $safe_empty_elements = array( 'img', 'hr', 'iframe' );
     152                $safe_empty_elements      = array( 'img', 'hr', 'iframe' );
    151153
    152154                foreach ( $body->getElementsByTagName( '*' ) as $element ) {
     
    216218                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    217219
    218                 $text = ! empty( $instance['text'] ) ? $instance['text'] : '';
     220                $text                  = ! empty( $instance['text'] ) ? $instance['text'] : '';
    219221                $is_visual_text_widget = ( ! empty( $instance['visual'] ) && ! empty( $instance['filter'] ) );
    220222
     
    234236                 * added to 'widget_text_content' then do_shortcode() will be manually called when in legacy mode as well.
    235237                 */
    236                 $widget_text_do_shortcode_priority = has_filter( 'widget_text', 'do_shortcode' );
     238                $widget_text_do_shortcode_priority       = has_filter( 'widget_text', 'do_shortcode' );
    237239                $should_suspend_legacy_shortcode_support = ( $is_visual_text_widget && false !== $widget_text_do_shortcode_priority );
    238240                if ( $should_suspend_legacy_shortcode_support ) {
     
    352354         */
    353355        public function update( $new_instance, $old_instance ) {
    354                 $new_instance = wp_parse_args( $new_instance, array(
    355                         'title' => '',
    356                         'text' => '',
    357                         'filter' => false, // For back-compat.
    358                         'visual' => null, // Must be explicitly defined.
    359                 ) );
     356                $new_instance = wp_parse_args(
     357                        $new_instance, array(
     358                                'title'  => '',
     359                                'text'   => '',
     360                                'filter' => false, // For back-compat.
     361                                'visual' => null, // Must be explicitly defined.
     362                        )
     363                );
    360364
    361365                $instance = $old_instance;
     
    418422                        array(
    419423                                'title' => '',
    420                                 'text' => '',
     424                                'text'  => '',
    421425                        )
    422426                );
Note: See TracChangeset for help on using the changeset viewer.