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

    r42228 r42343  
    6060        $_wp_additional_image_sizes = wp_get_additional_image_sizes();
    6161
    62         if ( ! $context )
     62        if ( ! $context ) {
    6363                $context = is_admin() ? 'edit' : 'display';
    64 
    65         if ( is_array($size) ) {
    66                 $max_width = $size[0];
     64        }
     65
     66        if ( is_array( $size ) ) {
     67                $max_width  = $size[0];
    6768                $max_height = $size[1];
    68         }
    69         elseif ( $size == 'thumb' || $size == 'thumbnail' ) {
    70                 $max_width = intval(get_option('thumbnail_size_w'));
    71                 $max_height = intval(get_option('thumbnail_size_h'));
     69        } elseif ( $size == 'thumb' || $size == 'thumbnail' ) {
     70                $max_width  = intval( get_option( 'thumbnail_size_w' ) );
     71                $max_height = intval( get_option( 'thumbnail_size_h' ) );
    7272                // last chance thumbnail size defaults
    73                 if ( !$max_width && !$max_height ) {
    74                         $max_width = 128;
     73                if ( ! $max_width && ! $max_height ) {
     74                        $max_width  = 128;
    7575                        $max_height = 96;
    7676                }
    77         }
    78         elseif ( $size == 'medium' ) {
    79                 $max_width = intval(get_option('medium_size_w'));
    80                 $max_height = intval(get_option('medium_size_h'));
    81 
    82         }
    83         elseif ( $size == 'medium_large' ) {
    84                 $max_width = intval( get_option( 'medium_large_size_w' ) );
     77        } elseif ( $size == 'medium' ) {
     78                $max_width  = intval( get_option( 'medium_size_w' ) );
     79                $max_height = intval( get_option( 'medium_size_h' ) );
     80
     81        } elseif ( $size == 'medium_large' ) {
     82                $max_width  = intval( get_option( 'medium_large_size_w' ) );
    8583                $max_height = intval( get_option( 'medium_large_size_h' ) );
    8684
    … …  
    8886                        $max_width = min( intval( $content_width ), $max_width );
    8987                }
    90         }
    91         elseif ( $size == 'large' ) {
     88        } elseif ( $size == 'large' ) {
    9289                /*
    9390                 * We're inserting a large size image into the editor. If it's a really
    … …  
    9693                 * can resize it in the editor if they wish.
    9794                 */
    98                 $max_width = intval(get_option('large_size_w'));
    99                 $max_height = intval(get_option('large_size_h'));
    100                 if ( intval($content_width) > 0 ) {
    101                         $max_width = min( intval($content_width), $max_width );
     95                $max_width  = intval( get_option( 'large_size_w' ) );
     96                $max_height = intval( get_option( 'large_size_h' ) );
     97                if ( intval( $content_width ) > 0 ) {
     98                        $max_width = min( intval( $content_width ), $max_width );
    10299                }
    103100        } elseif ( ! empty( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {
    104                 $max_width = intval( $_wp_additional_image_sizes[$size]['width'] );
    105                 $max_height = intval( $_wp_additional_image_sizes[$size]['height'] );
     101                $max_width  = intval( $_wp_additional_image_sizes[ $size ]['width'] );
     102                $max_height = intval( $_wp_additional_image_sizes[ $size ]['height'] );
    106103                // Only in admin. Assume that theme authors know what they're doing.
    107104                if ( intval( $content_width ) > 0 && 'edit' === $context ) {
    108105                        $max_width = min( intval( $content_width ), $max_width );
    109106                }
    110         }
    111         // $size == 'full' has no constraint
     107        } // $size == 'full' has no constraint
    112108        else {
    113                 $max_width = $width;
     109                $max_width  = $width;
    114110                $max_height = $height;
    115111        }
    … …  
    151147function image_hwstring( $width, $height ) {
    152148        $out = '';
    153         if ($width)
    154                 $out .= 'width="'.intval($width).'" ';
    155         if ($height)
    156                 $out .= 'height="'.intval($height).'" ';
     149        if ( $width ) {
     150                $out .= 'width="' . intval( $width ) . '" ';
     151        }
     152        if ( $height ) {
     153                $out .= 'height="' . intval( $height ) . '" ';
     154        }
    157155        return $out;
    158156}
    … …  
    203201        }
    204202
    205         $img_url = wp_get_attachment_url($id);
    206         $meta = wp_get_attachment_metadata($id);
    207         $width = $height = 0;
    208         $is_intermediate = false;
    209         $img_url_basename = wp_basename($img_url);
     203        $img_url          = wp_get_attachment_url( $id );
     204        $meta             = wp_get_attachment_metadata( $id );
     205        $width            = $height = 0;
     206        $is_intermediate  = false;
     207        $img_url_basename = wp_basename( $img_url );
    210208
    211209        // If the file isn't an image, attempt to replace its URL with a rendered image from its meta.
    … …  
    213211        if ( ! $is_image ) {
    214212                if ( ! empty( $meta['sizes'] ) ) {
    215                         $img_url = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url );
     213                        $img_url          = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url );
    216214                        $img_url_basename = $meta['sizes']['full']['file'];
    217                         $width = $meta['sizes']['full']['width'];
    218                         $height = $meta['sizes']['full']['height'];
     215                        $width            = $meta['sizes']['full']['width'];
     216                        $height           = $meta['sizes']['full']['height'];
    219217                } else {
    220218                        return false;
    … …  
    223221
    224222        // try for a new style intermediate size
    225         if ( $intermediate = image_get_intermediate_size($id, $size) ) {
    226                 $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url);
    227                 $width = $intermediate['width'];
    228                 $height = $intermediate['height'];
     223        if ( $intermediate = image_get_intermediate_size( $id, $size ) ) {
     224                $img_url         = str_replace( $img_url_basename, $intermediate['file'], $img_url );
     225                $width           = $intermediate['width'];
     226                $height          = $intermediate['height'];
    229227                $is_intermediate = true;
    230         }
    231         elseif ( $size == 'thumbnail' ) {
     228        } elseif ( $size == 'thumbnail' ) {
    232229                // fall back to the old thumbnail
    233                 if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) {
    234                         $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url);
    235                         $width = $info[0];
    236                         $height = $info[1];
     230                if ( ( $thumb_file = wp_get_attachment_thumb_file( $id ) ) && $info = getimagesize( $thumb_file ) ) {
     231                        $img_url         = str_replace( $img_url_basename, wp_basename( $thumb_file ), $img_url );
     232                        $width           = $info[0];
     233                        $height          = $info[1];
    237234                        $is_intermediate = true;
    238235                }
    239236        }
    240         if ( !$width && !$height && isset( $meta['width'], $meta['height'] ) ) {
     237        if ( ! $width && ! $height && isset( $meta['width'], $meta['height'] ) ) {
    241238                // any other type: use the real image
    242                 $width = $meta['width'];
     239                $width  = $meta['width'];
    243240                $height = $meta['height'];
    244241        }
    245242
    246         if ( $img_url) {
     243        if ( $img_url ) {
    247244                // we have the actual image size, but might need to further constrain it if content_width is narrower
    248245                list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
    … …  
    360357function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) {
    361358
    362         list( $img_src, $width, $height ) = image_downsize($id, $size);
    363         $hwstring = image_hwstring($width, $height);
     359        list( $img_src, $width, $height ) = image_downsize( $id, $size );
     360        $hwstring                         = image_hwstring( $width, $height );
    364361
    365362        $title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
    366363
    367         $class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id;
     364        $class = 'align' . esc_attr( $align ) . ' size-' . esc_attr( $size ) . ' wp-image-' . $id;
    368365
    369366        /**
    … …  
    380377        $class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );
    381378
    382         $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
     379        $html = '<img src="' . esc_attr( $img_src ) . '" alt="' . esc_attr( $alt ) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
    383380
    384381        /**
    … …  
    413410 */
    414411function wp_constrain_dimensions( $current_width, $current_height, $max_width = 0, $max_height = 0 ) {
    415         if ( !$max_width && !$max_height )
     412        if ( ! $max_width && ! $max_height ) {
    416413                return array( $current_width, $current_height );
     414        }
    417415
    418416        $width_ratio = $height_ratio = 1.0;
    419         $did_width = $did_height = false;
     417        $did_width   = $did_height = false;
    420418
    421419        if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) {
    422420                $width_ratio = $max_width / $current_width;
    423                 $did_width = true;
     421                $did_width   = true;
    424422        }
    425423
    426424        if ( $max_height > 0 && $current_height > 0 && $current_height > $max_height ) {
    427425                $height_ratio = $max_height / $current_height;
    428                 $did_height = true;
     426                $did_height   = true;
    429427        }
    430428
    … …  
    434432
    435433        if ( (int) round( $current_width * $larger_ratio ) > $max_width || (int) round( $current_height * $larger_ratio ) > $max_height ) {
    436                 // The larger ratio is too big. It would result in an overflow.
     434                // The larger ratio is too big. It would result in an overflow.
    437435                $ratio = $smaller_ratio;
    438436        } else {
    … …  
    442440
    443441        // Very small dimensions may result in 0, 1 should be the minimum.
    444         $w = max ( 1, (int) round( $current_width * $ratio ) );
    445         $h = max ( 1, (int) round( $current_height * $ratio ) );
     442        $w = max( 1, (int) round( $current_width * $ratio ) );
     443        $h = max( 1, (int) round( $current_height * $ratio ) );
    446444
    447445        // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short
    … …  
    465463         *
    466464         * @param array $dimensions     The image width and height.
    467          * @param int   $current_width  The current width of the image.
    468          * @param int   $current_height The current height of the image.
    469          * @param int   $max_width      The maximum width permitted.
    470          * @param int   $max_height     The maximum height permitted.
     465         * @param int   $current_width  The current width of the image.
     466         * @param int   $current_height The current height of the image.
     467         * @param int   $max_width      The maximum width permitted.
     468         * @param int   $max_height     The maximum height permitted.
    471469         */
    472470        return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height );
    … …  
    499497function image_resize_dimensions( $orig_w, $orig_h, $dest_w, $dest_h, $crop = false ) {
    500498
    501         if ($orig_w <= 0 || $orig_h <= 0)
     499        if ( $orig_w <= 0 || $orig_h <= 0 ) {
    502500                return false;
     501        }
    503502        // at least one of dest_w or dest_h must be specific
    504         if ($dest_w <= 0 && $dest_h <= 0)
     503        if ( $dest_w <= 0 && $dest_h <= 0 ) {
    505504                return false;
     505        }
    506506
    507507        /**
    … …  
    522522         */
    523523        $output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop );
    524         if ( null !== $output )
     524        if ( null !== $output ) {
    525525                return $output;
     526        }
    526527
    527528        if ( $crop ) {
    528529                // crop the largest possible portion of the original image that we can size to $dest_w x $dest_h
    529530                $aspect_ratio = $orig_w / $orig_h;
    530                 $new_w = min($dest_w, $orig_w);
    531                 $new_h = min($dest_h, $orig_h);
     531                $new_w        = min( $dest_w, $orig_w );
     532                $new_h        = min( $dest_h, $orig_h );
    532533
    533534                if ( ! $new_w ) {
    … …  
    539540                }
    540541
    541                 $size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
    542 
    543                 $crop_w = round($new_w / $size_ratio);
    544                 $crop_h = round($new_h / $size_ratio);
     542                $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
     543
     544                $crop_w = round( $new_w / $size_ratio );
     545                $crop_h = round( $new_h / $size_ratio );
    545546
    546547                if ( ! is_array( $crop ) || count( $crop ) !== 2 ) {
    … …  
    607608                $editor = wp_get_image_editor( $file );
    608609
    609                 if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
     610                if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
    610611                        return false;
     612                }
    611613
    612614                $resized_file = $editor->save();
    … …  
    638640        if ( $source_width > $target_width ) {
    639641                $constrained_size = wp_constrain_dimensions( $source_width, $source_height, $target_width );
    640                 $expected_size = array( $target_width, $target_height );
     642                $expected_size    = array( $target_width, $target_height );
    641643        } else {
    642644                $constrained_size = wp_constrain_dimensions( $target_width, $target_height, $source_width );
    643                 $expected_size = array( $source_width, $source_height );
     645                $expected_size    = array( $source_width, $source_height );
    644646        }
    645647
    … …  
    687689 */
    688690function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) {
    689         if ( ! $size || ! is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) || empty( $imagedata['sizes'] )  ) {
     691        if ( ! $size || ! is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) || empty( $imagedata['sizes'] ) ) {
    690692                return false;
    691693        }
    … …  
    731733
    732734                        $data = array_shift( $candidates );
    733                 /*
    734                  * When the size requested is smaller than the thumbnail dimensions, we
    735                  * fall back to the thumbnail size to maintain backwards compatibility with
    736                  * pre 4.6 versions of WordPress.
    737                  */
     735                        /*
     736                        * When the size requested is smaller than the thumbnail dimensions, we
     737                        * fall back to the thumbnail size to maintain backwards compatibility with
     738                        * pre 4.6 versions of WordPress.
     739                        */
    738740                } elseif ( ! empty( $imagedata['sizes']['thumbnail'] ) && $imagedata['sizes']['thumbnail']['width'] >= $size[0] && $imagedata['sizes']['thumbnail']['width'] >= $size[1] ) {
    739741                        $data = $imagedata['sizes']['thumbnail'];
    … …  
    756758        // include the full filesystem path of the intermediate file
    757759        if ( empty( $data['path'] ) && ! empty( $data['file'] ) && ! empty( $imagedata['file'] ) ) {
    758                 $file_url = wp_get_attachment_url($post_id);
    759                 $data['path'] = path_join( dirname($imagedata['file']), $data['file'] );
    760                 $data['url'] = path_join( dirname($file_url), $data['file'] );
     760                $file_url     = wp_get_attachment_url( $post_id );
     761                $data['path'] = path_join( dirname( $imagedata['file'] ), $data['file'] );
     762                $data['url']  = path_join( dirname( $file_url ), $data['file'] );
    761763        }
    762764
    … …  
    786788function get_intermediate_image_sizes() {
    787789        $_wp_additional_image_sizes = wp_get_additional_image_sizes();
    788         $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes
     790        $image_sizes                = array( 'thumbnail', 'medium', 'medium_large', 'large' ); // Standard sizes
    789791        if ( ! empty( $_wp_additional_image_sizes ) ) {
    790792                $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
    … …  
    830832                        $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
    831833
    832                         $src_file = $icon_dir . '/' . wp_basename( $src );
     834                        $src_file                = $icon_dir . '/' . wp_basename( $src );
    833835                        @list( $width, $height ) = getimagesize( $src_file );
    834836                }
    … …  
    869871 * @return string HTML img element or empty string on failure.
    870872 */
    871 function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') {
    872         $html = '';
    873         $image = wp_get_attachment_image_src($attachment_id, $size, $icon);
     873function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = false, $attr = '' ) {
     874        $html  = '';
     875        $image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
    874876        if ( $image ) {
    875877                list($src, $width, $height) = $image;
    876                 $hwstring = image_hwstring($width, $height);
    877                 $size_class = $size;
     878                $hwstring                   = image_hwstring( $width, $height );
     879                $size_class                 = $size;
    878880                if ( is_array( $size_class ) ) {
    879881                        $size_class = join( 'x', $size_class );
    880882                }
    881                 $attachment = get_post($attachment_id);
     883                $attachment   = get_post( $attachment_id );
    882884                $default_attr = array(
    883                         'src'   => $src,
    884                         'class' => "attachment-$size_class size-$size_class",
    885                         'alt'   => trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ),
     885                        'src'   => $src,
     886                        'class' => "attachment-$size_class size-$size_class",
     887                        'alt'   => trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ),
    886888                );
    887889
    … …  
    894896                        if ( is_array( $image_meta ) ) {
    895897                                $size_array = array( absint( $width ), absint( $height ) );
    896                                 $srcset = wp_calculate_image_srcset( $size_array, $src, $image_meta, $attachment_id );
    897                                 $sizes = wp_calculate_image_sizes( $size_array, $src, $image_meta, $attachment_id );
     898                                $srcset     = wp_calculate_image_srcset( $size_array, $src, $image_meta, $attachment_id );
     899                                $sizes      = wp_calculate_image_sizes( $size_array, $src, $image_meta, $attachment_id );
    898900
    899901                                if ( $srcset && ( $sizes || ! empty( $attr['sizes'] ) ) ) {
    … …  
    919921                $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
    920922                $attr = array_map( 'esc_attr', $attr );
    921                 $html = rtrim("<img $hwstring");
     923                $html = rtrim( "<img $hwstring" );
    922924                foreach ( $attr as $name => $value ) {
    923925                        $html .= " $name=" . '"' . $value . '"';
    … …  
    989991                        absint( $image_meta['height'] ),
    990992                );
    991         } elseif ( ! empty( $image_meta['sizes'][$size_name] ) ) {
     993        } elseif ( ! empty( $image_meta['sizes'][ $size_name ] ) ) {
    992994                return array(
    993                         absint( $image_meta['sizes'][$size_name]['width'] ),
    994                         absint( $image_meta['sizes'][$size_name]['height'] ),
     995                        absint( $image_meta['sizes'][ $size_name ]['width'] ),
     996                        absint( $image_meta['sizes'][ $size_name ]['height'] ),
    995997                );
    996998        }
    … …  
    10221024        }
    10231025
    1024         $image_src = $image[0];
     1026        $image_src  = $image[0];
    10251027        $size_array = array(
    10261028                absint( $image[1] ),
    1027                 absint( $image[2] )
     1029                absint( $image[2] ),
    10281030        );
    10291031
    … …  
    10621064
    10631065        // Get the width and height of the image.
    1064         $image_width = (int) $size_array[0];
     1066        $image_width  = (int) $size_array[0];
    10651067        $image_height = (int) $size_array[1];
    10661068
    … …  
    10941096        }
    10951097
    1096         $upload_dir = wp_get_upload_dir();
     1098        $upload_dir    = wp_get_upload_dir();
    10971099        $image_baseurl = trailingslashit( $upload_dir['baseurl'] ) . $dirname;
    10981100
    … …  
    12401242        }
    12411243
    1242         $image_src = $image[0];
     1244        $image_src  = $image[0];
    12431245        $size_array = array(
    12441246                absint( $image[1] ),
    1245                 absint( $image[2] )
     1247                absint( $image[2] ),
    12461248        );
    12471249
    … …  
    13201322        $selected_images = $attachment_ids = array();
    13211323
    1322         foreach( $matches[0] as $image ) {
     1324        foreach ( $matches[0] as $image ) {
    13231325                if ( false === strpos( $image, ' srcset=' ) && preg_match( '/wp-image-([0-9]+)/i', $image, $class_id ) &&
    13241326                        ( $attachment_id = absint( $class_id[1] ) ) ) {
    … …  
    13441346        foreach ( $selected_images as $image => $attachment_id ) {
    13451347                $image_meta = wp_get_attachment_metadata( $attachment_id );
    1346                 $content = str_replace( $image, wp_image_add_srcset_and_sizes( $image, $image_meta, $attachment_id ), $content );
     1348                $content    = str_replace( $image, wp_image_add_srcset_and_sizes( $image, $image_meta, $attachment_id ), $content );
    13471349        }
    13481350
    … …  
    13691371        }
    13701372
    1371         $image_src = preg_match( '/src="([^"]+)"/', $image, $match_src ) ? $match_src[1] : '';
     1373        $image_src         = preg_match( '/src="([^"]+)"/', $image, $match_src ) ? $match_src[1] : '';
    13721374        list( $image_src ) = explode( '?', $image_src );
    13731375
    … …  
    13841386        }
    13851387
    1386         $width  = preg_match( '/ width="([0-9]+)"/',  $image, $match_width  ) ? (int) $match_width[1] : 0;
     1388        $width  = preg_match( '/ width="([0-9]+)"/', $image, $match_width ) ? (int) $match_width[1] : 0;
    13871389        $height = preg_match( '/ height="([0-9]+)"/', $image, $match_height ) ? (int) $match_height[1] : 0;
    13881390
    … …  
    13951397
    13961398                if ( $image_filename === wp_basename( $image_meta['file'] ) ) {
    1397                         $width = (int) $image_meta['width'];
     1399                        $width  = (int) $image_meta['width'];
    13981400                        $height = (int) $image_meta['height'];
    13991401                } else {
    1400                         foreach( $image_meta['sizes'] as $image_size_data ) {
     1402                        foreach ( $image_meta['sizes'] as $image_size_data ) {
    14011403                                if ( $image_filename === $image_size_data['file'] ) {
    1402                                         $width = (int) $image_size_data['width'];
     1404                                        $width  = (int) $image_size_data['width'];
    14031405                                        $height = (int) $image_size_data['height'];
    14041406                                        break;
    … …  
    14131415
    14141416        $size_array = array( $width, $height );
    1415         $srcset = wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attachment_id );
     1417        $srcset     = wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attachment_id );
    14161418
    14171419        if ( $srcset ) {
    … …  
    14821484}
    14831485
    1484 add_shortcode('wp_caption', 'img_caption_shortcode');
    1485 add_shortcode('caption', 'img_caption_shortcode');
     1486add_shortcode( 'wp_caption', 'img_caption_shortcode' );
     1487add_shortcode( 'caption', 'img_caption_shortcode' );
    14861488
    14871489/**
    … …  
    15141516        if ( ! isset( $attr['caption'] ) ) {
    15151517                if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
    1516                         $content = $matches[1];
     1518                        $content         = $matches[1];
    15171519                        $attr['caption'] = trim( $matches[2] );
    15181520                }
    … …  
    15361538         */
    15371539        $output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
    1538         if ( $output != '' )
     1540        if ( $output != '' ) {
    15391541                return $output;
    1540 
    1541         $atts = shortcode_atts( array(
    1542                 'id'      => '',
    1543                 'align'   => 'alignnone',
    1544                 'width'   => '',
    1545                 'caption' => '',
    1546                 'class'   => '',
    1547         ), $attr, 'caption' );
     1542        }
     1543
     1544        $atts = shortcode_atts(
     1545                array(
     1546                        'id'      => '',
     1547                        'align'   => 'alignnone',
     1548                        'width'   => '',
     1549                        'caption' => '',
     1550                        'class'   => '',
     1551                ), $attr, 'caption'
     1552        );
    15481553
    15491554        $atts['width'] = (int) $atts['width'];
    1550         if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
     1555        if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) {
    15511556                return $content;
    1552 
    1553         if ( ! empty( $atts['id'] ) )
     1557        }
     1558
     1559        if ( ! empty( $atts['id'] ) ) {
    15541560                $atts['id'] = 'id="' . esc_attr( sanitize_html_class( $atts['id'] ) ) . '" ';
     1561        }
    15551562
    15561563        $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
    … …  
    15931600}
    15941601
    1595 add_shortcode('gallery', 'gallery_shortcode');
     1602add_shortcode( 'gallery', 'gallery_shortcode' );
    15961603
    15971604/**
    … …  
    16641671
    16651672        $html5 = current_theme_supports( 'html5', 'gallery' );
    1666         $atts = shortcode_atts( array(
    1667                 'order'      => 'ASC',
    1668                 'orderby'    => 'menu_order ID',
    1669                 'id'         => $post ? $post->ID : 0,
    1670                 'itemtag'    => $html5 ? 'figure'     : 'dl',
    1671                 'icontag'    => $html5 ? 'div'        : 'dt',
    1672                 'captiontag' => $html5 ? 'figcaption' : 'dd',
    1673                 'columns'    => 3,
    1674                 'size'       => 'thumbnail',
    1675                 'include'    => '',
    1676                 'exclude'    => '',
    1677                 'link'       => ''
    1678         ), $attr, 'gallery' );
     1673        $atts  = shortcode_atts(
     1674                array(
     1675                        'order'      => 'ASC',
     1676                        'orderby'    => 'menu_order ID',
     1677                        'id'         => $post ? $post->ID : 0,
     1678                        'itemtag'    => $html5 ? 'figure' : 'dl',
     1679                        'icontag'    => $html5 ? 'div' : 'dt',
     1680                        'captiontag' => $html5 ? 'figcaption' : 'dd',
     1681                        'columns'    => 3,
     1682                        'size'       => 'thumbnail',
     1683                        'include'    => '',
     1684                        'exclude'    => '',
     1685                        'link'       => '',
     1686                ), $attr, 'gallery'
     1687        );
    16791688
    16801689        $id = intval( $atts['id'] );
    16811690
    16821691        if ( ! empty( $atts['include'] ) ) {
    1683                 $_attachments = get_posts( array( 'include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1692                $_attachments = get_posts(
     1693                        array(
     1694                                'include'        => $atts['include'],
     1695                                'post_status'    => 'inherit',
     1696                                'post_type'      => 'attachment',
     1697                                'post_mime_type' => 'image',
     1698                                'order'          => $atts['order'],
     1699                                'orderby'        => $atts['orderby'],
     1700                        )
     1701                );
    16841702
    16851703                $attachments = array();
    16861704                foreach ( $_attachments as $key => $val ) {
    1687                         $attachments[$val->ID] = $_attachments[$key];
     1705                        $attachments[ $val->ID ] = $_attachments[ $key ];
    16881706                }
    16891707        } elseif ( ! empty( $atts['exclude'] ) ) {
    1690                 $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1708                $attachments = get_children(
     1709                        array(
     1710                                'post_parent'    => $id,
     1711                                'exclude'        => $atts['exclude'],
     1712                                'post_status'    => 'inherit',
     1713                                'post_type'      => 'attachment',
     1714                                'post_mime_type' => 'image',
     1715                                'order'          => $atts['order'],
     1716                                'orderby'        => $atts['orderby'],
     1717                        )
     1718                );
    16911719        } else {
    1692                 $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1720                $attachments = get_children(
     1721                        array(
     1722                                'post_parent'    => $id,
     1723                                'post_status'    => 'inherit',
     1724                                'post_type'      => 'attachment',
     1725                                'post_mime_type' => 'image',
     1726                                'order'          => $atts['order'],
     1727                                'orderby'        => $atts['orderby'],
     1728                        )
     1729                );
    16931730        }
    16941731
    … …  
    17051742        }
    17061743
    1707         $itemtag = tag_escape( $atts['itemtag'] );
     1744        $itemtag    = tag_escape( $atts['itemtag'] );
    17081745        $captiontag = tag_escape( $atts['captiontag'] );
    1709         $icontag = tag_escape( $atts['icontag'] );
     1746        $icontag    = tag_escape( $atts['icontag'] );
    17101747        $valid_tags = wp_kses_allowed_html( 'post' );
    17111748        if ( ! isset( $valid_tags[ $itemtag ] ) ) {
    … …  
    17191756        }
    17201757
    1721         $columns = intval( $atts['columns'] );
    1722         $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    1723         $float = is_rtl() ? 'right' : 'left';
     1758        $columns   = intval( $atts['columns'] );
     1759        $itemwidth = $columns > 0 ? floor( 100 / $columns ) : 100;
     1760        $float     = is_rtl() ? 'right' : 'left';
    17241761
    17251762        $selector = "gallery-{$instance}";
    … …  
    17581795        }
    17591796
    1760         $size_class = sanitize_html_class( $atts['size'] );
     1797        $size_class  = sanitize_html_class( $atts['size'] );
    17611798        $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    17621799
    … …  
    17821819                        $image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr );
    17831820                }
    1784                 $image_meta  = wp_get_attachment_metadata( $id );
     1821                $image_meta = wp_get_attachment_metadata( $id );
    17851822
    17861823                $orientation = '';
    … …  
    17931830                                $image_output
    17941831                        </{$icontag}>";
    1795                 if ( $captiontag && trim($attachment->post_excerpt) ) {
     1832                if ( $captiontag && trim( $attachment->post_excerpt ) ) {
    17961833                        $output .= "
    17971834                                <{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
    1798                                 " . wptexturize($attachment->post_excerpt) . "
     1835                                " . wptexturize( $attachment->post_excerpt ) . "
    17991836                                </{$captiontag}>";
    18001837                }
    … …  
    18281865        <# } #>
    18291866        <div class="wp-playlist-caption">
    1830                 <span class="wp-playlist-item-meta wp-playlist-item-title"><?php
     1867                <span class="wp-playlist-item-meta wp-playlist-item-title">
     1868                <?php
    18311869                        /* translators: playlist item title */
    18321870                        printf( _x( '&#8220;%s&#8221;', 'playlist item title' ), '{{ data.title }}' );
    1833                 ?></span>
     1871                ?>
     1872                </span>
    18341873                <# if ( data.meta.album ) { #><span class="wp-playlist-item-meta wp-playlist-item-album">{{ data.meta.album }}</span><# } #>
    18351874                <# if ( data.meta.artist ) { #><span class="wp-playlist-item-meta wp-playlist-item-artist">{{ data.meta.artist }}</span><# } #>
    … …  
    18431882                                {{ data.caption }}
    18441883                        <# } else { #>
    1845                                 <span class="wp-playlist-item-title"><?php
     1884                                <span class="wp-playlist-item-title">
     1885                                <?php
    18461886                                        /* translators: playlist item title */
    18471887                                        printf( _x( '&#8220;%s&#8221;', 'playlist item title' ), '{{{ data.title }}}' );
    1848                                 ?></span>
     1888                                ?>
     1889                                </span>
    18491890                                <# if ( data.artists && data.meta.artist ) { #>
    18501891                                <span class="wp-playlist-item-artist"> &mdash; {{ data.meta.artist }}</span>
    … …  
    18711912        wp_enqueue_script( 'wp-playlist' );
    18721913?>
    1873 <!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ) ?>');</script><![endif]-->
     1914<!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ); ?>');</script><![endif]-->
    18741915<?php
    18751916        add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
    … …  
    19471988        }
    19481989
    1949         $atts = shortcode_atts( array(
    1950                 'type'          => 'audio',
    1951                 'order'         => 'ASC',
    1952                 'orderby'       => 'menu_order ID',
    1953                 'id'            => $post ? $post->ID : 0,
    1954                 'include'       => '',
    1955                 'exclude'   => '',
    1956                 'style'         => 'light',
    1957                 'tracklist' => true,
    1958                 'tracknumbers' => true,
    1959                 'images'        => true,
    1960                 'artists'       => true
    1961         ), $attr, 'playlist' );
     1990        $atts = shortcode_atts(
     1991                array(
     1992                        'type'         => 'audio',
     1993                        'order'        => 'ASC',
     1994                        'orderby'      => 'menu_order ID',
     1995                        'id'           => $post ? $post->ID : 0,
     1996                        'include'      => '',
     1997                        'exclude'      => '',
     1998                        'style'        => 'light',
     1999                        'tracklist'    => true,
     2000                        'tracknumbers' => true,
     2001                        'images'       => true,
     2002                        'artists'      => true,
     2003                ), $attr, 'playlist'
     2004        );
    19622005
    19632006        $id = intval( $atts['id'] );
    … …  
    19682011
    19692012        $args = array(
    1970                 'post_status' => 'inherit',
    1971                 'post_type' => 'attachment',
     2013                'post_status'    => 'inherit',
     2014                'post_type'      => 'attachment',
    19722015                'post_mime_type' => $atts['type'],
    1973                 'order' => $atts['order'],
    1974                 'orderby' => $atts['orderby']
     2016                'order'          => $atts['order'],
     2017                'orderby'        => $atts['orderby'],
    19752018        );
    19762019
    19772020        if ( ! empty( $atts['include'] ) ) {
    19782021                $args['include'] = $atts['include'];
    1979                 $_attachments = get_posts( $args );
     2022                $_attachments    = get_posts( $args );
    19802023
    19812024                $attachments = array();
    19822025                foreach ( $_attachments as $key => $val ) {
    1983                         $attachments[$val->ID] = $_attachments[$key];
     2026                        $attachments[ $val->ID ] = $_attachments[ $key ];
    19842027                }
    19852028        } elseif ( ! empty( $atts['exclude'] ) ) {
    19862029                $args['post_parent'] = $id;
    1987                 $args['exclude'] = $atts['exclude'];
    1988                 $attachments = get_children( $args );
     2030                $args['exclude']     = $atts['exclude'];
     2031                $attachments         = get_children( $args );
    19892032        } else {
    19902033                $args['post_parent'] = $id;
    1991                 $attachments = get_children( $args );
     2034                $attachments         = get_children( $args );
    19922035        }
    19932036
    … …  
    20062049        $outer = 22; // default padding and border of wrapper
    20072050
    2008         $default_width = 640;
     2051        $default_width  = 640;
    20092052        $default_height = 360;
    20102053
    2011         $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer );
     2054        $theme_width  = empty( $content_width ) ? $default_width : ( $content_width - $outer );
    20122055        $theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width );
    20132056
    20142057        $data = array(
    2015                 'type' => $atts['type'],
     2058                'type'         => $atts['type'],
    20162059                // don't pass strings to JSON, will be truthy in JS
    2017                 'tracklist' => wp_validate_boolean( $atts['tracklist'] ),
     2060                'tracklist'    => wp_validate_boolean( $atts['tracklist'] ),
    20182061                'tracknumbers' => wp_validate_boolean( $atts['tracknumbers'] ),
    2019                 'images' => wp_validate_boolean( $atts['images'] ),
    2020                 'artists' => wp_validate_boolean( $atts['artists'] ),
     2062                'images'       => wp_validate_boolean( $atts['images'] ),
     2063                'artists'      => wp_validate_boolean( $atts['artists'] ),
    20212064        );
    20222065
    20232066        $tracks = array();
    20242067        foreach ( $attachments as $attachment ) {
    2025                 $url = wp_get_attachment_url( $attachment->ID );
     2068                $url   = wp_get_attachment_url( $attachment->ID );
    20262069                $ftype = wp_check_filetype( $url, wp_get_mime_types() );
    20272070                $track = array(
    2028                         'src' => $url,
    2029                         'type' => $ftype['type'],
    2030                         'title' => $attachment->post_title,
    2031                         'caption' => $attachment->post_excerpt,
    2032                         'description' => $attachment->post_content
     2071                        'src'         => $url,
     2072                        'type'        => $ftype['type'],
     2073                        'title'       => $attachment->post_title,
     2074                        'caption'     => $attachment->post_excerpt,
     2075                        'description' => $attachment->post_content,
    20332076                );
    20342077
    20352078                $track['meta'] = array();
    2036                 $meta = wp_get_attachment_metadata( $attachment->ID );
     2079                $meta          = wp_get_attachment_metadata( $attachment->ID );
    20372080                if ( ! empty( $meta ) ) {
    20382081
    … …  
    20452088                        if ( 'video' === $atts['type'] ) {
    20462089                                if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
    2047                                         $width = $meta['width'];
    2048                                         $height = $meta['height'];
     2090                                        $width        = $meta['width'];
     2091                                        $height       = $meta['height'];
    20492092                                        $theme_height = round( ( $height * $theme_width ) / $width );
    20502093                                } else {
    2051                                         $width = $default_width;
     2094                                        $width  = $default_width;
    20522095                                        $height = $default_height;
    20532096                                }
    … …  
    20552098                                $track['dimensions'] = array(
    20562099                                        'original' => compact( 'width', 'height' ),
    2057                                         'resized' => array(
    2058                                                 'width' => $theme_width,
    2059                                                 'height' => $theme_height
    2060                                         )
     2100                                        'resized'  => array(
     2101                                                'width'  => $theme_width,
     2102                                                'height' => $theme_height,
     2103                                        ),
    20612104                                );
    20622105                        }
    … …  
    20672110                        if ( ! empty( $thumb_id ) ) {
    20682111                                list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' );
    2069                                 $track['image'] = compact( 'src', 'width', 'height' );
     2112                                $track['image']               = compact( 'src', 'width', 'height' );
    20702113                                list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
    2071                                 $track['thumb'] = compact( 'src', 'width', 'height' );
     2114                                $track['thumb']               = compact( 'src', 'width', 'height' );
    20722115                        } else {
    2073                                 $src = wp_mime_type_icon( $attachment->ID );
    2074                                 $width = 48;
    2075                                 $height = 64;
     2116                                $src            = wp_mime_type_icon( $attachment->ID );
     2117                                $width          = 48;
     2118                                $height         = 64;
    20762119                                $track['image'] = compact( 'src', 'width', 'height' );
    20772120                                $track['thumb'] = compact( 'src', 'width', 'height' );
    … …  
    20832126        $data['tracks'] = $tracks;
    20842127
    2085         $safe_type = esc_attr( $atts['type'] );
     2128        $safe_type  = esc_attr( $atts['type'] );
    20862129        $safe_style = esc_attr( $atts['style'] );
    20872130
    … …  
    20982141                 */
    20992142                do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
    2100         } ?>
    2101 <div class="wp-playlist wp-<?php echo $safe_type ?>-playlist wp-playlist-<?php echo $safe_style ?>">
    2102         <?php if ( 'audio' === $atts['type'] ): ?>
     2143        }
     2144        ?>
     2145<div class="wp-playlist wp-<?php echo $safe_type; ?>-playlist wp-playlist-<?php echo $safe_style; ?>">
     2146        <?php if ( 'audio' === $atts['type'] ) : ?>
    21032147        <div class="wp-playlist-current-item"></div>
    21042148        <?php endif ?>
    2105         <<?php echo $safe_type ?> controls="controls" preload="none" width="<?php
    2106                 echo (int) $theme_width;
    2107         ?>"<?php if ( 'video' === $safe_type ):
     2149        <<?php echo $safe_type; ?> controls="controls" preload="none" width="
     2150                                <?php
     2151                                echo (int) $theme_width;
     2152        ?>
     2153        "
     2154        <?php
     2155        if ( 'video' === $safe_type ) :
    21082156                echo ' height="', (int) $theme_height, '"';
    2109         endif; ?>></<?php echo $safe_type ?>>
     2157        endif;
     2158        ?>
     2159        ></<?php echo $safe_type; ?>>
    21102160        <div class="wp-playlist-next"></div>
    21112161        <div class="wp-playlist-prev"></div>
    21122162        <noscript>
    2113         <ol><?php
     2163        <ol>
     2164        <?php
    21142165        foreach ( $attachments as $att_id => $attachment ) {
    21152166                printf( '<li>%s</li>', wp_get_attachment_link( $att_id ) );
    21162167        }
    2117         ?></ol>
     2168        ?>
     2169        </ol>
    21182170        </noscript>
    2119         <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ) ?></script>
     2171        <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ); ?></script>
    21202172</div>
    21212173        <?php
    … …  
    21752227        $fields = array(
    21762228                'artist' => __( 'Artist' ),
    2177                 'album' => __( 'Album' ),
     2229                'album'  => __( 'Album' ),
    21782230        );
    21792231
    … …  
    21832235                $fields['length_formatted'] = _x( 'Length', 'video or audio' );
    21842236        } elseif ( 'js' === $context ) {
    2185                 $fields['bitrate']          = __( 'Bitrate' );
    2186                 $fields['bitrate_mode']     = __( 'Bitrate Mode' );
     2237                $fields['bitrate']      = __( 'Bitrate' );
     2238                $fields['bitrate_mode'] = __( 'Bitrate Mode' );
    21872239        }
    21882240
    … …  
    22532305                'preload'  => 'none',
    22542306                'class'    => 'wp-audio-shortcode',
    2255                 'style'    => 'width: 100%;'
     2307                'style'    => 'width: 100%;',
    22562308        );
    22572309        foreach ( $default_types as $type ) {
    2258                 $defaults_atts[$type] = '';
     2310                $defaults_atts[ $type ] = '';
    22592311        }
    22602312
    … …  
    22862338                }
    22872339
    2288                 $audio = reset( $audios );
     2340                $audio       = reset( $audios );
    22892341                $atts['src'] = wp_get_attachment_url( $audio->ID );
    22902342                if ( empty( $atts['src'] ) ) {
    … …  
    23302382        // These ones should just be omitted altogether if they are blank
    23312383        foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) {
    2332                 if ( empty( $html_atts[$a] ) ) {
    2333                         unset( $html_atts[$a] );
     2384                if ( empty( $html_atts[ $a ] ) ) {
     2385                        unset( $html_atts[ $a ] );
    23342386                }
    23352387        }
    … …  
    23472399
    23482400        $fileurl = '';
    2349         $source = '<source type="%s" src="%s" />';
     2401        $source  = '<source type="%s" src="%s" />';
    23502402        foreach ( $default_types as $fallback ) {
    23512403                if ( ! empty( $atts[ $fallback ] ) ) {
    … …  
    23532405                                $fileurl = $atts[ $fallback ];
    23542406                        }
    2355                         $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
    2356                         $url = add_query_arg( '_', $instance, $atts[ $fallback ] );
     2407                        $type  = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
     2408                        $url   = add_query_arg( '_', $instance, $atts[ $fallback ] );
    23572409                        $html .= sprintf( $source, $type['type'], esc_url( $url ) );
    23582410                }
    … …  
    24682520
    24692521        foreach ( $default_types as $type ) {
    2470                 $defaults_atts[$type] = '';
     2522                $defaults_atts[ $type ] = '';
    24712523        }
    24722524
    … …  
    24772529                if ( $atts['width'] > $defaults_atts['width'] ) {
    24782530                        $atts['height'] = round( ( $atts['height'] * $defaults_atts['width'] ) / $atts['width'] );
    2479                         $atts['width'] = $defaults_atts['width'];
     2531                        $atts['width']  = $defaults_atts['width'];
    24802532                }
    24812533        } else {
    … …  
    24832535                if ( ! empty( $content_width ) && $atts['width'] > $content_width ) {
    24842536                        $atts['height'] = round( ( $atts['height'] * $content_width ) / $atts['width'] );
    2485                         $atts['width'] = $content_width;
    2486                 }
    2487         }
    2488 
    2489         $is_vimeo = $is_youtube = false;
    2490         $yt_pattern = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#';
     2537                        $atts['width']  = $content_width;
     2538                }
     2539        }
     2540
     2541        $is_vimeo      = $is_youtube = false;
     2542        $yt_pattern    = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#';
    24912543        $vimeo_pattern = '#^https?://(.+\.)?vimeo\.com/.*#';
    24922544
    24932545        $primary = false;
    24942546        if ( ! empty( $atts['src'] ) ) {
    2495                 $is_vimeo = ( preg_match( $vimeo_pattern, $atts['src'] ) );
    2496                 $is_youtube = (  preg_match( $yt_pattern, $atts['src'] ) );
     2547                $is_vimeo   = ( preg_match( $vimeo_pattern, $atts['src'] ) );
     2548                $is_youtube = ( preg_match( $yt_pattern, $atts['src'] ) );
    24972549                if ( ! $is_youtube && ! $is_vimeo ) {
    24982550                        $type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
    … …  
    25032555
    25042556                if ( $is_vimeo ) {
    2505                     wp_enqueue_script( 'mediaelement-vimeo' );
     2557                        wp_enqueue_script( 'mediaelement-vimeo' );
    25062558                }
    25072559
    … …  
    25252577                }
    25262578
    2527                 $video = reset( $videos );
     2579                $video       = reset( $videos );
    25282580                $atts['src'] = wp_get_attachment_url( $video->ID );
    25292581                if ( empty( $atts['src'] ) ) {
    … …  
    25582610                        // Remove all query arguments and force SSL - see #40866.
    25592611                        $parsed_vimeo_url = wp_parse_url( $atts['src'] );
    2560                         $vimeo_src = 'https://' . $parsed_vimeo_url['host'] . $parsed_vimeo_url['path'];
     2612                        $vimeo_src        = 'https://' . $parsed_vimeo_url['host'] . $parsed_vimeo_url['path'];
    25612613
    25622614                        // Add loop param for mejs bug - see #40977, not needed after #39686.
    2563                         $loop = $atts['loop'] ? '1' : '0';
     2615                        $loop        = $atts['loop'] ? '1' : '0';
    25642616                        $atts['src'] = add_query_arg( 'loop', $loop, $vimeo_src );
    25652617                }
    … …  
    25902642        // These ones should just be omitted altogether if they are blank
    25912643        foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) {
    2592                 if ( empty( $html_atts[$a] ) ) {
    2593                         unset( $html_atts[$a] );
     2644                if ( empty( $html_atts[ $a ] ) ) {
     2645                        unset( $html_atts[ $a ] );
    25942646                }
    25952647        }
    … …  
    26072659
    26082660        $fileurl = '';
    2609         $source = '<source type="%s" src="%s" />';
     2661        $source  = '<source type="%s" src="%s" />';
    26102662        foreach ( $default_types as $fallback ) {
    26112663                if ( ! empty( $atts[ $fallback ] ) ) {
    … …  
    26202672                                $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
    26212673                        }
    2622                         $url = add_query_arg( '_', $instance, $atts[ $fallback ] );
     2674                        $url   = add_query_arg( '_', $instance, $atts[ $fallback ] );
    26232675                        $html .= sprintf( $source, $type['type'], esc_url( $url ) );
    26242676                }
    … …  
    26712723 */
    26722724function previous_image_link( $size = 'thumbnail', $text = false ) {
    2673         adjacent_image_link(true, $size, $text);
     2725        adjacent_image_link( true, $size, $text );
    26742726}
    26752727
    … …  
    26872739 */
    26882740function next_image_link( $size = 'thumbnail', $text = false ) {
    2689         adjacent_image_link(false, $size, $text);
     2741        adjacent_image_link( false, $size, $text );
    26902742}
    26912743
    … …  
    27032755 */
    27042756function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) {
    2705         $post = get_post();
    2706         $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
     2757        $post        = get_post();
     2758        $attachments = array_values(
     2759                get_children(
     2760                        array(
     2761                                'post_parent'    => $post->post_parent,
     2762                                'post_status'    => 'inherit',
     2763                                'post_type'      => 'attachment',
     2764                                'post_mime_type' => 'image',
     2765                                'order'          => 'ASC',
     2766                                'orderby'        => 'menu_order ID',
     2767                        )
     2768                )
     2769        );
    27072770
    27082771        foreach ( $attachments as $k => $attachment ) {
    … …  
    27122775        }
    27132776
    2714         $output = '';
     2777        $output        = '';
    27152778        $attachment_id = 0;
    27162779
    … …  
    27202783                if ( isset( $attachments[ $k ] ) ) {
    27212784                        $attachment_id = $attachments[ $k ]->ID;
    2722                         $output = wp_get_attachment_link( $attachment_id, $size, true, false, $text );
     2785                        $output        = wp_get_attachment_link( $attachment_id, $size, true, false, $text );
    27232786                }
    27242787        }
    … …  
    27602823                $attachment = (object) $attachment;
    27612824        }
    2762         if ( ! is_object($attachment) )
     2825        if ( ! is_object( $attachment ) ) {
    27632826                return array();
    2764 
    2765         $file = get_attached_file( $attachment->ID );
     2827        }
     2828
     2829        $file     = get_attached_file( $attachment->ID );
    27662830        $filename = basename( $file );
    27672831
    2768         $objects = array('attachment');
    2769 
    2770         if ( false !== strpos($filename, '.') )
    2771                 $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1);
    2772         if ( !empty($attachment->post_mime_type) ) {
     2832        $objects = array( 'attachment' );
     2833
     2834        if ( false !== strpos( $filename, '.' ) ) {
     2835                $objects[] = 'attachment:' . substr( $filename, strrpos( $filename, '.' ) + 1 );
     2836        }
     2837        if ( ! empty( $attachment->post_mime_type ) ) {
    27732838                $objects[] = 'attachment:' . $attachment->post_mime_type;
    2774                 if ( false !== strpos($attachment->post_mime_type, '/') )
    2775                         foreach ( explode('/', $attachment->post_mime_type) as $token )
    2776                                 if ( !empty($token) )
     2839                if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
     2840                        foreach ( explode( '/', $attachment->post_mime_type ) as $token ) {
     2841                                if ( ! empty( $token ) ) {
    27772842                                        $objects[] = "attachment:$token";
     2843                                }
     2844                        }
     2845                }
    27782846        }
    27792847
    … …  
    28102878                foreach ( $taxonomy->object_type as $object_type ) {
    28112879                        if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
    2812                                 if ( 'names' == $output )
     2880                                if ( 'names' == $output ) {
    28132881                                        $taxonomies[] = $taxonomy->name;
    2814                                 else
     2882                                } else {
    28152883                                        $taxonomies[ $taxonomy->name ] = $taxonomy;
     2884                                }
    28162885                                break;
    28172886                        }
    … …  
    28332902 * @return resource The GD image resource.
    28342903 */
    2835 function wp_imagecreatetruecolor($width, $height) {
    2836         $img = imagecreatetruecolor($width, $height);
    2837         if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
    2838                 imagealphablending($img, false);
    2839                 imagesavealpha($img, true);
     2904function wp_imagecreatetruecolor( $width, $height ) {
     2905        $img = imagecreatetruecolor( $width, $height );
     2906        if ( is_resource( $img ) && function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) {
     2907                imagealphablending( $img, false );
     2908                imagesavealpha( $img, true );
    28402909        }
    28412910        return $img;
    … …  
    29062975                // If $file_info['type'] is false, then we let the editor attempt to
    29072976                // figure out the file type, rather than forcing a failure based on extension.
    2908                 if ( isset( $file_info ) && $file_info['type'] )
     2977                if ( isset( $file_info ) && $file_info['type'] ) {
    29092978                        $args['mime_type'] = $file_info['type'];
     2979                }
    29102980        }
    29112981
    … …  
    29162986                $loaded = $editor->load();
    29172987
    2918                 if ( is_wp_error( $loaded ) )
     2988                if ( is_wp_error( $loaded ) ) {
    29192989                        return $loaded;
     2990                }
    29202991
    29212992                return $editor;
    29222993        }
    29232994
    2924         return new WP_Error( 'image_no_editor', __('No editor could be selected.') );
     2995        return new WP_Error( 'image_no_editor', __( 'No editor could be selected.' ) );
    29252996}
    29262997
    … …  
    29633034
    29643035        foreach ( $implementations as $implementation ) {
    2965                 if ( ! call_user_func( array( $implementation, 'test' ), $args ) )
     3036                if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) {
    29663037                        continue;
     3038                }
    29673039
    29683040                if ( isset( $args['mime_type'] ) &&
    29693041                        ! call_user_func(
    29703042                                array( $implementation, 'supports_mime_type' ),
    2971                                 $args['mime_type'] ) ) {
     3043                                $args['mime_type']
     3044                        ) ) {
    29723045                        continue;
    29733046                }
    … …  
    29943067
    29953068        $data = $wp_scripts->get_data( 'wp-plupload', 'data' );
    2996         if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) )
     3069        if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) ) {
    29973070                return;
    2998 
    2999         $max_upload_size = wp_max_upload_size();
     3071        }
     3072
     3073        $max_upload_size    = wp_max_upload_size();
    30003074        $allowed_extensions = array_keys( get_allowed_mime_types() );
    3001         $extensions = array();
     3075        $extensions         = array();
    30023076        foreach ( $allowed_extensions as $extension ) {
    30033077                $extensions = array_merge( $extensions, explode( '|', $extension ) );
    … …  
    30093083         */
    30103084        $defaults = array(
    3011                 'file_data_name'      => 'async-upload', // key passed to $_FILE.
    3012                 'url'                 => admin_url( 'async-upload.php', 'relative' ),
    3013                 'filters' => array(
    3014                         'max_file_size'   => $max_upload_size . 'b',
    3015                         'mime_types'      => array( array( 'extensions' => implode( ',', $extensions ) ) ),
     3085                'file_data_name' => 'async-upload', // key passed to $_FILE.
     3086                'url'            => admin_url( 'async-upload.php', 'relative' ),
     3087                'filters'        => array(
     3088                        'max_file_size' => $max_upload_size . 'b',
     3089                        'mime_types'    => array( array( 'extensions' => implode( ',', $extensions ) ) ),
    30163090                ),
    30173091        );
    … …  
    30453119         * @param array $params Default Plupload parameters array.
    30463120         */
    3047         $params = apply_filters( 'plupload_default_params', $params );
    3048         $params['_wpnonce'] = wp_create_nonce( 'media-form' );
     3121        $params                       = apply_filters( 'plupload_default_params', $params );
     3122        $params['_wpnonce']           = wp_create_nonce( 'media-form' );
    30493123        $defaults['multipart_params'] = $params;
    30503124
    30513125        $settings = array(
    3052                 'defaults' => $defaults,
    3053                 'browser'  => array(
     3126                'defaults'      => $defaults,
     3127                'browser'       => array(
    30543128                        'mobile'    => wp_is_mobile(),
    30553129                        'supported' => _device_can_upload(),
    30563130                ),
    3057                 'limitExceeded' => is_multisite() && ! is_upload_space_available()
     3131                'limitExceeded' => is_multisite() && ! is_upload_space_available(),
    30583132        );
    30593133
    30603134        $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';';
    30613135
    3062         if ( $data )
     3136        if ( $data ) {
    30633137                $script = "$data\n$script";
     3138        }
    30643139
    30653140        $wp_scripts->add_data( 'wp-plupload', 'data', $script );
    … …  
    30763151 */
    30773152function wp_prepare_attachment_for_js( $attachment ) {
    3078         if ( ! $attachment = get_post( $attachment ) )
     3153        if ( ! $attachment = get_post( $attachment ) ) {
    30793154                return;
    3080 
    3081         if ( 'attachment' != $attachment->post_type )
     3155        }
     3156
     3157        if ( 'attachment' != $attachment->post_type ) {
    30823158                return;
     3159        }
    30833160
    30843161        $meta = wp_get_attachment_metadata( $attachment->ID );
    3085         if ( false !== strpos( $attachment->post_mime_type, '/' ) )
     3162        if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
    30863163                list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
    3087         else
     3164        } else {
    30883165                list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
     3166        }
    30893167
    30903168        $attachment_url = wp_get_attachment_url( $attachment->ID );
    3091         $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
     3169        $base_url       = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
    30923170
    30933171        $response = array(
    3094                 'id'          => $attachment->ID,
    3095                 'title'       => $attachment->post_title,
    3096                 'filename'    => wp_basename( get_attached_file( $attachment->ID ) ),
    3097                 'url'         => $attachment_url,
    3098                 'link'        => get_attachment_link( $attachment->ID ),
    3099                 'alt'         => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
    3100                 'author'      => $attachment->post_author,
    3101                 'description' => $attachment->post_content,
    3102                 'caption'     => $attachment->post_excerpt,
    3103                 'name'        => $attachment->post_name,
    3104                 'status'      => $attachment->post_status,
    3105                 'uploadedTo'  => $attachment->post_parent,
    3106                 'date'        => strtotime( $attachment->post_date_gmt ) * 1000,
    3107                 'modified'    => strtotime( $attachment->post_modified_gmt ) * 1000,
    3108                 'menuOrder'   => $attachment->menu_order,
    3109                 'mime'        => $attachment->post_mime_type,
    3110                 'type'        => $type,
    3111                 'subtype'     => $subtype,
    3112                 'icon'        => wp_mime_type_icon( $attachment->ID ),
     3172                'id'            => $attachment->ID,
     3173                'title'         => $attachment->post_title,
     3174                'filename'      => wp_basename( get_attached_file( $attachment->ID ) ),
     3175                'url'           => $attachment_url,
     3176                'link'          => get_attachment_link( $attachment->ID ),
     3177                'alt'           => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
     3178                'author'        => $attachment->post_author,
     3179                'description'   => $attachment->post_content,
     3180                'caption'       => $attachment->post_excerpt,
     3181                'name'          => $attachment->post_name,
     3182                'status'        => $attachment->post_status,
     3183                'uploadedTo'    => $attachment->post_parent,
     3184                'date'          => strtotime( $attachment->post_date_gmt ) * 1000,
     3185                'modified'      => strtotime( $attachment->post_modified_gmt ) * 1000,
     3186                'menuOrder'     => $attachment->menu_order,
     3187                'mime'          => $attachment->post_mime_type,
     3188                'type'          => $type,
     3189                'subtype'       => $subtype,
     3190                'icon'          => wp_mime_type_icon( $attachment->ID ),
    31133191                'dateFormatted' => mysql2date( __( 'F j, Y' ), $attachment->post_date ),
    3114                 'nonces'      => array(
     3192                'nonces'        => array(
    31153193                        'update' => false,
    31163194                        'delete' => false,
    3117                         'edit'   => false
     3195                        'edit'   => false,
    31183196                ),
    3119                 'editLink'   => false,
    3120                 'meta'       => false,
     3197                'editLink'      => false,
     3198                'meta'          => false,
    31213199        );
    31223200
    … …  
    31573235
    31583236        if ( $bytes ) {
    3159                 $response['filesizeInBytes'] = $bytes;
     3237                $response['filesizeInBytes']       = $bytes;
    31603238                $response['filesizeHumanReadable'] = size_format( $bytes );
    31613239        }
    31623240
    3163         $context = get_post_meta( $attachment->ID, '_wp_attachment_context', true );
     3241        $context             = get_post_meta( $attachment->ID, '_wp_attachment_context', true );
    31643242        $response['context'] = ( $context ) ? $context : '';
    31653243
    31663244        if ( current_user_can( 'edit_post', $attachment->ID ) ) {
    31673245                $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );
    3168                 $response['nonces']['edit'] = wp_create_nonce( 'image_editor-' . $attachment->ID );
    3169                 $response['editLink'] = get_edit_post_link( $attachment->ID, 'raw' );
    3170         }
    3171 
    3172         if ( current_user_can( 'delete_post', $attachment->ID ) )
     3246                $response['nonces']['edit']   = wp_create_nonce( 'image_editor-' . $attachment->ID );
     3247                $response['editLink']         = get_edit_post_link( $attachment->ID, 'raw' );
     3248        }
     3249
     3250        if ( current_user_can( 'delete_post', $attachment->ID ) ) {
    31733251                $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID );
     3252        }
    31743253
    31753254        if ( $meta && ( 'image' === $type || ! empty( $meta['sizes'] ) ) ) {
    … …  
    31773256
    31783257                /** This filter is documented in wp-admin/includes/media.php */
    3179                 $possible_sizes = apply_filters( 'image_size_names_choose', array(
    3180                         'thumbnail' => __('Thumbnail'),
    3181                         'medium'    => __('Medium'),
    3182                         'large'     => __('Large'),
    3183                         'full'      => __('Full Size'),
    3184                 ) );
     3258                $possible_sizes = apply_filters(
     3259                        'image_size_names_choose', array(
     3260                                'thumbnail' => __( 'Thumbnail' ),
     3261                                'medium'    => __( 'Medium' ),
     3262                                'large'     => __( 'Large' ),
     3263                                'full'      => __( 'Full Size' ),
     3264                        )
     3265                );
    31853266                unset( $possible_sizes['full'] );
    31863267
    … …  
    32243305
    32253306                        if ( isset( $meta['height'], $meta['width'] ) ) {
    3226                                 $sizes['full']['height'] = $meta['height'];
    3227                                 $sizes['full']['width'] = $meta['width'];
     3307                                $sizes['full']['height']      = $meta['height'];
     3308                                $sizes['full']['width']       = $meta['width'];
    32283309                                $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape';
    32293310                        }
    … …  
    32353316                                'height'      => $meta['sizes']['full']['height'],
    32363317                                'width'       => $meta['sizes']['full']['width'],
    3237                                 'orientation' => $meta['sizes']['full']['height'] > $meta['sizes']['full']['width'] ? 'portrait' : 'landscape'
     3318                                'orientation' => $meta['sizes']['full']['height'] > $meta['sizes']['full']['width'] ? 'portrait' : 'landscape',
    32383319                        );
    32393320                }
    … …  
    32433324
    32443325        if ( $meta && 'video' === $type ) {
    3245                 if ( isset( $meta['width'] ) )
     3326                if ( isset( $meta['width'] ) ) {
    32463327                        $response['width'] = (int) $meta['width'];
    3247                 if ( isset( $meta['height'] ) )
     3328                }
     3329                if ( isset( $meta['height'] ) ) {
    32483330                        $response['height'] = (int) $meta['height'];
     3331                }
    32493332        }
    32503333
    32513334        if ( $meta && ( 'audio' === $type || 'video' === $type ) ) {
    3252                 if ( isset( $meta['length_formatted'] ) )
     3335                if ( isset( $meta['length_formatted'] ) ) {
    32533336                        $response['fileLength'] = $meta['length_formatted'];
     3337                }
    32543338
    32553339                $response['meta'] = array();
    … …  
    32653349                if ( ! empty( $id ) ) {
    32663350                        list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'full' );
    3267                         $response['image'] = compact( 'src', 'width', 'height' );
     3351                        $response['image']            = compact( 'src', 'width', 'height' );
    32683352                        list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'thumbnail' );
    3269                         $response['thumb'] = compact( 'src', 'width', 'height' );
     3353                        $response['thumb']            = compact( 'src', 'width', 'height' );
    32703354                } else {
    3271                         $src = wp_mime_type_icon( $attachment->ID );
    3272                         $width = 48;
    3273                         $height = 64;
     3355                        $src               = wp_mime_type_icon( $attachment->ID );
     3356                        $width             = 48;
     3357                        $height            = 64;
    32743358                        $response['image'] = compact( 'src', 'width', 'height' );
    32753359                        $response['thumb'] = compact( 'src', 'width', 'height' );
    … …  
    32773361        }
    32783362
    3279         if ( function_exists('get_compat_media_markup') )
     3363        if ( function_exists( 'get_compat_media_markup' ) ) {
    32803364                $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) );
     3365        }
    32813366
    32823367        /**
    … …  
    33103395function wp_enqueue_media( $args = array() ) {
    33113396        // Enqueue me just once per page, please.
    3312         if ( did_action( 'wp_enqueue_media' ) )
     3397        if ( did_action( 'wp_enqueue_media' ) ) {
    33133398                return;
     3399        }
    33143400
    33153401        global $content_width, $wpdb, $wp_locale;
    … …  
    33183404                'post' => null,
    33193405        );
    3320         $args = wp_parse_args( $args, $defaults );
     3406        $args     = wp_parse_args( $args, $defaults );
    33213407
    33223408        // We're going to pass the old thickbox media tabs to `media_upload_tabs`
    … …  
    33403426        );
    33413427
    3342         $exts = array_merge( wp_get_audio_extensions(), wp_get_video_extensions() );
    3343         $mimes = get_allowed_mime_types();
     3428        $exts      = array_merge( wp_get_audio_extensions(), wp_get_video_extensions() );
     3429        $mimes     = get_allowed_mime_types();
    33443430        $ext_mimes = array();
    33453431        foreach ( $exts as $ext ) {
    … …  
    33713457        $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true );
    33723458        if ( null === $show_audio_playlist ) {
    3373                 $show_audio_playlist = $wpdb->get_var( "
     3459                $show_audio_playlist = $wpdb->get_var(
     3460                        "
    33743461                        SELECT ID
    33753462                        FROM $wpdb->posts
    … …  
    33773464                        AND post_mime_type LIKE 'audio%'
    33783465                        LIMIT 1
    3379                 " );
     3466                "
     3467                );
    33803468        }
    33813469
    … …  
    33993487        $show_video_playlist = apply_filters( 'media_library_show_video_playlist', true );
    34003488        if ( null === $show_video_playlist ) {
    3401                 $show_video_playlist = $wpdb->get_var( "
     3489                $show_video_playlist = $wpdb->get_var(
     3490                        "
    34023491                        SELECT ID
    34033492                        FROM $wpdb->posts
    … …  
    34053494                        AND post_mime_type LIKE 'video%'
    34063495                        LIMIT 1
    3407                 " );
     3496                "
     3497                );
    34083498        }
    34093499
    … …  
    34263516        $months = apply_filters( 'media_library_months_with_files', null );
    34273517        if ( ! is_array( $months ) ) {
    3428                 $months = $wpdb->get_results( $wpdb->prepare( "
     3518                $months = $wpdb->get_results(
     3519                        $wpdb->prepare(
     3520                                "
    34293521                        SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    34303522                        FROM $wpdb->posts
    34313523                        WHERE post_type = %s
    34323524                        ORDER BY post_date DESC
    3433                 ", 'attachment' ) );
     3525                ", 'attachment'
     3526                        )
     3527                );
    34343528        }
    34353529        foreach ( $months as $month_year ) {
    … …  
    34383532
    34393533        $settings = array(
    3440                 'tabs'      => $tabs,
    3441                 'tabUrl'    => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ),
    3442                 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ),
     3534                'tabs'             => $tabs,
     3535                'tabUrl'           => add_query_arg( array( 'chromeless' => true ), admin_url( 'media-upload.php' ) ),
     3536                'mimeTypes'        => wp_list_pluck( get_post_mime_types(), 0 ),
    34433537                /** This filter is documented in wp-admin/includes/media.php */
    3444                 'captions'  => ! apply_filters( 'disable_captions', '' ),
    3445                 'nonce'     => array(
     3538                'captions'         => ! apply_filters( 'disable_captions', '' ),
     3539                'nonce'            => array(
    34463540                        'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ),
    34473541                ),
    3448                 'post'    => array(
     3542                'post'             => array(
    34493543                        'id' => 0,
    34503544                ),
    3451                 'defaultProps' => $props,
     3545                'defaultProps'     => $props,
    34523546                'attachmentCounts' => array(
    34533547                        'audio' => ( $show_audio_playlist ) ? 1 : 0,
    34543548                        'video' => ( $show_video_playlist ) ? 1 : 0,
    34553549                ),
    3456                 'oEmbedProxyUrl' => rest_url( 'oembed/1.0/proxy' ),
    3457                 'embedExts'    => $exts,
    3458                 'embedMimes'   => $ext_mimes,
    3459                 'contentWidth' => $content_width,
    3460                 'months'       => $months,
    3461                 'mediaTrash'   => MEDIA_TRASH ? 1 : 0,
     3550                'oEmbedProxyUrl'   => rest_url( 'oembed/1.0/proxy' ),
     3551                'embedExts'        => $exts,
     3552                'embedMimes'       => $ext_mimes,
     3553                'contentWidth'     => $content_width,
     3554                'months'           => $months,
     3555                'mediaTrash'       => MEDIA_TRASH ? 1 : 0,
    34623556        );
    34633557
    34643558        $post = null;
    34653559        if ( isset( $args['post'] ) ) {
    3466                 $post = get_post( $args['post'] );
     3560                $post             = get_post( $args['post'] );
    34673561                $settings['post'] = array(
    3468                         'id' => $post->ID,
     3562                        'id'    => $post->ID,
    34693563                        'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
    34703564                );
    … …  
    34803574
    34813575                if ( $thumbnail_support ) {
    3482                         $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
     3576                        $featured_image_id                   = get_post_meta( $post->ID, '_thumbnail_id', true );
    34833577                        $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
    34843578                }
    … …  
    34933587        $strings = array(
    34943588                // Generic
    3495                 'url'         => __( 'URL' ),
    3496                 'addMedia'    => __( 'Add Media' ),
    3497                 'search'      => __( 'Search' ),
    3498                 'select'      => __( 'Select' ),
    3499                 'cancel'      => __( 'Cancel' ),
    3500                 'update'      => __( 'Update' ),
    3501                 'replace'     => __( 'Replace' ),
    3502                 'remove'      => __( 'Remove' ),
    3503                 'back'        => __( 'Back' ),
     3589                'url'                         => __( 'URL' ),
     3590                'addMedia'                    => __( 'Add Media' ),
     3591                'search'                      => __( 'Search' ),
     3592                'select'                      => __( 'Select' ),
     3593                'cancel'                      => __( 'Cancel' ),
     3594                'update'                      => __( 'Update' ),
     3595                'replace'                     => __( 'Replace' ),
     3596                'remove'                      => __( 'Remove' ),
     3597                'back'                        => __( 'Back' ),
    35043598                /*
    35053599                 * translators: This is a would-be plural string used in the media manager.
    … …  
    35073601                 * lack of plural support here, turn it into "selected: %d" then translate it.
    35083602                 */
    3509                 'selected'    => __( '%d selected' ),
    3510                 'dragInfo'    => __( 'Drag and drop to reorder media files.' ),
     3603                'selected'                    => __( '%d selected' ),
     3604                'dragInfo'                    => __( 'Drag and drop to reorder media files.' ),
    35113605
    35123606                // Upload
    3513                 'uploadFilesTitle'  => __( 'Upload Files' ),
    3514                 'uploadImagesTitle' => __( 'Upload Images' ),
     3607                'uploadFilesTitle'            => __( 'Upload Files' ),
     3608                'uploadImagesTitle'           => __( 'Upload Images' ),
    35153609
    35163610                // Library
    3517                 'mediaLibraryTitle'      => __( 'Media Library' ),
    3518                 'insertMediaTitle'       => __( 'Add Media' ),
    3519                 'createNewGallery'       => __( 'Create a new gallery' ),
    3520                 'createNewPlaylist'      => __( 'Create a new playlist' ),
    3521                 'createNewVideoPlaylist' => __( 'Create a new video playlist' ),
    3522                 'returnToLibrary'        => __( '&#8592; Return to library' ),
    3523                 'allMediaItems'          => __( 'All media items' ),
    3524                 'allDates'               => __( 'All dates' ),
    3525                 'noItemsFound'           => __( 'No items found.' ),
    3526                 'insertIntoPost'         => $post_type_object->labels->insert_into_item,
    3527                 'unattached'             => __( 'Unattached' ),
    3528                 'trash'                  => _x( 'Trash', 'noun' ),
    3529                 'uploadedToThisPost'     => $post_type_object->labels->uploaded_to_this_item,
    3530                 'warnDelete'             => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
    3531                 'warnBulkDelete'         => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
    3532                 'warnBulkTrash'          => __( "You are about to trash these items.\n  'Cancel' to stop, 'OK' to delete." ),
    3533                 'bulkSelect'             => __( 'Bulk Select' ),
    3534                 'cancelSelection'        => __( 'Cancel Selection' ),
    3535                 'trashSelected'          => __( 'Trash Selected' ),
    3536                 'untrashSelected'        => __( 'Untrash Selected' ),
    3537                 'deleteSelected'         => __( 'Delete Selected' ),
    3538                 'deletePermanently'      => __( 'Delete Permanently' ),
    3539                 'apply'                  => __( 'Apply' ),
    3540                 'filterByDate'           => __( 'Filter by date' ),
    3541                 'filterByType'           => __( 'Filter by type' ),
    3542                 'searchMediaLabel'       => __( 'Search Media' ),
    3543                 'searchMediaPlaceholder' => __( 'Search media items...' ), // placeholder (no ellipsis)
    3544                 'noMedia'                => __( 'No media files found.' ),
     3611                'mediaLibraryTitle'           => __( 'Media Library' ),
     3612                'insertMediaTitle'            => __( 'Add Media' ),
     3613                'createNewGallery'            => __( 'Create a new gallery' ),
     3614                'createNewPlaylist'           => __( 'Create a new playlist' ),
     3615                'createNewVideoPlaylist'      => __( 'Create a new video playlist' ),
     3616                'returnToLibrary'             => __( '&#8592; Return to library' ),
     3617                'allMediaItems'               => __( 'All media items' ),
     3618                'allDates'                    => __( 'All dates' ),
     3619                'noItemsFound'                => __( 'No items found.' ),
     3620                'insertIntoPost'              => $post_type_object->labels->insert_into_item,
     3621                'unattached'                  => __( 'Unattached' ),
     3622                'trash'                       => _x( 'Trash', 'noun' ),
     3623                'uploadedToThisPost'          => $post_type_object->labels->uploaded_to_this_item,
     3624                'warnDelete'                  => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
     3625                'warnBulkDelete'              => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
     3626                'warnBulkTrash'               => __( "You are about to trash these items.\n  'Cancel' to stop, 'OK' to delete." ),
     3627                'bulkSelect'                  => __( 'Bulk Select' ),
     3628                'cancelSelection'             => __( 'Cancel Selection' ),
     3629                'trashSelected'               => __( 'Trash Selected' ),
     3630                'untrashSelected'             => __( 'Untrash Selected' ),
     3631                'deleteSelected'              => __( 'Delete Selected' ),
     3632                'deletePermanently'           => __( 'Delete Permanently' ),
     3633                'apply'                       => __( 'Apply' ),
     3634                'filterByDate'                => __( 'Filter by date' ),
     3635                'filterByType'                => __( 'Filter by type' ),
     3636                'searchMediaLabel'            => __( 'Search Media' ),
     3637                'searchMediaPlaceholder'      => __( 'Search media items...' ), // placeholder (no ellipsis)
     3638                'noMedia'                     => __( 'No media files found.' ),
    35453639
    35463640                // Library Details
    3547                 'attachmentDetails'  => __( 'Attachment Details' ),
     3641                'attachmentDetails'           => __( 'Attachment Details' ),
    35483642
    35493643                // From URL
    3550                 'insertFromUrlTitle' => __( 'Insert from URL' ),
     3644                'insertFromUrlTitle'          => __( 'Insert from URL' ),
    35513645
    35523646                // Featured Images
    3553                 'setFeaturedImageTitle' => $post_type_object->labels->featured_image,
    3554                 'setFeaturedImage'      => $post_type_object->labels->set_featured_image,
     3647                'setFeaturedImageTitle'       => $post_type_object->labels->featured_image,
     3648                'setFeaturedImage'            => $post_type_object->labels->set_featured_image,
    35553649
    35563650                // Gallery
    3557                 'createGalleryTitle' => __( 'Create Gallery' ),
    3558                 'editGalleryTitle'   => __( 'Edit Gallery' ),
    3559                 'cancelGalleryTitle' => __( '&#8592; Cancel Gallery' ),
    3560                 'insertGallery'      => __( 'Insert gallery' ),
    3561                 'updateGallery'      => __( 'Update gallery' ),
    3562                 'addToGallery'       => __( 'Add to gallery' ),
    3563                 'addToGalleryTitle'  => __( 'Add to Gallery' ),
    3564                 'reverseOrder'       => __( 'Reverse order' ),
     3651                'createGalleryTitle'          => __( 'Create Gallery' ),
     3652                'editGalleryTitle'            => __( 'Edit Gallery' ),
     3653                'cancelGalleryTitle'          => __( '&#8592; Cancel Gallery' ),
     3654                'insertGallery'               => __( 'Insert gallery' ),
     3655                'updateGallery'               => __( 'Update gallery' ),
     3656                'addToGallery'                => __( 'Add to gallery' ),
     3657                'addToGalleryTitle'           => __( 'Add to Gallery' ),
     3658                'reverseOrder'                => __( 'Reverse order' ),
    35653659
    35663660                // Edit Image
    3567                 'imageDetailsTitle'     => __( 'Image Details' ),
    3568                 'imageReplaceTitle'     => __( 'Replace Image' ),
    3569                 'imageDetailsCancel'    => __( 'Cancel Edit' ),
    3570                 'editImage'             => __( 'Edit Image' ),
     3661                'imageDetailsTitle'           => __( 'Image Details' ),
     3662                'imageReplaceTitle'           => __( 'Replace Image' ),
     3663                'imageDetailsCancel'          => __( 'Cancel Edit' ),
     3664                'editImage'                   => __( 'Edit Image' ),
    35713665
    35723666                // Crop Image
    3573                 'chooseImage' => __( 'Choose Image' ),
    3574                 'selectAndCrop' => __( 'Select and Crop' ),
    3575                 'skipCropping' => __( 'Skip Cropping' ),
    3576                 'cropImage' => __( 'Crop Image' ),
    3577                 'cropYourImage' => __( 'Crop your image' ),
    3578                 'cropping' => __( 'Cropping&hellip;' ),
     3667                'chooseImage'                 => __( 'Choose Image' ),
     3668                'selectAndCrop'               => __( 'Select and Crop' ),
     3669                'skipCropping'                => __( 'Skip Cropping' ),
     3670                'cropImage'                   => __( 'Crop Image' ),
     3671                'cropYourImage'               => __( 'Crop your image' ),
     3672                'cropping'                    => __( 'Cropping&hellip;' ),
    35793673                /* translators: 1: suggested width number, 2: suggested height number. */
    3580                 'suggestedDimensions' => __( 'Suggested image dimensions: %1$s by %2$s pixels.' ),
    3581                 'cropError' => __( 'There has been an error cropping your image.' ),
     3674                'suggestedDimensions'         => __( 'Suggested image dimensions: %1$s by %2$s pixels.' ),
     3675                'cropError'                   => __( 'There has been an error cropping your image.' ),
    35823676
    35833677                // Edit Audio
    3584                 'audioDetailsTitle'     => __( 'Audio Details' ),
    3585                 'audioReplaceTitle'     => __( 'Replace Audio' ),
    3586                 'audioAddSourceTitle'   => __( 'Add Audio Source' ),
    3587                 'audioDetailsCancel'    => __( 'Cancel Edit' ),
     3678                'audioDetailsTitle'           => __( 'Audio Details' ),
     3679                'audioReplaceTitle'           => __( 'Replace Audio' ),
     3680                'audioAddSourceTitle'         => __( 'Add Audio Source' ),
     3681                'audioDetailsCancel'          => __( 'Cancel Edit' ),
    35883682
    35893683                // Edit Video
    3590                 'videoDetailsTitle'     => __( 'Video Details' ),
    3591                 'videoReplaceTitle'     => __( 'Replace Video' ),
    3592                 'videoAddSourceTitle'   => __( 'Add Video Source' ),
    3593                 'videoDetailsCancel'    => __( 'Cancel Edit' ),
     3684                'videoDetailsTitle'           => __( 'Video Details' ),
     3685                'videoReplaceTitle'           => __( 'Replace Video' ),
     3686                'videoAddSourceTitle'         => __( 'Add Video Source' ),
     3687                'videoDetailsCancel'          => __( 'Cancel Edit' ),
    35943688                'videoSelectPosterImageTitle' => __( 'Select Poster Image' ),
    3595                 'videoAddTrackTitle'    => __( 'Add Subtitles' ),
    3596 
    3597                 // Playlist
    3598                 'playlistDragInfo'    => __( 'Drag and drop to reorder tracks.' ),
    3599                 'createPlaylistTitle' => __( 'Create Audio Playlist' ),
    3600                 'editPlaylistTitle'   => __( 'Edit Audio Playlist' ),
    3601                 'cancelPlaylistTitle' => __( '&#8592; Cancel Audio Playlist' ),
    3602                 'insertPlaylist'      => __( 'Insert audio playlist' ),
    3603                 'updatePlaylist'      => __( 'Update audio playlist' ),
    3604                 'addToPlaylist'       => __( 'Add to audio playlist' ),
    3605                 'addToPlaylistTitle'  => __( 'Add to Audio Playlist' ),
    3606 
    3607                 // Video Playlist
    3608                 'videoPlaylistDragInfo'    => __( 'Drag and drop to reorder videos.' ),
    3609                 'createVideoPlaylistTitle' => __( 'Create Video Playlist' ),
    3610                 'editVideoPlaylistTitle'   => __( 'Edit Video Playlist' ),
    3611                 'cancelVideoPlaylistTitle' => __( '&#8592; Cancel Video Playlist' ),
    3612                 'insertVideoPlaylist'      => __( 'Insert video playlist' ),
    3613                 'updateVideoPlaylist'      => __( 'Update video playlist' ),
    3614                 'addToVideoPlaylist'       => __( 'Add to video playlist' ),
    3615                 'addToVideoPlaylistTitle'  => __( 'Add to Video Playlist' ),
     3689                'videoAddTrackTitle'          => __( 'Add Subtitles' ),
     3690
     3691                // Playlist
     3692                'playlistDragInfo'            => __( 'Drag and drop to reorder tracks.' ),
     3693                'createPlaylistTitle'        => __( 'Create Audio Playlist' ),
     3694                'editPlaylistTitle'           => __( 'Edit Audio Playlist' ),
     3695                'cancelPlaylistTitle'        => __( '&#8592; Cancel Audio Playlist' ),
     3696                'insertPlaylist'              => __( 'Insert audio playlist' ),
     3697                'updatePlaylist'              => __( 'Update audio playlist' ),
     3698                'addToPlaylist'               => __( 'Add to audio playlist' ),
     3699                'addToPlaylistTitle'          => __( 'Add to Audio Playlist' ),
     3700
     3701                // Video Playlist
     3702                'videoPlaylistDragInfo'       => __( 'Drag and drop to reorder videos.' ),
     3703                'createVideoPlaylistTitle'    => __( 'Create Video Playlist' ),
     3704                'editVideoPlaylistTitle'      => __( 'Edit Video Playlist' ),
     3705                'cancelVideoPlaylistTitle'    => __( '&#8592; Cancel Video Playlist' ),
     3706                'insertVideoPlaylist'         => __( 'Insert video playlist' ),
     3707                'updateVideoPlaylist'         => __( 'Update video playlist' ),
     3708                'addToVideoPlaylist'          => __( 'Add to video playlist' ),
     3709                'addToVideoPlaylistTitle'     => __( 'Add to Video Playlist' ),
    36163710        );
    36173711
    … …  
    36343728         * @param WP_Post $post    Post object.
    36353729         */
    3636         $strings = apply_filters( 'media_view_strings', $strings,  $post );
     3730        $strings = apply_filters( 'media_view_strings', $strings, $post );
    36373731
    36383732        $strings['settings'] = $settings;
    … …  
    36753769 */
    36763770function get_attached_media( $type, $post = 0 ) {
    3677         if ( ! $post = get_post( $post ) )
     3771        if ( ! $post = get_post( $post ) ) {
    36783772                return array();
     3773        }
    36793774
    36803775        $args = array(
    3681                 'post_parent' => $post->ID,
    3682                 'post_type' => 'attachment',
     3776                'post_parent'    => $post->ID,
     3777                'post_type'      => 'attachment',
    36833778                'post_mime_type' => $type,
    36843779                'posts_per_page' => -1,
    3685                 'orderby' => 'menu_order',
    3686                 'order' => 'ASC',
     3780                'orderby'        => 'menu_order',
     3781                'order'          => 'ASC',
    36873782        );
    36883783
    … …  
    37643859 */
    37653860function get_post_galleries( $post, $html = true ) {
    3766         if ( ! $post = get_post( $post ) )
     3861        if ( ! $post = get_post( $post ) ) {
    37673862                return array();
    3768 
    3769         if ( ! has_shortcode( $post->post_content, 'gallery' ) )
     3863        }
     3864
     3865        if ( ! has_shortcode( $post->post_content, 'gallery' ) ) {
    37703866                return array();
     3867        }
    37713868
    37723869        $galleries = array();
    … …  
    38003897                                                $shortcode_attrs,
    38013898                                                array(
    3802                                                         'src' => array_values( array_unique( $srcs ) )
     3899                                                        'src' => array_values( array_unique( $srcs ) ),
    38033900                                                )
    38043901                                        );
    … …  
    38303927function get_post_gallery( $post = 0, $html = true ) {
    38313928        $galleries = get_post_galleries( $post, $html );
    3832         $gallery = reset( $galleries );
     3929        $gallery   = reset( $galleries );
    38333930
    38343931        /**
    … …  
    38903987        $meta = wp_get_attachment_metadata( $attachment_id );
    38913988        if ( empty( $meta ) && file_exists( $file ) ) {
    3892                 $_meta = get_post_meta( $attachment_id );
     3989                $_meta             = get_post_meta( $attachment_id );
    38933990                $regeneration_lock = 'wp_generating_att_' . $attachment_id;
    38943991                if ( ! array_key_exists( '_wp_attachment_metadata', $_meta ) && ! get_transient( $regeneration_lock ) ) {
    … …  
    39134010        global $wpdb;
    39144011
    3915         $dir = wp_get_upload_dir();
     4012        $dir  = wp_get_upload_dir();
    39164013        $path = $url;
    39174014
    3918         $site_url = parse_url( $dir['url'] );
     4015        $site_url   = parse_url( $dir['url'] );
    39194016        $image_path = parse_url( $path );
    39204017
    … …  
    39284025        }
    39294026
    3930         $sql = $wpdb->prepare(
     4027        $sql     = $wpdb->prepare(
    39314028                "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s",
    39324029                $path
    … …  
    39534050 */
    39544051function wpview_media_sandbox_styles() {
    3955         $version = 'ver=' . get_bloginfo( 'version' );
    3956         $mediaelement = includes_url( "js/mediaelement/mediaelementplayer-legacy.min.css?$version" );
    3957         $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );
     4052        $version        = 'ver=' . get_bloginfo( 'version' );
     4053        $mediaelement  = includes_url( "js/mediaelement/mediaelementplayer-legacy.min.css?$version" );
     4054        $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );
    39584055
    39594056        return array( $mediaelement, $wpmediaelement );
Note: See TracChangeset for help on using the changeset viewer.