-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
101 lines (79 loc) · 2.62 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
<?php
/**
* Helper methods for the REPLACE_ME theme
*
* @package Boilerplate for Developers
* @author Christopher Frazier (chris@wpdevtools.com), David Sutoyo (david@wpdevtools.com)
**/
define( 'THEME_URL', get_template_directory_uri() . '/' );
define( 'THEME_VERSION', '0.1' );
define( 'THEME_DIR', dirname(__FILE__).'/' );
define( 'THEME_PREFIX', 'replace_me' );
define( 'THEME_NAME', 'REPLACE_ME' );
define( 'THEME_OPTIONS', THEME_PREFIX . '_options' );
require_once(THEME_DIR . 'options.php');
require_once(THEME_DIR . 'lib/wpdt-core/utility.php');
class Theme_Functions
{
/**
* Sets global context for comments
*
**/
public function call_comment ($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
include( 'comment.php' );
}
/**
* Enqueues required JS and CSS scripts with WordPress
*
**/
public function enqueue_scripts () {
if ( !is_admin() ) {
// jQuery and Modernizr
wp_enqueue_script("jquery");
wp_enqueue_script("modernizr", THEME_URL . 'lib/Modernizr/modernizr.js', 'jquery', 'trunk');
// Theme scripts
if (WPDT_Utility::is_mobile()) {
wp_enqueue_style(THEME_PREFIX, THEME_URL . 'mobile.css', '', THEME_VERSION);
} else {
wp_enqueue_style(THEME_PREFIX, THEME_URL . 'style.css', '', THEME_VERSION);
}
wp_enqueue_script(THEME_PREFIX . "-script", THEME_URL . 'assets/js/script.js', '', THEME_VERSION, true);
// Threaded comment form handler
if ( is_singular() ) wp_enqueue_script( "comment-reply" );
}
}
/**
* Sets up theme features in WordPress on first activation
*
**/
public function theme_setup () {
// Set the document width
if ( ! isset( $content_width ) ) $content_width = 900;
// Support theme styling in TinyMCE editor
add_editor_style('editor.css');
// Load the correct language files
load_theme_textdomain(THEME_NAME, THEME_DIR . '/assets/languages');
// Support automatic feed links
add_theme_support( 'automatic-feed-links' );
// Support post thumbnails
add_theme_support( 'post-thumbnails' );
// Sidebar Registration
register_sidebar( array(
'name' => __( 'Main Sidebar', 'sidebar-main' ),
'id' => 'sidebar-main',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
// Menu registration
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(array(
'main-menu' => 'The primary menu.'
));
}
}
}
add_action( 'after_setup_theme', array('Theme_Functions', 'theme_setup') );
add_action( 'wp_enqueue_scripts', array('Theme_Functions', 'enqueue_scripts') );