diff --git a/CHANGELOG.md b/CHANGELOG.md index 18875ed..94f1c05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Change theme name from Roots to Sage * Bump required PHP version to >=5.4 * Add namespace +* Use short array syntax * Use short echo syntax * Switch from Grunt to gulp, new workflow * Use wiredep for Sass and Less injection diff --git a/functions.php b/functions.php index 0b4a2a5..c90e6bb 100644 --- a/functions.php +++ b/functions.php @@ -9,7 +9,7 @@ * * @link https://github.com/roots/sage/pull/1042 */ -$sage_includes = array( +$sage_includes = [ 'lib/utils.php', // Utility functions 'lib/init.php', // Initial theme setup and constants 'lib/wrapper.php', // Theme wrapper class @@ -20,7 +20,7 @@ $sage_includes = array( 'lib/nav.php', // Custom nav modifications 'lib/gallery.php', // Custom [gallery] modifications 'lib/extras.php', // Custom functions -); +]; foreach ($sage_includes as $file) { if (!$filepath = locate_template($file)) { diff --git a/lib/assets.php b/lib/assets.php index cf2b943..cc3690d 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -47,7 +47,7 @@ function assets() { if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); - wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', array(), null, true); + wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', [], null, true); add_filter('script_loader_src', __NAMESPACE__ . '\\jquery_local_fallback', 10, 2); } @@ -56,9 +56,9 @@ function assets() { wp_enqueue_script('comment-reply'); } - wp_enqueue_script('modernizr', asset_path('scripts/modernizr.js'), array(), null, true); + wp_enqueue_script('modernizr', asset_path('scripts/modernizr.js'), [], null, true); wp_enqueue_script('jquery'); - wp_enqueue_script('sage_js', asset_path('scripts/app.js'), array(), null, true); + wp_enqueue_script('sage_js', asset_path('scripts/app.js'), [], null, true); } add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100); diff --git a/lib/config.php b/lib/config.php index ed22120..6e9b735 100644 --- a/lib/config.php +++ b/lib/config.php @@ -48,21 +48,21 @@ function display_sidebar() { * * To use a function that accepts arguments, use the following format: * - * array('function_name', array('arg1', 'arg2')) + * ['function_name', ['arg1', 'arg2']] * * The second element must be an array even if there's only 1 argument. */ - array( + [ 'is_404', 'is_front_page' - ), + ], /** * Page template checks (via is_page_template()) * Any of these page templates that return true won't show the sidebar */ - array( + [ 'template-custom.php' - ) + ] ); $display = apply_filters('sage/display_sidebar', $sidebar_config->display); } diff --git a/lib/gallery.php b/lib/gallery.php index 874a8e1..fc56908 100644 --- a/lib/gallery.php +++ b/lib/gallery.php @@ -36,7 +36,7 @@ function gallery($attr) { } } - extract(shortcode_atts(array( + extract(shortcode_atts([ 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, @@ -48,7 +48,7 @@ function gallery($attr) { 'include' => '', 'exclude' => '', 'link' => '' - ), $attr)); + ], $attr)); $id = intval($id); $columns = (12 % $columns == 0) ? $columns: 4; @@ -59,16 +59,16 @@ function gallery($attr) { } if (!empty($include)) { - $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); + $_attachments = get_posts(['include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]); - $attachments = array(); + $attachments = []; foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { - $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); + $attachments = get_children(['post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]); } else { - $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); + $attachments = get_children(['post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]); } if (empty($attachments)) { @@ -93,7 +93,7 @@ function gallery($attr) { $image = wp_get_attachment_link($id, $size, false, false); break; case 'none': - $image = wp_get_attachment_image($id, $size, false, array('class' => 'thumbnail img-thumbnail')); + $image = wp_get_attachment_image($id, $size, false, ['class' => 'thumbnail img-thumbnail']); break; default: $image = wp_get_attachment_link($id, $size, true, false); diff --git a/lib/init.php b/lib/init.php index e8fcf02..50f69fd 100644 --- a/lib/init.php +++ b/lib/init.php @@ -16,9 +16,9 @@ function setup() { // Register wp_nav_menu() menus // http://codex.wordpress.org/Function_Reference/register_nav_menus - register_nav_menus(array( + register_nav_menus([ 'primary_navigation' => __('Primary Navigation', 'sage') - )); + ]); // Add post thumbnails // http://codex.wordpress.org/Post_Thumbnails @@ -28,11 +28,11 @@ function setup() { // Add post formats // http://codex.wordpress.org/Post_Formats - add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio')); + add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']); // Add HTML5 markup for captions // http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5 - add_theme_support('html5', array('caption', 'comment-form', 'comment-list')); + add_theme_support('html5', ['caption', 'comment-form', 'comment-list']); // Tell the TinyMCE editor to use a custom stylesheet add_editor_style('/dist/css/editor-style.css'); @@ -43,22 +43,22 @@ add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); * Register sidebars */ function widgets_init() { - register_sidebar(array( + register_sidebar([ 'name' => __('Primary', 'sage'), 'id' => 'sidebar-primary', 'before_widget' => '', 'before_title' => '