-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
386 lines (303 loc) · 10.9 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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<?php
/**
* progression functions and definitions
*
* @package progression
* @since progression 1.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since progression 1.0
*/
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
if ( ! function_exists( 'progression_setup' ) ):
/**
* 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.
*
* @since progression 1.0
*/
function progression_setup() {
if(function_exists( 'set_revslider_as_theme' )){
add_action( 'init', 'pro_ezio_custom_slider_rev' );
function pro_ezio_custom_slider_rev() { set_revslider_as_theme(); }
}
// Post Thumbnails
add_theme_support('post-thumbnails');
add_image_size('progression-blog', 900, 525, true); // Blog Post Image
add_image_size('progression-page-title', 1800, 600, true); // Blog Post Image
add_image_size('progression-portfolio-thumb', 600, 338, true); //600 wide by 338 tall Image is cropped due to true setting
add_image_size('progression-portfolio-single', 1200, 500, true); //1200 wide x 800 tall with cropping
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on progression, use a find and replace
* to change 'progression' to the name of your theme in all the template files
*/
load_theme_textdomain( 'progression', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
// Include widgets
require( get_template_directory() . '/widgets/widgets.php' );
/**
* Enable support for Post Formats
*/
add_theme_support( 'post-formats', array( 'gallery', 'video', 'audio', 'link' ) );
add_post_type_support( 'portfolio', 'post-formats' );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary-left' => __( 'Primary Left Menu', 'progression' ),
'primary-right' => __( 'Primary Right Menu', 'progression' ),
) );
if (!current_user_can('manage_options')) {
add_filter('show_admin_bar', '__return_false');
}
// show admin bar only for admins and editors
if (!current_user_can('edit_posts')) {
add_filter('show_admin_bar', '__return_false');
}
}
endif; // progression_setup
add_action( 'after_setup_theme', 'progression_setup' );
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'recipe' )
{
return locate_template('archive-search.php'); // redirect to archive-search.php
}
return $template;
}
add_filter('template_include', 'template_chooser');
/**
* Registering Custom Post Type
*/
add_action('init', 'progression_portfolio_init');
function progression_portfolio_init() {
register_post_type(
'portfolio',
array(
'labels' => array(
'name' => 'Portfolio',
'singular_name' => 'Portfolio'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'portfolio-type'),
'supports' => array('title', 'editor', 'thumbnail','comments'),
'can_export' => true,
)
);
register_taxonomy('portfolio_type', 'portfolio', array('hierarchical' => true, 'label' => 'Portfolio Categories', 'query_var' => true, 'rewrite' => true));
register_post_type(
'testimonial',
array(
'labels' => array(
'name' => 'Testimonials',
'singular_name' => 'Testimonial'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'testimonial-type'),
'supports' => array('title', 'editor', 'thumbnail','comments'),
'can_export' => true,
)
);
register_taxonomy('testimonial_type', 'testimonial', array('hierarchical' => true, 'label' => 'Testimonial Categories', 'query_var' => true, 'rewrite' => true));
register_post_type(
'service',
array(
'labels' => array(
'name' => 'Services',
'singular_name' => 'Service'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'service-type'),
'supports' => array('title', 'editor', 'thumbnail','comments'),
'can_export' => true,
)
);
register_taxonomy('service_type', 'service', array('hierarchical' => true, 'label' => 'Service Categories', 'query_var' => true, 'rewrite' => true));
}
/* WooCommerce */
add_theme_support( 'woocommerce' );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
/**
* Register widgetized area and update sidebar with default widgets
*
* @since progression 1.0
*/
function progression_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'progression' ),
'id' => 'sidebar-1',
'description' => 'Default Sidebar',
'before_widget' => '<div id="%1$s" class="sidebar-item widget %2$s">',
'after_widget' => '<div class="sidebar-divider"></div></div>',
'before_title' => '<h5 class="widget-title">',
'after_title' => '</h5>',
) );
register_sidebar( array(
'name' => __( 'Footer Widgets', 'progression' ),
'description' => __( 'Footer widgets', 'progression' ),
'id' => 'footer-widgets',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6 class="widget-title">',
'after_title' => '</h6>',
) );
register_sidebar( array(
'name' => __( 'Homepage Widgets', 'progression' ),
'id' => 'homepage-widgets',
'description' => 'Display Home: widgets on the homepage page template',
'before_widget' => '<div id="%1$s" class="widget home-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="title-homepage">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Home: Widgets on all Pages', 'progression' ),
'id' => 'homepage-all-widgets',
'description' => 'Display Home: widgets on all pages above footer',
'before_widget' => '<div id="%1$s" class="widget home-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="title-homepage">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Portfolio Sidebar', 'progression' ),
'id' => 'sidebar-portfolio',
'description' => 'Optional portfolio Sidebar',
'before_widget' => '<div id="%1$s" class="sidebar-item widget %2$s">',
'after_widget' => '<div class="sidebar-divider"></div></div>',
'before_title' => '<h5 class="widget-title">',
'after_title' => '</h5>',
) );
register_sidebar( array(
'name' => __( 'Services Sidebar', 'progression' ),
'id' => 'sidebar-service',
'description' => 'Optional services Sidebar',
'before_widget' => '<div id="%1$s" class="sidebar-item widget %2$s">',
'after_widget' => '<div class="sidebar-divider"></div></div>',
'before_title' => '<h5 class="widget-title">',
'after_title' => '</h5>',
) );
register_sidebar( array(
'name' => __( 'Shop Sidebar', 'progression' ),
'id' => 'sidebar-shop',
'description' => 'WooCommerce Sidebar',
'before_widget' => '<div id="%1$s" class="sidebar-item widget %2$s">',
'after_widget' => '<div class="sidebar-divider"></div></div>',
'before_title' => '<h5 class="widget-title">',
'after_title' => '</h5>',
) );
}
add_action( 'widgets_init', 'progression_widgets_init' );
/* custom portfolio posts per page */
function my_post_queries( $query ) {
$portfolio_count = get_theme_mod('portfolio_pages_progression');
if ($query->is_main_query()){
if(is_tax( 'portfolio_type' )){
// show 50 posts on custom taxonomy pages
$query->set('posts_per_page', $portfolio_count);
}
}
if(is_post_type_archive( 'portfolio' )){
$query->set('posts_per_page', $portfolio_count);
}
$testimonial_count = get_theme_mod('testimonial_pages_progression');
if ($query->is_main_query()){
if(is_tax( 'testimonial_type' )){
// show 50 posts on custom taxonomy pages
$query->set('posts_per_page', $testimonial_count);
}
}
if(is_post_type_archive( 'testimonial' )){
$query->set('posts_per_page', $testimonial_count);
}
$servicecount = get_theme_mod('service_pages_progression');
if ($query->is_main_query()){
if(is_tax( 'service_type' )){
// show 50 posts on custom taxonomy pages
$query->set('posts_per_page', $servicecount);
}
}
if(is_post_type_archive( 'service' )){
$query->set('posts_per_page', $servicecount);
}
}
add_action( 'pre_get_posts', 'my_post_queries' );
/* remove more link jump */
function remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
add_filter( 'the_content_more_link', 'remove_more_link_scroll' );
/**
* Enqueue scripts and styles
*/
function progression_scripts() {
wp_enqueue_style( 'progression-style', get_stylesheet_uri() );
wp_enqueue_style( 'responsive', get_template_directory_uri() . '/css/responsive.css', array( 'progression-style' ) );
wp_enqueue_style( 'fira-font', '//code.cdn.mozilla.net/fonts/fira.css', array( 'progression-style' ) );
wp_enqueue_style( 'google-fonts', 'http://fonts.googleapis.com/css?family=PT+Sans+Narrow', array( 'progression-style' ) );
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/libs/modernizr-2.6.2.min.js', false, '20120206', false );
wp_enqueue_script( 'plugins', get_template_directory_uri() . '/js/plugins.js', array( 'jquery' ), '20120206', true );
wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), '20120206', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'progression_scripts' );
function pro_mobile_menu_insert()
{
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#mobile-menu .width-container').mobileMenu({
defaultText: '<?php _e( "Navigate to...", "progression" ); ?>',
className: 'select-menu',
subMenuDash: '––'
});
});
</script>
<?php
}
add_action('wp_footer', 'pro_mobile_menu_insert');
/*
MetaBox Options from Dev7studios
*/
require get_template_directory() . '/inc/dev7_meta_box_framework.php';
require get_template_directory() . '/inc/custom-fields.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Load Plugin Activiation
*/
require get_template_directory() . '/tgm-plugin-activation/plugin-activation.php';