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-media.php

    r41951 r42343  
    2424         */
    2525        public $l10n = array(
    26                 'add_to_widget' => '',
    27                 'replace_media' => '',
    28                 'edit_media' => '',
    29                 'media_library_state_multi' => '',
     26                'add_to_widget'              => '',
     27                'replace_media'              => '',
     28                'edit_media'                 => '',
     29                'media_library_state_multi'  => '',
    3030                'media_library_state_single' => '',
    31                 'missing_attachment' => '',
    32                 'no_media_selected' => '',
    33                 'add_media' => '',
     31                'missing_attachment'         => '',
     32                'no_media_selected'          => '',
     33                'add_media'                  => '',
    3434        );
    3535
    … …  
    5555         */
    5656        public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
    57                 $widget_opts = wp_parse_args( $widget_options, array(
    58                         'description' => __( 'A media item.' ),
    59                         'customize_selective_refresh' => true,
    60                         'mime_type' => '',
    61                 ) );
     57                $widget_opts = wp_parse_args(
     58                        $widget_options, array(
     59                                'description'                 => __( 'A media item.' ),
     60                                'customize_selective_refresh' => true,
     61                                'mime_type'                   => '',
     62                        )
     63                );
    6264
    6365                $control_opts = wp_parse_args( $control_options, array() );
    6466
    6567                $l10n_defaults = array(
    66                         'no_media_selected' => __( 'No media selected' ),
    67                         'add_media' => _x( 'Add Media', 'label for button in the media widget' ),
    68                         'replace_media' => _x( 'Replace Media', 'label for button in the media widget; should preferably not be longer than ~13 characters long' ),
    69                         'edit_media' => _x( 'Edit Media', 'label for button in the media widget; should preferably not be longer than ~13 characters long' ),
    70                         'add_to_widget' => __( 'Add to Widget' ),
    71                         'missing_attachment' => sprintf(
     68                        'no_media_selected'          => __( 'No media selected' ),
     69                        'add_media'                  => _x( 'Add Media', 'label for button in the media widget' ),
     70                        'replace_media'              => _x( 'Replace Media', 'label for button in the media widget; should preferably not be longer than ~13 characters long' ),
     71                        'edit_media'                 => _x( 'Edit Media', 'label for button in the media widget; should preferably not be longer than ~13 characters long' ),
     72                        'add_to_widget'              => __( 'Add to Widget' ),
     73                        'missing_attachment'         => sprintf(
    7274                                /* translators: %s: URL to media library */
    7375                                __( 'We can&#8217;t find that file. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
    … …  
    7577                        ),
    7678                        /* translators: %d: widget count */
    77                         'media_library_state_multi' => _n_noop( 'Media Widget (%d)', 'Media Widget (%d)' ),
     79                        'media_library_state_multi'  => _n_noop( 'Media Widget (%d)', 'Media Widget (%d)' ),
    7880                        'media_library_state_single' => __( 'Media Widget' ),
    79                         'unsupported_file_type' => __( 'Looks like this isn&#8217;t the correct kind of file. Please link to an appropriate file instead.' ),
     81                        'unsupported_file_type'      => __( 'Looks like this isn&#8217;t the correct kind of file. Please link to an appropriate file instead.' ),
    8082                );
    8183                $this->l10n = array_merge( $l10n_defaults, array_filter( $this->l10n ) );
    … …  
    130132                $schema = array(
    131133                        'attachment_id' => array(
    132                                 'type' => 'integer',
    133                                 'default' => 0,
    134                                 'minimum' => 0,
     134                                'type'        => 'integer',
     135                                'default'     => 0,
     136                                'minimum'     => 0,
    135137                                'description' => __( 'Attachment post ID' ),
    136                                 'media_prop' => 'id',
     138                                'media_prop'  => 'id',
    137139                        ),
    138                         'url' => array(
    139                                 'type' => 'string',
    140                                 'default' => '',
    141                                 'format' => 'uri',
     140                        'url'           => array(
     141                                'type'        => 'string',
     142                                'default'     => '',
     143                                'format'      => 'uri',
    142144                                'description' => __( 'URL to the media file' ),
    143145                        ),
    144                         'title' => array(
    145                                 'type' => 'string',
    146                                 'default' => '',
    147                                 'sanitize_callback' => 'sanitize_text_field',
    148                                 'description' => __( 'Title for the widget' ),
     146                        'title'         => array(
     147                                'type'                  => 'string',
     148                                'default'               => '',
     149                                'sanitize_callback'     => 'sanitize_text_field',
     150                                'description'           => __( 'Title for the widget' ),
    149151                                'should_preview_update' => false,
    150152                        ),
    … …  
    323325        final public function form( $instance ) {
    324326                $instance_schema = $this->get_instance_schema();
    325                 $instance = wp_array_slice_assoc(
     327                $instance        = wp_array_slice_assoc(
    326328                        wp_parse_args( (array) $instance, wp_list_pluck( $instance_schema, 'default' ) ),
    327329                        array_keys( $instance_schema )
Note: See TracChangeset for help on using the changeset viewer.