-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
115 lines (93 loc) · 2.84 KB
/
functions.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* functions.php
*
* Shared functionality used by the theme. Sets up theme options and contains
* helper functions for displaying things
*
* @package MinimalTheme
* @subpackage Functions
* @author Phil Newton <[email protected]>
* @copyright 2012 Phil Newton
* @version 1.0
*/
// ----------------------------------------------------------------------
// -- Theme Setup Hooks
// ----------------------------------------------------------------------
add_action( 'init', 'minimal_setup_theme' );
add_action( 'wp_head', 'minimal_minify_location', 99 );
add_theme_support( 'title-tag' );
// ----------------------------------------------------------------------
// -- Theme Setup Functions
// ----------------------------------------------------------------------
/**
* Setup the theme sidebars, menus and external resources.
*/
function minimal_setup_theme() {
minimal_setup_javascript();
minimal_setup_stylesheets();
minimal_setup_sidebars();
minimal_setup_menus();
}
/**
* Register site javascript.
*/
function minimal_setup_javascript() {
// Don't load scripts in admin area.
if ( is_admin() ) {
return;
}
// Removes jQuery UNLESS a plugin or something else needs it.
wp_dequeue_script( 'jquery' );
// Add modernizr for Internet Explorer.
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/modernizr.js' );
wp_script_add_data( 'modernizr', 'conditional', 'IE' );
}
/**
* Register site stylesheets.
*/
function minimal_setup_stylesheets() {
if ( is_admin() ) {
return;
}
// Theme stylesheet.
wp_enqueue_style( 'minimal', get_template_directory_uri() . '/style.css' );
// Print stylesheet.
wp_enqueue_style( 'minimal-print', get_template_directory_uri() . '/print.css', null, false, 'print' );
}
/**
* Register theme sidebars with WordPress.
*/
function minimal_setup_sidebars() {
register_sidebar( array(
'name' => 'Primary Sidebar Widgets',
'id' => 'primary-sidebar',
'description' => 'Widgets that appear in the left sidebar',
'before_widget' => '<section id="%1$s" class="%2$s">',
'after_widget' => '</section>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );
}
/**
* Register theme menus with WordPress.
*/
function minimal_setup_menus() {
register_nav_menus( array(
'footer_links' => 'Footer Links',
) );
}
// ----------------------------------------------------------------------
// -- Minify Helpers
// ----------------------------------------------------------------------
/**
* If WP Minify is installed, sets the placement at the bottom of the header.
* This means that minified files that require jQuery will still work as jQuery
* will now load before, rather than after minified files.
*/
function minimal_minify_location() {
if ( class_exists( 'WPMinify' ) ) {
echo "<!-- WP-Minify JS -->\n";
echo "<!-- WP-Minify CSS -->\n";
}
}