Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42228 r42343  
    6060
    6161    // This theme uses wp_nav_menu() in two locations.
    62     register_nav_menus( array(
    63         'top'    => __( 'Top Menu', 'twentyseventeen' ),
    64         'social' => __( 'Social Links Menu', 'twentyseventeen' ),
    65     ) );
     62    register_nav_menus(
     63        array(
     64            'top'    => __( 'Top Menu', 'twentyseventeen' ),
     65            'social' => __( 'Social Links Menu', 'twentyseventeen' ),
     66        )
     67    );
    6668
    6769    /*
     
    6971     * to output valid HTML5.
    7072     */
    71     add_theme_support( 'html5', array(
    72         'comment-form',
    73         'comment-list',
    74         'gallery',
    75         'caption',
    76     ) );
     73    add_theme_support(
     74        'html5', array(
     75            'comment-form',
     76            'comment-list',
     77            'gallery',
     78            'caption',
     79        )
     80    );
    7781
    7882    /*
     
    8185     * See: https://codex.wordpress.org/Post_Formats
    8286     */
    83     add_theme_support( 'post-formats', array(
    84         'aside',
    85         'image',
    86         'video',
    87         'quote',
    88         'link',
    89         'gallery',
    90         'audio',
    91     ) );
     87    add_theme_support(
     88        'post-formats', array(
     89            'aside',
     90            'image',
     91            'video',
     92            'quote',
     93            'link',
     94            'gallery',
     95            'audio',
     96        )
     97    );
    9298
    9399    // Add theme support for Custom Logo.
    94     add_theme_support( 'custom-logo', array(
    95         'width'       => 250,
    96         'height'      => 250,
    97         'flex-width'  => true,
    98     ) );
     100    add_theme_support(
     101        'custom-logo', array(
     102            'width'      => 250,
     103            'height'     => 250,
     104            'flex-width' => true,
     105        )
     106    );
    99107
    100108    // Add theme support for selective refresh for widgets.
     
    104112     * This theme styles the visual editor to resemble the theme style,
    105113     * specifically font, colors, and column width.
    106     */
     114      */
    107115    add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
    108116
    109117    // Define and register starter content to showcase the theme on new sites.
    110118    $starter_content = array(
    111         'widgets' => array(
     119        'widgets'     => array(
    112120            // Place three core-defined widgets in the sidebar area.
    113121            'sidebar-1' => array(
     
    130138
    131139        // Specify the core-defined pages to create and add custom thumbnails to some of them.
    132         'posts' => array(
     140        'posts'       => array(
    133141            'home',
    134             'about' => array(
     142            'about'            => array(
    135143                'thumbnail' => '{{image-sandwich}}',
    136144            ),
    137             'contact' => array(
     145            'contact'          => array(
    138146                'thumbnail' => '{{image-espresso}}',
    139147            ),
    140             'blog' => array(
     148            'blog'             => array(
    141149                'thumbnail' => '{{image-coffee}}',
    142150            ),
     
    150158            'image-espresso' => array(
    151159                'post_title' => _x( 'Espresso', 'Theme starter content', 'twentyseventeen' ),
    152                 'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
     160                'file'       => 'assets/images/espresso.jpg', // URL relative to the template directory.
    153161            ),
    154162            'image-sandwich' => array(
    155163                'post_title' => _x( 'Sandwich', 'Theme starter content', 'twentyseventeen' ),
    156                 'file' => 'assets/images/sandwich.jpg',
    157             ),
    158             'image-coffee' => array(
     164                'file'       => 'assets/images/sandwich.jpg',
     165            ),
     166            'image-coffee'   => array(
    159167                'post_title' => _x( 'Coffee', 'Theme starter content', 'twentyseventeen' ),
    160                 'file' => 'assets/images/coffee.jpg',
     168                'file'       => 'assets/images/coffee.jpg',
    161169            ),
    162170        ),
    163171
    164172        // Default to a static front page and assign the front and posts pages.
    165         'options' => array(
    166             'show_on_front' => 'page',
    167             'page_on_front' => '{{home}}',
     173        'options'     => array(
     174            'show_on_front'  => 'page',
     175            'page_on_front'  => '{{home}}',
    168176            'page_for_posts' => '{{blog}}',
    169177        ),
    170178
    171179        // Set the front page section theme mods to the IDs of the core-registered pages.
    172         'theme_mods' => array(
     180        'theme_mods'  => array(
    173181            'panel_1' => '{{homepage-section}}',
    174182            'panel_2' => '{{about}}',
     
    178186
    179187        // Set up nav menus for each of the two areas registered in the theme.
    180         'nav_menus' => array(
     188        'nav_menus'   => array(
    181189            // Assign a menu to the "top" location.
    182             'top' => array(
    183                 'name' => __( 'Top Menu', 'twentyseventeen' ),
     190            'top'    => array(
     191                'name'  => __( 'Top Menu', 'twentyseventeen' ),
    184192                'items' => array(
    185193                    'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
     
    192200            // Assign a menu to the "social" location.
    193201            'social' => array(
    194                 'name' => __( 'Social Links Menu', 'twentyseventeen' ),
     202                'name'  => __( 'Social Links Menu', 'twentyseventeen' ),
    195203                'items' => array(
    196204                    'link_yelp',
     
    312320 */
    313321function twentyseventeen_widgets_init() {
    314     register_sidebar( array(
    315         'name'          => __( 'Blog Sidebar', 'twentyseventeen' ),
    316         'id'            => 'sidebar-1',
    317         'description'   => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'twentyseventeen' ),
    318         'before_widget' => '<section id="%1$s" class="widget %2$s">',
    319         'after_widget'  => '</section>',
    320         'before_title'  => '<h2 class="widget-title">',
    321         'after_title'   => '</h2>',
    322     ) );
    323 
    324     register_sidebar( array(
    325         'name'          => __( 'Footer 1', 'twentyseventeen' ),
    326         'id'            => 'sidebar-2',
    327         'description'   => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
    328         'before_widget' => '<section id="%1$s" class="widget %2$s">',
    329         'after_widget'  => '</section>',
    330         'before_title'  => '<h2 class="widget-title">',
    331         'after_title'   => '</h2>',
    332     ) );
    333 
    334     register_sidebar( array(
    335         'name'          => __( 'Footer 2', 'twentyseventeen' ),
    336         'id'            => 'sidebar-3',
    337         'description'   => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
    338         'before_widget' => '<section id="%1$s" class="widget %2$s">',
    339         'after_widget'  => '</section>',
    340         'before_title'  => '<h2 class="widget-title">',
    341         'after_title'   => '</h2>',
    342     ) );
     322    register_sidebar(
     323        array(
     324            'name'          => __( 'Blog Sidebar', 'twentyseventeen' ),
     325            'id'            => 'sidebar-1',
     326            'description'   => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'twentyseventeen' ),
     327            'before_widget' => '<section id="%1$s" class="widget %2$s">',
     328            'after_widget'  => '</section>',
     329            'before_title'  => '<h2 class="widget-title">',
     330            'after_title'   => '</h2>',
     331        )
     332    );
     333
     334    register_sidebar(
     335        array(
     336            'name'          => __( 'Footer 1', 'twentyseventeen' ),
     337            'id'            => 'sidebar-2',
     338            'description'   => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
     339            'before_widget' => '<section id="%1$s" class="widget %2$s">',
     340            'after_widget'  => '</section>',
     341            'before_title'  => '<h2 class="widget-title">',
     342            'after_title'   => '</h2>',
     343        )
     344    );
     345
     346    register_sidebar(
     347        array(
     348            'name'          => __( 'Footer 2', 'twentyseventeen' ),
     349            'id'            => 'sidebar-3',
     350            'description'   => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
     351            'before_widget' => '<section id="%1$s" class="widget %2$s">',
     352            'after_widget'  => '</section>',
     353            'before_title'  => '<h2 class="widget-title">',
     354            'after_title'   => '</h2>',
     355        )
     356    );
    343357}
    344358add_action( 'widgets_init', 'twentyseventeen_widgets_init' );
     
    358372    }
    359373
    360     $link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
     374    $link = sprintf(
     375        '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
    361376        esc_url( get_permalink( get_the_ID() ) ),
    362377        /* translators: %s: Name of current post */
     
    408423        <?php echo twentyseventeen_custom_colors_css(); ?>
    409424    </style>
    410 <?php }
     425<?php
     426}
    411427add_action( 'wp_head', 'twentyseventeen_colors_css_wrap' );
    412428
     
    443459
    444460    $twentyseventeen_l10n = array(
    445         'quote'          => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
     461        'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
    446462    );
    447463
    448464    if ( has_nav_menu( 'top' ) ) {
    449465        wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '1.0', true );
    450         $twentyseventeen_l10n['expand']         = __( 'Expand child menu', 'twentyseventeen' );
    451         $twentyseventeen_l10n['collapse']       = __( 'Collapse child menu', 'twentyseventeen' );
    452         $twentyseventeen_l10n['icon']           = twentyseventeen_get_svg( array( 'icon' => 'angle-down', 'fallback' => true ) );
     466        $twentyseventeen_l10n['expand']   = __( 'Expand child menu', 'twentyseventeen' );
     467        $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
     468        $twentyseventeen_l10n['icon']     = twentyseventeen_get_svg(
     469            array(
     470                'icon'     => 'angle-down',
     471                'fallback' => true,
     472            )
     473        );
    453474    }
    454475
     
    545566    return is_home() ? '' : $template;
    546567}
    547 add_filter( 'frontpage_template',  'twentyseventeen_front_page_template' );
     568add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' );
    548569
    549570/**
Note: See TracChangeset for help on using the changeset viewer.