forked from tareq1988/_bootstraps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
executable file
·168 lines (140 loc) · 5.23 KB
/
functions.php
File metadata and controls
executable file
·168 lines (140 loc) · 5.23 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
* _bootstraps - 2013 functions and definitions
*
* @package _bootstraps
* @package _bootstraps - 2013 1.0
*/
/**
* Bootstrap Theme Class
*
* @package _bootstraps - 2013 1.0
*/
class WeDevs_Bootstrap {
function __construct() {
add_action( 'after_setup_theme', array($this, 'setup_theme') );
add_action( 'wp_enqueue_scripts', array($this, 'enqueue_scripts') );
add_action( 'wp_footer', array($this, 'footer_scripts'), 99 );
add_action( 'widgets_init', array($this, 'widgets_init') );
remove_action( 'wp_head', 'wp_generator' );
}
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* @package _bootstraps - 2013 1.0
*/
function setup_theme() {
/**
* Custom template tags for this theme.
*/
require_once dirname( __FILE__ ) . '/lib/template-tags.php';
/**
* Custom Theme Options
*/
if ( is_admin() ) {
require_once dirname( __FILE__ ) . '/lib/admin.php';
}
/**
* Load bootstrap menu walker class
*/
require_once dirname( __FILE__ ) . '/lib/bootstrap-walker.php';
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on Tareq\'s Planet - 2013, use a find and replace
* to change 'tp' to the name of your theme in all the template files
*/
load_theme_textdomain( 'wedevs', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* Enable support for Post Thumbnails
*/
add_theme_support( 'post-thumbnails' );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'wedevs' ),
) );
/**
* Add support for the Aside Post Formats
*/
add_theme_support( 'post-formats', array('aside',) );
}
/**
* Enqueue scripts and styles
*/
function enqueue_scripts() {
// cache the directory path, maybe helpful?
$template_directory = get_template_directory_uri() . '/assets';
// all styles
wp_enqueue_style( 'bootstrap', $template_directory . '/css/bootstrap.css' );
wp_enqueue_style( 'font-awesome', $template_directory . '/css/font-awesome.css' );
wp_enqueue_style( 'style', $template_directory . '/css/style.css' );
// all scripts
// wp_enqueue_script( 'small-menu', $template_directory . '/js/small-menu.js', array('jquery'), '20120206', true );
wp_enqueue_script( 'bootstrap', $template_directory . '/js/bootstrap.min.js', array('jquery'), '20120206', true );
// comment reply on single posts
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'keyboard-image-navigation', $template_directory . '/js/keyboard-image-navigation.js', array('jquery'), '20120202', true );
}
wp_enqueue_script( 'jquery-prettyphoto', $template_directory . '/js/jquery.prettyPhoto.js', array('jquery', 'theme-script'), '20120202', true );
wp_enqueue_script( 'theme-script', $template_directory . '/js/scripts.js', array('jquery'), '20120206', true );
}
/**
* Register widgetized area and update sidebar with default widgets
*
* @package _bootstraps - 2013 1.0
*/
function widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'wedevs' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
/**
* Print custom JS and CSS codes in theme footer
*
* @return void
*/
function footer_scripts() {
$css = wedevs_get_option( 'footer_css', 'tp_settings' );
$js = wedevs_get_option( 'footer_js', 'tp_settings' );
if ( $css ) {
echo '<style type="text/css">' . $css . '</style>' . "\r\n";
}
if ( $js ) {
echo '<script type="text/javascript">' . $js . '</script>' . "\r\n";
}
}
}
$wedevs_bootstrap = new WeDevs_Bootstrap();
/**
* Get the value of a settings field
*
* @param string $option settings field name
* @param string $section the section name this field belongs to
* @param string $default default text if it's not found
* @return mixed
*/
function wedevs_get_option( $option, $section, $default = '' ) {
$options = get_option( $section );
if ( isset( $options[$option] ) ) {
return $options[$option];
}
return $default;
}