-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
273 lines (201 loc) · 8.71 KB
/
functions.php
File metadata and controls
273 lines (201 loc) · 8.71 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
/**
* The functions file is used to initialize everything in the theme. It controls how the theme is loaded and
* sets up the supported features, default actions, and default filters. If making customizations, users
* should create a child theme and make changes to its functions.php file (not this one). Friends don't let
* friends modify parent theme files. ;)
*
* Child themes should do their setup on the 'after_setup_theme' hook with a priority of 11 if they want to
* override parent theme features. Use a priority of 9 if wanting to run before the parent theme.
*
* @package happystraps
* @subpackage Functions
* @version 0.1.0
* @author Brian Krogsgard <Brian@Krogsgard.com>
* @copyright Copyright (c) 2011, Brian Krogsgard
* @link http://krogsgard.com
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/* Load the core theme framework. */
require_once( trailingslashit( TEMPLATEPATH ) . 'library/hybrid.php' );
$theme = new Hybrid();
/* Do theme setup on the 'after_setup_theme' hook. */
add_action( 'after_setup_theme', 'happystraps_theme_setup' );
/**
* Theme setup function. This function adds support for theme features and defines the default theme
* actions and filters.
*
* @since 0.1.0
*/
function happystraps_theme_setup() {
/* Get action/filter hook prefix. */
$prefix = hybrid_get_prefix();
/* Add theme support for core framework features. */
add_theme_support( 'hybrid-core-menus', array( 'primary') );
add_theme_support( 'hybrid-core-sidebars', array( 'primary', 'secondary' ) );
add_theme_support( 'hybrid-core-widgets' );
add_theme_support( 'hybrid-core-shortcodes' );
add_theme_support( 'hybrid-core-post-meta-box' );
add_theme_support( 'hybrid-core-theme-settings' );
add_theme_support( 'hybrid-core-meta-box-footer' );
add_theme_support( 'hybrid-core-template-hierarchy' );
/* Add theme support for extensions. */
add_theme_support( 'theme-layouts', array( '1c', '2c-l', '2c-r') );
add_theme_support( 'post-stylesheets' );
add_theme_support( 'dev-stylesheet' );
add_theme_support( 'loop-pagination' );
add_theme_support( 'get-the-image' );
add_theme_support( 'entry-views' );
add_theme_support( 'cleaner-gallery' );
/* Add theme support for WordPress features. */
add_theme_support( 'automatic-feed-links' );
/* Register sidebars. */
add_action( 'widgets_init', 'happystraps_register_sidebars', 9 );
/* Remove the page title from the home page. */
add_action( 'happystraps_before_entry', 'empty_home_title', 9 );
/* Embed width/height defaults. */
add_filter( 'embed_defaults', 'happystraps_embed_defaults' );
/* Filter the sidebar widgets. */
add_filter( 'sidebars_widgets', 'happystraps_disable_sidebars' );
add_action( 'template_redirect', 'happystraps_one_column' );
/* Change default comment status for pages to false. */
add_action( 'load-page-new.php', 'my_change_comment_status' );
/* Call functions-admin.php file for theme settings THIS MAY NEED TO BE ADDED BACK... TAKEN OUT BC NOT IN PROTOTYPE 0.2. */
if ( is_admin() )
require_once( trailingslashit( TEMPLATEPATH ) . 'functions-admin.php' );
// Register and load scripts
add_action( 'wp_enqueue_scripts', 'happystraps_load_my_js' );
add_shortcode( 'entry-modified', 'krogs_entry_modified_shortcode' );
add_action( '{$prefix}_open_footer', 'happystraps_insert_sidebars', 30 );
}
function happystraps_insert_sidebars() {
?> <div class="well">HEY</div> <?php
}
function krogs_entry_modified_shortcode( $attr ) {
$domain = hybrid_get_textdomain();
$attr = shortcode_atts( array( 'before' => '', 'after' => '', 'format' => get_option( 'date_format' ) ), $attr );
$modified = '<abbr class="modified" title="' . sprintf( get_the_modified_time( esc_attr__( 'l, F jS, Y, g:i a', $domain ) ) ) . '">' . sprintf( get_the_modified_time( $attr['format'] ) ) . '</abbr>';
return $attr['before'] . $modified . $attr['after'];
}
function happystraps_load_my_js() {
if( !is_admin()){
// other scripts
wp_register_script('easing', get_template_directory_uri() . '/js/jquery.easing-1.3.pack.js', array('jquery'), '1.3', true );
wp_register_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0.0', true );
wp_enqueue_script('easing');
wp_enqueue_script('custom');
// Bootstrap scripts
// wp_register_script('prettify.js', get_template_directory_uri().'/js/prettify.js', array('jquery'),'1.0', true );
wp_register_script('alert.js', get_template_directory_uri().'/js/bootstrap-alerts.js', array('jquery'),'2.0.1', true );
wp_register_script('button.js', get_template_directory_uri().'/js/bootstrap-buttons.js', array('jquery'),'2.0.1', true );
wp_register_script('carousel.js', get_template_directory_uri().'/js/bootstrap-carousel.js', array('jquery'),'2.0.1', true );
wp_register_script('collapse.js', get_template_directory_uri().'/js/bootstrap-collapse.js', array('jquery'),'2.0.1', true );
wp_register_script('dropdown.js', get_template_directory_uri().'/js/bootstrap-dropdown.js', array('jquery'),'2.0.1', true );
wp_register_script('modal.js', get_template_directory_uri().'/js/bootstrap-modal.js', array('jquery'),'2.0.1', true );
wp_register_script('popover.js', get_template_directory_uri().'/js/bootstrap-popover.js', array('tooltip.js'),'2.0.1', true );
wp_register_script('scrollspy.js', get_template_directory_uri().'/js/bootstrap-scrollspy.js', array('jquery'),'2.0.1', true );
wp_register_script('tab.js', get_template_directory_uri().'/js/bootstrap-tabs.js', array('jquery'),'2.0.1', true );
wp_register_script('tooltip.js', get_template_directory_uri().'/js/bootstrap-tooltip.js', array('jquery'),'2.0.1', true );
wp_register_script('transition.js', get_template_directory_uri().'/js/bootstrap-transition.js', array('jquery'),'2.0.1', true );
// wp_enqueue_script('prettify.js');
wp_enqueue_script('alert.js');
wp_enqueue_script('carousel.js');
wp_enqueue_script('collapse.js');
wp_enqueue_script('dropdown.js');
wp_enqueue_script('modal.js');
wp_enqueue_script('scrollspy.js');
wp_enqueue_script('tab.js');
wp_enqueue_script('tooltip.js');
wp_enqueue_script('transition.js');
wp_enqueue_script('popover.js');
wp_enqueue_script('button.js');
}
}
/**
* Unregisters some of the core framework sidebars that the theme doesn't use.
*
* @since 0.1.0
*/
//function happystraps_unregister_sidebars() {
// unregister_sidebar( 'primary' );
// unregister_sidebar( 'secondary' );
//}
/**
* Registers new sidebars for the theme.
*
* @since 0.1.0.
*/
function happystraps_register_sidebars() {
/* register_sidebar( array( 'name' => __( 'Feature', hybrid_get_textdomain() ), 'id' => 'feature', 'description' => __( 'Displayed in the feature area.', hybrid_get_textdomain() ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); */
}
/**
* Sets default comment and ping status
* to off for "Page" post types
*
*/
function my_change_comment_status() {
add_filter( 'option_default_comment_status', '__return_false' );
add_filter( 'option_default_ping_status', '__return_false' );
}
/**
* Adds custom image sizes for use
* typically with feature widget areas
*
*/
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'tiny', 160, 120, true );
}
/**
* Function for deciding which pages should have a one-column layout.
*
* @since 0.1.0
*/
function happystraps_one_column() {
if ( !is_active_sidebar( 'primary' ) )
add_filter( 'get_theme_layout', 'happystraps_post_layout_one_column' );
elseif ( is_attachment() )
add_filter( 'get_theme_layout', 'happystraps_post_layout_one_column' );
}
/**
* Filters 'get_post_layout' by returning 'layout-1c'.
*
* @since 0.1.0
*/
function happystraps_post_layout_one_column( $layout ) {
return 'layout-1c';
}
/**
* Disables sidebars if viewing a one-column page.
*
* @since 0.1.0
*/
function happystraps_disable_sidebars( $sidebars_widgets ) {
global $wp_query;
if ( current_theme_supports( 'theme-layouts' ) ) {
if ( 'layout-1c' == theme_layouts_get_layout() ) {
$sidebars_widgets['primary'] = false;
$sidebars_widgets['secondary'] = false;
}
}
return $sidebars_widgets;
}
/**
* Overwrites the default widths for embeds. This is especially useful for making sure videos properly
* expand the full width on video pages. This function overwrites what the $content_width variable handles
* with context-based widths.
*
* @since 0.1.0
*/
function happystraps_embed_defaults( $args ) {
if ( current_theme_supports( 'theme-layouts' ) ) {
$layout = theme_layouts_get_layout();
if ( 'layout-1c' == $layout )
$args['width'] = 928;
else
$args['width'] = 650;
}
else
$args['width'] = 650;
return $args;
}
?>