From beae33cba0c02af84a6cf99b222f30815316c18a Mon Sep 17 00:00:00 2001 From: Lukas Juhas Date: Tue, 21 Nov 2017 13:02:14 +0000 Subject: [PATCH] update and tidy up functions, add missing docblocks --- assets/styles/core.scss | 7 +++ assets/styles/styles.scss | 6 +++ functions.php | 99 +++++++++++++++++++++------------------ header.php | 3 +- includes/functions.php | 5 ++ 5 files changed, 74 insertions(+), 46 deletions(-) diff --git a/assets/styles/core.scss b/assets/styles/core.scss index f33782d..afe5ed5 100755 --- a/assets/styles/core.scss +++ b/assets/styles/core.scss @@ -1,3 +1,10 @@ +/** +* +* Core styles should contain all the core, important styling to improve +* peformance and first impression of the site on load. +* +**/ + @import 'config/variables'; @import 'config/mixins'; diff --git a/assets/styles/styles.scss b/assets/styles/styles.scss index d4e9b40..b252699 100755 --- a/assets/styles/styles.scss +++ b/assets/styles/styles.scss @@ -1,3 +1,9 @@ +/** +* +* Styles, containing "less" important layouts, components and pages +* +**/ + @import 'config/variables'; @import 'config/mixins'; diff --git a/functions.php b/functions.php index 8ec4619..162c057 100644 --- a/functions.php +++ b/functions.php @@ -25,17 +25,14 @@ if (function_exists('add_theme_support')) { load_theme_textdomain('barebones', get_template_directory() . '/languages'); } - +/** + * Hide admin bar + */ +add_filter('show_admin_bar', '__return_false'); /** * Remove junk */ - -define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true); -define('ICL_DONT_LOAD_LANGUAGES_JS', true); - -add_filter('show_admin_bar', '__return_false'); - remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); @@ -46,73 +43,80 @@ remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); -function barebones_remove_comments_rss($for_comments) +/** + * Remove comments feed + * + * @return void + */ +function barebones_post_comments_feed_link() { return; } - -add_filter('post_comments_feed_link', 'barebones_remove_comments_rss'); - - +add_filter('post_comments_feed_link', 'barebones_post_comments_feed_link'); /** - * jQuery the right way + * Enqueue scripts */ - -function barebones_scripts() +function barebones_enqueue_scripts() { // wp_enqueue_style( 'fonts', '//fonts.googleapis.com/css?family=Font+Family' ); // wp_enqueue_style( 'icons', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' ); wp_enqueue_script('script', get_stylesheet_directory_uri() . '/js/script.min.js?' . filemtime(get_stylesheet_directory() . '/js/script.min.js'), [], null, true); } - -add_action('wp_enqueue_scripts', 'barebones_scripts'); - - +add_action('wp_enqueue_scripts', 'barebones_wnqueue_scripts'); /** - * Nav menus + * Register nav menus + * + * @return void */ - -if (function_exists('register_nav_menus')) { +function barebones_register_nav_menus() +{ register_nav_menus([ - 'header' => 'Header', - 'footer' => 'Footer' + 'header' => __('Header', 'barebones'), + 'footer' => __('Footer', 'barebones'), ]); } +add_action('after_setup_theme', 'barebones_register_nav_menus', 0); -function barebones_nav_menu_args($args = '') +/** + * Nav menu args + * + * @param array $args + * @return void + */ +function barebones_nav_menu_args($args) { - $args['container'] = false; + $args['container'] = false; $args['container_class'] = false; - $args['menu_id'] = false; - $args['items_wrap'] = ''; + $args['menu_id'] = false; + $args['items_wrap'] = ''; return $args; } - add_filter('wp_nav_menu_args', 'barebones_nav_menu_args'); - /** - * Shortcodes ([button] shortcode included) + * Button Shortcode + * + * @param array $atts + * @param string $content + * @return void */ - -function button_shortcode($atts, $content = null) +function barebones_button_shortcode($atts, $content = null) { - $atts['class'] = isset($atts['class']) ? $atts['class'] : 'btn'; + $atts['class'] = isset($atts['class']) ? $atts['class'] : 'btn'; return '' . $content . ''; } - -add_shortcode('button', 'button_shortcode'); - - +add_shortcode('button', 'barebones_button_shortcode'); /** * TinyMCE + * + * @param array $buttons + * @return void */ - function barebones_mce_buttons_2($buttons) { array_unshift($buttons, 'styleselect'); @@ -120,10 +124,14 @@ function barebones_mce_buttons_2($buttons) return $buttons; } - add_filter('mce_buttons_2', 'barebones_mce_buttons_2'); - +/** + * TinyMCE styling + * + * @param array $settings + * @return void + */ function barebones_tiny_mce_before_init($settings) { $style_formats = [ @@ -139,14 +147,15 @@ function barebones_tiny_mce_before_init($settings) return $settings; } - add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init'); /** * Get post thumbnail url - * @param string $size Size of the returned image - * @param int $post_id post id - * @param boolean $icon if no image found, display icon + * + * @param string $size + * @param boolean $post_id + * @param boolean $icon + * @return void */ function get_post_thumbnail_url($size = 'full', $post_id = false, $icon = false) { diff --git a/header.php b/header.php index 3b2e744..31a0afd 100755 --- a/header.php +++ b/header.php @@ -9,7 +9,8 @@