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-custom-html.php

    r42185 r42343  
    3232     */
    3333    protected $default_instance = array(
    34         'title' => '',
     34        'title'   => '',
    3535        'content' => '',
    3636    );
     
    4242     */
    4343    public function __construct() {
    44         $widget_ops = array(
    45             'classname' => 'widget_custom_html',
    46             'description' => __( 'Arbitrary HTML code.' ),
     44        $widget_ops  = array(
     45            'classname'                   => 'widget_custom_html',
     46            'description'                 => __( 'Arbitrary HTML code.' ),
    4747            'customize_selective_refresh' => true,
    4848        );
    4949        $control_ops = array(
    50             'width' => 400,
     50            'width'  => 400,
    5151            'height' => 350,
    5252        );
     
    131131
    132132        // Prepare instance data that looks like a normal Text widget.
    133         $simulated_text_widget_instance = array_merge( $instance, array(
    134             'text' => isset( $instance['content'] ) ? $instance['content'] : '',
    135             'filter' => false, // Because wpautop is not applied.
    136             'visual' => false, // Because it wasn't created in TinyMCE.
    137         ) );
     133        $simulated_text_widget_instance = array_merge(
     134            $instance, array(
     135                'text'   => isset( $instance['content'] ) ? $instance['content'] : '',
     136                'filter' => false, // Because wpautop is not applied.
     137                'visual' => false, // Because it wasn't created in TinyMCE.
     138            )
     139        );
    138140        unset( $simulated_text_widget_instance['content'] ); // Was moved to 'text' prop.
    139141
     
    180182     */
    181183    public function update( $new_instance, $old_instance ) {
    182         $instance = array_merge( $this->default_instance, $old_instance );
     184        $instance          = array_merge( $this->default_instance, $old_instance );
    183185        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    184186        if ( current_user_can( 'unfiltered_html' ) ) {
     
    196198     */
    197199    public function enqueue_admin_scripts() {
    198         $settings = wp_enqueue_code_editor( array(
    199             'type' => 'text/html',
    200             'codemirror' => array(
    201                 'indentUnit' => 2,
    202                 'tabSize' => 2,
    203             ),
    204         ) );
     200        $settings = wp_enqueue_code_editor(
     201            array(
     202                'type'       => 'text/html',
     203                'codemirror' => array(
     204                    'indentUnit' => 2,
     205                    'tabSize'    => 2,
     206                ),
     207            )
     208        );
    205209
    206210        wp_enqueue_script( 'custom-html-widgets' );
     
    217221                'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ),
    218222                /* translators: %d: error count */
    219                 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
     223                'plural'   => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
    220224            ),
    221225        );
     
    263267                <?php
    264268                $probably_unsafe_html = array( 'script', 'iframe', 'form', 'input', 'style' );
    265                 $allowed_html = wp_kses_allowed_html( 'post' );
    266                 $disallowed_html = array_diff( $probably_unsafe_html, array_keys( $allowed_html ) );
     269                $allowed_html         = wp_kses_allowed_html( 'post' );
     270                $disallowed_html      = array_diff( $probably_unsafe_html, array_keys( $allowed_html ) );
    267271                ?>
    268272                <?php if ( ! empty( $disallowed_html ) ) : ?>
     
    289293        $screen = get_current_screen();
    290294
    291         $content = '<p>';
     295        $content  = '<p>';
    292296        $content .= __( 'Use the Custom HTML widget to add arbitrary HTML code to your widget areas.' );
    293297        $content .= '</p>';
     
    300304                esc_url( get_edit_profile_url() ),
    301305                'class="external-link" target="_blank"',
    302                 sprintf( '<span class="screen-reader-text"> %s</span>',
     306                sprintf(
     307                    '<span class="screen-reader-text"> %s</span>',
    303308                    /* translators: accessibility text */
    304309                    __( '(opens in a new window)' )
     
    315320        }
    316321
    317         $screen->add_help_tab( array(
    318             'id' => 'custom_html_widget',
    319             'title' => __( 'Custom HTML Widget' ),
    320             'content' => $content,
    321         ) );
     322        $screen->add_help_tab(
     323            array(
     324                'id'      => 'custom_html_widget',
     325                'title'   => __( 'Custom HTML Widget' ),
     326                'content' => $content,
     327            )
     328        );
    322329    }
    323330}
Note: See TracChangeset for help on using the changeset viewer.