WordPress.org

Make WordPress Core

Changeset 41343


Ignore:
Timestamp:
09/08/2017 06:03:09 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Twenty Sixteen: Replace inline control structureв to improve code readability.

Fixes #38468.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentysixteen/functions.php

    r41341 r41343  
    372372    $width = $size[0];
    373373
    374     840 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px';
     374    if ( 840 <= $width ){
     375        $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px';
     376    }
    375377
    376378    if ( 'page' === get_post_type() ) {
    377         840 > $width && $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px';
     379        if ( 840 > $width ) {
     380            $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px';
     381        }
    378382    } else {
    379         840 > $width && 600 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px';
    380         600 > $width && $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px';
     383        if ( 840 > $width && 600 <= $width ) {
     384            $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px';
     385        } elseif ( 600 > $width ) {
     386            $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px';
     387        }
    381388    }
    382389
     
    398405function twentysixteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
    399406    if ( 'post-thumbnail' === $size ) {
    400         is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px';
    401         ! is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px';
     407        if ( is_active_sidebar( 'sidebar-1' ) ) {
     408            $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px';
     409        } else {
     410            $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px';
     411        }
    402412    }
    403413    return $attr;
Note: See TracChangeset for help on using the changeset viewer.