Use short array syntax
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
16
lib/init.php
16
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' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
));
|
||||
]);
|
||||
|
||||
register_sidebar(array(
|
||||
register_sidebar([
|
||||
'name' => __('Footer', 'sage'),
|
||||
'id' => 'sidebar-footer',
|
||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
));
|
||||
]);
|
||||
}
|
||||
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');
|
||||
|
||||
@@ -18,11 +18,11 @@ class Sage_Nav_Walker extends \Walker_Nav_Menu {
|
||||
return preg_match('/(current[-_])|active|dropdown/', $classes);
|
||||
}
|
||||
|
||||
function start_lvl(&$output, $depth = 0, $args = array()) {
|
||||
function start_lvl(&$output, $depth = 0, $args = []) {
|
||||
$output .= "\n<ul class=\"dropdown-menu\">\n";
|
||||
}
|
||||
|
||||
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
|
||||
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0) {
|
||||
$item_html = '';
|
||||
parent::start_el($item_html, $item, $depth, $args);
|
||||
|
||||
@@ -85,7 +85,7 @@ add_filter('nav_menu_item_id', '__return_null');
|
||||
* Use Sage_Nav_Walker() by default
|
||||
*/
|
||||
function nav_menu_args($args = '') {
|
||||
$nav_menu_args = array();
|
||||
$nav_menu_args = [];
|
||||
|
||||
$nav_menu_args['container'] = false;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ class Sage_Sidebar {
|
||||
|
||||
public $display = true;
|
||||
|
||||
function __construct($conditionals = array(), $templates = array()) {
|
||||
function __construct($conditionals = [], $templates = []) {
|
||||
$this->conditionals = $conditionals;
|
||||
$this->templates = $templates;
|
||||
|
||||
$conditionals = array_map(array($this, 'check_conditional_tag'), $this->conditionals);
|
||||
$templates = array_map(array($this, 'check_page_template'), $this->templates);
|
||||
$conditionals = array_map([$this, 'check_conditional_tag'], $this->conditionals);
|
||||
$templates = array_map([$this, 'check_page_template'], $this->templates);
|
||||
|
||||
if (in_array(true, $conditionals) || in_array(true, $templates)) {
|
||||
$this->display = false;
|
||||
|
||||
@@ -21,10 +21,10 @@ class Sage_Wrapping {
|
||||
// Stores the full path to the main template file
|
||||
public static $main_template;
|
||||
|
||||
// basename of template file
|
||||
// Basename of template file
|
||||
public $slug;
|
||||
|
||||
// array of templates
|
||||
// Array of templates
|
||||
public $templates;
|
||||
|
||||
// Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
|
||||
@@ -32,7 +32,7 @@ class Sage_Wrapping {
|
||||
|
||||
public function __construct($template = 'base.php') {
|
||||
$this->slug = basename($template, '.php');
|
||||
$this->templates = array($template);
|
||||
$this->templates = [$template];
|
||||
|
||||
if (self::$base) {
|
||||
$str = substr($template, 0, -4);
|
||||
@@ -61,4 +61,4 @@ class Sage_Wrapping {
|
||||
return new Sage_Wrapping();
|
||||
}
|
||||
}
|
||||
add_filter('template_include', array(__NAMESPACE__ . '\\Sage_Wrapping', 'wrap'), 99);
|
||||
add_filter('template_include', [__NAMESPACE__ . '\\Sage_Wrapping', 'wrap'], 99);
|
||||
|
||||
Reference in New Issue
Block a user