From eca31bd91508eaf9b2482a08712c0dfd0300f5f1 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 15 Jan 2012 19:31:14 -0700 Subject: [PATCH] adding roots-scripts.php, now using wp_enqueue_script --- functions.php | 13 +++--- header.php | 2 - inc/roots-actions.php | 57 +----------------------- inc/roots-scripts.php | 101 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 65 deletions(-) create mode 100644 inc/roots-scripts.php diff --git a/functions.php b/functions.php index b253a6b..e86226c 100644 --- a/functions.php +++ b/functions.php @@ -5,6 +5,7 @@ if (!defined('__DIR__')) define('__DIR__', dirname(__FILE__)); require_once locate_template('/inc/roots-activation.php'); // activation require_once locate_template('/inc/roots-options.php'); // theme options require_once locate_template('/inc/roots-cleanup.php'); // cleanup +require_once locate_template('/inc/roots-scripts.php'); // modified scripts output require_once locate_template('/inc/roots-htaccess.php'); // rewrites for assets, h5bp htaccess require_once locate_template('/inc/roots-hooks.php'); // hooks require_once locate_template('/inc/roots-actions.php'); // actions @@ -71,17 +72,15 @@ function roots_setup() { add_action('after_setup_theme', 'roots_setup'); // http://codex.wordpress.org/Function_Reference/register_sidebar -// hook into 'widgets_init' function with a lower priority in your -// child theme to remove these sidebars function roots_register_sidebars() { - $sidebars = array( 'Sidebar', 'Footer' ); + $sidebars = array('Sidebar', 'Footer'); - foreach( $sidebars as $sidebar ) { + foreach($sidebars as $sidebar) { register_sidebar( array( - 'id'=> 'roots-' . strtolower( $sidebar ), - 'name' => __( $sidebar, 'roots' ), - 'description' => __( $sidebar, 'roots' ), + 'id'=> 'roots-' . strtolower($sidebar), + 'name' => __($sidebar, 'roots'), + 'description' => __($sidebar, 'roots'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', diff --git a/header.php b/header.php index 984047c..311440a 100644 --- a/header.php +++ b/header.php @@ -21,8 +21,6 @@ - - > diff --git a/inc/roots-actions.php b/inc/roots-actions.php index e93bdf1..be74f86 100644 --- a/inc/roots-actions.php +++ b/inc/roots-actions.php @@ -103,17 +103,11 @@ function roots_google_analytics() { // 1140 specific if (roots_current_framework() === '1140') { - add_action('roots_head', 'roots_1140_head'); add_action('roots_header_before', 'roots_1140_header_before'); add_action('roots_header_after', 'roots_1140_header_after'); add_action('roots_footer_before', 'roots_1140_footer_before'); add_action('roots_footer_after', 'roots_1140_footer_after'); - function roots_1140_head() { - $template_uri = get_template_directory_uri(); - echo "\t"; - } - function roots_1140_header_before() { echo '
', "\n"; } @@ -153,65 +147,16 @@ if (roots_current_framework() === 'adapt') { echo "\t\t\t]\n"; echo "\t\t};\n"; echo "\t\n"; - echo "\t"; - } -} - -// Foundation specific -if (roots_current_framework() === 'foundation') { - add_action('roots_head', 'roots_foundation_head'); - - function roots_foundation_head() { - $template_uri = get_template_directory_uri(); - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; } } // Bootstrap specific if (roots_current_framework() === 'bootstrap' || roots_current_framework() === 'bootstrap_less') { - add_action('roots_head', 'roots_bootstrap_head'); add_action('roots_header_before', 'roots_bootstrap_header_before'); add_action('roots_header_after', 'roots_bootstrap_header_after'); add_action('roots_footer_before', 'roots_bootstrap_footer_before'); add_action('roots_footer_after', 'roots_bootstrap_footer_after'); - function roots_bootstrap_head() { - global $roots_options; - $roots_bootstrap_js = $roots_options['bootstrap_javascript']; - $roots_bootstrap_less_js = $roots_options['bootstrap_less_javascript']; - $template_uri = get_template_directory_uri(); - if (roots_current_framework() === 'bootstrap_less') { - echo "\t\n"; - } - if ($roots_bootstrap_js === true) { - $roots_options['bootstrap_less_javascript'] = false; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - } - if ($roots_bootstrap_less_js === true) { - $roots_options['bootstrap_javascript'] = false; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - } - } - function roots_bootstrap_header_before() { echo '
', "\n"; } @@ -231,4 +176,4 @@ if (roots_current_framework() === 'bootstrap' || roots_current_framework() === ' } } -?> +?> \ No newline at end of file diff --git a/inc/roots-scripts.php b/inc/roots-scripts.php new file mode 100644 index 0000000..1b409b7 --- /dev/null +++ b/inc/roots-scripts.php @@ -0,0 +1,101 @@ +all_deps($wp_scripts->queue); + $scripts = array(); + + foreach ($wp_scripts->queue as $key => $handle) { + $skip_scripts = array('jquery', 'roots_script', 'roots_plugins'); + + $src = $wp_scripts->registered[$handle]->src; + unset($wp_scripts->queue[$key]); + $wp_scripts->done[] = $handle; + + if (!in_array($handle, $skip_scripts)) { + $scripts[] = ''; + } + } + + echo "\t" . implode("\n\t", $scripts) . "\n"; + + $template_uri = get_template_directory_uri(); + echo "\t\n"; + echo "\t\n"; + + $wp_scripts->reset(); + return $wp_scripts->done; +} + +?> \ No newline at end of file