/
scripts.php
69 lines (57 loc) · 2.81 KB
/
scripts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Functions for handling JavaScript in the framework. Themes can add support for the
* 'hybrid-core-javascript' feature to allow the framework to handle loading the stylesheets into
* the theme header or footer at an appropriate time.
*
* @package HybridCore
* @subpackage Functions
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2008 - 2012, Justin Tadlock
* @link http://themehybrid.com/hybrid-core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/* Register Hybrid Core scripts. */
add_action( 'wp_enqueue_scripts', 'hybrid_register_scripts', 1 );
/* Load Hybrid Core scripts. */
add_action( 'wp_enqueue_scripts', 'hybrid_enqueue_scripts' );
/**
* Registers JavaScript files for the framework. This function merely registers scripts with WordPress using
* the wp_register_script() function. It does not load any script files on the site. If a theme wants to register
* its own custom scripts, it should do so on the 'wp_enqueue_scripts' hook.
*
* @since 1.2.0
* @access private
* @return void
*/
function hybrid_register_scripts() {
/* Supported JavaScript. */
$supports = get_theme_support( 'hybrid-core-javascript' );
/* Register the 'drop-downs' script if the current theme supports 'hybrid-core-drop-downs'. */
if ( current_theme_supports( 'hybrid-core-drop-downs' ) || ( isset( $supports[0] ) && in_array( 'drop-downs', $supports[0] ) ) )
wp_register_script( 'drop-downs', esc_url( apply_atomic( 'drop_downs_script', trailingslashit( HYBRID_JS ) . 'drop-downs.js' ) ), array( 'jquery' ), '20110920', true );
/* Register the 'nav-bar' script if the current theme supports 'hybrid-core-nav-bar'. */
if ( isset( $supports[0] ) && in_array( 'nav-bar', $supports[0] ) )
wp_register_script( 'nav-bar', esc_url( apply_atomic( 'nav_bar_script', trailingslashit( HYBRID_JS ) . 'nav-bar.js' ) ), array( 'jquery' ), '20111008', true );
}
/**
* Tells WordPress to load the scripts needed for the framework using the wp_enqueue_script() function.
*
* @since 1.2.0
* @access private
* @return void
*/
function hybrid_enqueue_scripts() {
/* Supported JavaScript. */
$supports = get_theme_support( 'hybrid-core-javascript' );
/* Load the comment reply script on singular posts with open comments if threaded comments are supported. */
if ( is_singular() && get_option( 'thread_comments' ) && comments_open() )
wp_enqueue_script( 'comment-reply' );
/* Load the 'drop-downs' script if the current theme supports 'hybrid-core-drop-downs'. */
if ( isset( $supports[0] ) && in_array( 'drop-downs', $supports[0] ) )
wp_enqueue_script( 'drop-downs' );
/* Load the 'nav-bar' script if the current theme supports 'hybrid-core-nav-bar'. */
if ( isset( $supports[0] ) && in_array( 'nav-bar', $supports[0] ) )
wp_enqueue_script( 'nav-bar' );
}
?>