Use short array syntax
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
* Change theme name from Roots to Sage
|
* Change theme name from Roots to Sage
|
||||||
* Bump required PHP version to >=5.4
|
* Bump required PHP version to >=5.4
|
||||||
* Add namespace
|
* Add namespace
|
||||||
|
* Use short array syntax
|
||||||
* Use short echo syntax
|
* Use short echo syntax
|
||||||
* Switch from Grunt to gulp, new workflow
|
* Switch from Grunt to gulp, new workflow
|
||||||
* Use wiredep for Sass and Less injection
|
* Use wiredep for Sass and Less injection
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/roots/sage/pull/1042
|
* @link https://github.com/roots/sage/pull/1042
|
||||||
*/
|
*/
|
||||||
$sage_includes = array(
|
$sage_includes = [
|
||||||
'lib/utils.php', // Utility functions
|
'lib/utils.php', // Utility functions
|
||||||
'lib/init.php', // Initial theme setup and constants
|
'lib/init.php', // Initial theme setup and constants
|
||||||
'lib/wrapper.php', // Theme wrapper class
|
'lib/wrapper.php', // Theme wrapper class
|
||||||
@@ -20,7 +20,7 @@ $sage_includes = array(
|
|||||||
'lib/nav.php', // Custom nav modifications
|
'lib/nav.php', // Custom nav modifications
|
||||||
'lib/gallery.php', // Custom [gallery] modifications
|
'lib/gallery.php', // Custom [gallery] modifications
|
||||||
'lib/extras.php', // Custom functions
|
'lib/extras.php', // Custom functions
|
||||||
);
|
];
|
||||||
|
|
||||||
foreach ($sage_includes as $file) {
|
foreach ($sage_includes as $file) {
|
||||||
if (!$filepath = locate_template($file)) {
|
if (!$filepath = locate_template($file)) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ function assets() {
|
|||||||
if (!is_admin() && current_theme_supports('jquery-cdn')) {
|
if (!is_admin() && current_theme_supports('jquery-cdn')) {
|
||||||
wp_deregister_script('jquery');
|
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);
|
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('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('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);
|
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:
|
* 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.
|
* The second element must be an array even if there's only 1 argument.
|
||||||
*/
|
*/
|
||||||
array(
|
[
|
||||||
'is_404',
|
'is_404',
|
||||||
'is_front_page'
|
'is_front_page'
|
||||||
),
|
],
|
||||||
/**
|
/**
|
||||||
* Page template checks (via is_page_template())
|
* Page template checks (via is_page_template())
|
||||||
* Any of these page templates that return true won't show the sidebar
|
* Any of these page templates that return true won't show the sidebar
|
||||||
*/
|
*/
|
||||||
array(
|
[
|
||||||
'template-custom.php'
|
'template-custom.php'
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$display = apply_filters('sage/display_sidebar', $sidebar_config->display);
|
$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',
|
'order' => 'ASC',
|
||||||
'orderby' => 'menu_order ID',
|
'orderby' => 'menu_order ID',
|
||||||
'id' => $post->ID,
|
'id' => $post->ID,
|
||||||
@@ -48,7 +48,7 @@ function gallery($attr) {
|
|||||||
'include' => '',
|
'include' => '',
|
||||||
'exclude' => '',
|
'exclude' => '',
|
||||||
'link' => ''
|
'link' => ''
|
||||||
), $attr));
|
], $attr));
|
||||||
|
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
$columns = (12 % $columns == 0) ? $columns: 4;
|
$columns = (12 % $columns == 0) ? $columns: 4;
|
||||||
@@ -59,16 +59,16 @@ function gallery($attr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($include)) {
|
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) {
|
foreach ($_attachments as $key => $val) {
|
||||||
$attachments[$val->ID] = $_attachments[$key];
|
$attachments[$val->ID] = $_attachments[$key];
|
||||||
}
|
}
|
||||||
} elseif (!empty($exclude)) {
|
} 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 {
|
} 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)) {
|
if (empty($attachments)) {
|
||||||
@@ -93,7 +93,7 @@ function gallery($attr) {
|
|||||||
$image = wp_get_attachment_link($id, $size, false, false);
|
$image = wp_get_attachment_link($id, $size, false, false);
|
||||||
break;
|
break;
|
||||||
case 'none':
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
$image = wp_get_attachment_link($id, $size, true, false);
|
$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
|
// Register wp_nav_menu() menus
|
||||||
// http://codex.wordpress.org/Function_Reference/register_nav_menus
|
// http://codex.wordpress.org/Function_Reference/register_nav_menus
|
||||||
register_nav_menus(array(
|
register_nav_menus([
|
||||||
'primary_navigation' => __('Primary Navigation', 'sage')
|
'primary_navigation' => __('Primary Navigation', 'sage')
|
||||||
));
|
]);
|
||||||
|
|
||||||
// Add post thumbnails
|
// Add post thumbnails
|
||||||
// http://codex.wordpress.org/Post_Thumbnails
|
// http://codex.wordpress.org/Post_Thumbnails
|
||||||
@@ -28,11 +28,11 @@ function setup() {
|
|||||||
|
|
||||||
// Add post formats
|
// Add post formats
|
||||||
// http://codex.wordpress.org/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
|
// Add HTML5 markup for captions
|
||||||
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
|
// 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
|
// Tell the TinyMCE editor to use a custom stylesheet
|
||||||
add_editor_style('/dist/css/editor-style.css');
|
add_editor_style('/dist/css/editor-style.css');
|
||||||
@@ -43,22 +43,22 @@ add_action('after_setup_theme', __NAMESPACE__ . '\\setup');
|
|||||||
* Register sidebars
|
* Register sidebars
|
||||||
*/
|
*/
|
||||||
function widgets_init() {
|
function widgets_init() {
|
||||||
register_sidebar(array(
|
register_sidebar([
|
||||||
'name' => __('Primary', 'sage'),
|
'name' => __('Primary', 'sage'),
|
||||||
'id' => 'sidebar-primary',
|
'id' => 'sidebar-primary',
|
||||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||||
'after_widget' => '</section>',
|
'after_widget' => '</section>',
|
||||||
'before_title' => '<h3>',
|
'before_title' => '<h3>',
|
||||||
'after_title' => '</h3>',
|
'after_title' => '</h3>',
|
||||||
));
|
]);
|
||||||
|
|
||||||
register_sidebar(array(
|
register_sidebar([
|
||||||
'name' => __('Footer', 'sage'),
|
'name' => __('Footer', 'sage'),
|
||||||
'id' => 'sidebar-footer',
|
'id' => 'sidebar-footer',
|
||||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||||
'after_widget' => '</section>',
|
'after_widget' => '</section>',
|
||||||
'before_title' => '<h3>',
|
'before_title' => '<h3>',
|
||||||
'after_title' => '</h3>',
|
'after_title' => '</h3>',
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');
|
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);
|
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";
|
$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 = '';
|
$item_html = '';
|
||||||
parent::start_el($item_html, $item, $depth, $args);
|
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
|
* Use Sage_Nav_Walker() by default
|
||||||
*/
|
*/
|
||||||
function nav_menu_args($args = '') {
|
function nav_menu_args($args = '') {
|
||||||
$nav_menu_args = array();
|
$nav_menu_args = [];
|
||||||
|
|
||||||
$nav_menu_args['container'] = false;
|
$nav_menu_args['container'] = false;
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ class Sage_Sidebar {
|
|||||||
|
|
||||||
public $display = true;
|
public $display = true;
|
||||||
|
|
||||||
function __construct($conditionals = array(), $templates = array()) {
|
function __construct($conditionals = [], $templates = []) {
|
||||||
$this->conditionals = $conditionals;
|
$this->conditionals = $conditionals;
|
||||||
$this->templates = $templates;
|
$this->templates = $templates;
|
||||||
|
|
||||||
$conditionals = array_map(array($this, 'check_conditional_tag'), $this->conditionals);
|
$conditionals = array_map([$this, 'check_conditional_tag'], $this->conditionals);
|
||||||
$templates = array_map(array($this, 'check_page_template'), $this->templates);
|
$templates = array_map([$this, 'check_page_template'], $this->templates);
|
||||||
|
|
||||||
if (in_array(true, $conditionals) || in_array(true, $templates)) {
|
if (in_array(true, $conditionals) || in_array(true, $templates)) {
|
||||||
$this->display = false;
|
$this->display = false;
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ class Sage_Wrapping {
|
|||||||
// Stores the full path to the main template file
|
// Stores the full path to the main template file
|
||||||
public static $main_template;
|
public static $main_template;
|
||||||
|
|
||||||
// basename of template file
|
// Basename of template file
|
||||||
public $slug;
|
public $slug;
|
||||||
|
|
||||||
// array of templates
|
// Array of templates
|
||||||
public $templates;
|
public $templates;
|
||||||
|
|
||||||
// Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
|
// 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') {
|
public function __construct($template = 'base.php') {
|
||||||
$this->slug = basename($template, '.php');
|
$this->slug = basename($template, '.php');
|
||||||
$this->templates = array($template);
|
$this->templates = [$template];
|
||||||
|
|
||||||
if (self::$base) {
|
if (self::$base) {
|
||||||
$str = substr($template, 0, -4);
|
$str = substr($template, 0, -4);
|
||||||
@@ -61,4 +61,4 @@ class Sage_Wrapping {
|
|||||||
return new 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);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<h2><?php printf(_nx('One response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'), number_format_i18n(get_comments_number()), '<span>' . get_the_title() . '</span>'); ?></h2>
|
<h2><?php printf(_nx('One response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'), number_format_i18n(get_comments_number()), '<span>' . get_the_title() . '</span>'); ?></h2>
|
||||||
|
|
||||||
<ol class="comment-list">
|
<ol class="comment-list">
|
||||||
<?php wp_list_comments(array('style' => 'ol', 'short_ping' => true)); ?>
|
<?php wp_list_comments(['style' => 'ol', 'short_ping' => true]); ?>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
|
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
<?php the_content(); ?>
|
<?php the_content(); ?>
|
||||||
<?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
|
<?php wp_link_pages(['before' => '<nav class="pagination">', 'after' => '</nav>']); ?>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<?php the_content(); ?>
|
<?php the_content(); ?>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<?php wp_link_pages(array('before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>')); ?>
|
<?php wp_link_pages(['before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']); ?>
|
||||||
</footer>
|
</footer>
|
||||||
<?php comments_template('/templates/comments.php'); ?>
|
<?php comments_template('/templates/comments.php'); ?>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav class="collapse navbar-collapse" role="navigation">
|
<nav class="collapse navbar-collapse" role="navigation">
|
||||||
<?php
|
<?php
|
||||||
if (has_nav_menu('primary_navigation')) :
|
if (has_nav_menu('primary_navigation')) :
|
||||||
wp_nav_menu(array('theme_location' => 'primary_navigation', 'walker' => new Nav\Sage_Nav_Walker(), 'menu_class' => 'nav navbar-nav'));
|
wp_nav_menu(['theme_location' => 'primary_navigation', 'walker' => new Nav\Sage_Nav_Walker(), 'menu_class' => 'nav navbar-nav']);
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
Reference in New Issue
Block a user