-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfunctions.php
More file actions
487 lines (418 loc) · 16.6 KB
/
Copy pathfunctions.php
File metadata and controls
487 lines (418 loc) · 16.6 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
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<?php
/**
* switch functions and definitions
*
* @package switch
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 640; /* pixels */
}
if ( ! function_exists( 'switch_setup' ) ) :
function switch_setup() {
load_theme_textdomain( 'switch', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'switch' ),
) );
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
) );
add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'switch_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
}
endif; // switch_setup
add_action( 'after_setup_theme', 'switch_setup' );
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function switch_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'switch' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'switch_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function switch_scripts() {
wp_enqueue_style( 'switch-style', get_stylesheet_uri() );
wp_enqueue_script( 'switch-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '', true );
wp_enqueue_script( 'switch-modernizr', get_template_directory_uri() . '/js/vendor/modernizr-2.6.2.min.js', array(), '', true );
wp_enqueue_script( 'switch-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '', true );
wp_enqueue_script( 'switch-smooth', get_template_directory_uri() . '/js/smooth-scroll.js', array(), '', true );
wp_enqueue_script( 'switch-isotope', get_template_directory_uri() . '/js/isotope.min.js', array(), '', true );
wp_enqueue_script( 'switch-hoverdir', get_template_directory_uri() . '/js/jquery.hoverdir.js', array(), '', true );
wp_enqueue_script( 'switch-popup', get_template_directory_uri() . '/js/jquery.magnific-popup.min.js', array(), '', true );
wp_enqueue_script( 'switch-nicescroll', get_template_directory_uri() . '/js/jquery.nicescroll.min.js', array(), '', true );
wp_enqueue_script( 'switch-wow', get_template_directory_uri() . '/js/wow.min.js', array(), '', true );
wp_enqueue_script( 'switch-owl', get_template_directory_uri() . '/js/owl.carousel.js', array(), '', true );
wp_enqueue_script( 'switch-main', get_template_directory_uri() . '/js/main.js', array(), '', true );
wp_enqueue_script( 'switch-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'switch_scripts' );
/**
* Implement the Custom Header feature.
*/
//require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/extras.php';
require get_template_directory() . '/inc/customizer.php';
require get_template_directory() . '/inc/jetpack.php';
/*
* Include Redux Framework
*/
if ( !class_exists( 'ReduxFramework' ) ) {
require_once( dirname( __FILE__ ) . '/libs/ReduxCore/framework.php' );
}
if ( !isset( $redux_demo ) ) {
require_once( dirname( __FILE__ ) . '/inc/theme-settings.php' );
}
function tx_switch_cmb()
{
$prefix = "_tx_";
$meta_boxes[] = array(
'id' => 'feature',
'title' => __('feature Details (Latest feature will be displayed on top)',"tx_switch"),
'pages' => array('feature'), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => __('Feature Icon ',"tx_switch"),
'id' => $prefix . 'exp_url',
'type' => 'file'
),
array(
'name' => __('Description',"tx_switch"),
'id' => $prefix . 'exp_description',
'type' => 'textarea'
),
)
);
// Testimonial Meta Box
$meta_boxes[] = array(
'id' => 'testimonial',
'title' => __('Testimonial Details (Latest testimonial will be displayed first)',"tx_switch"),
'pages' => array('testimonial'), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => __('Testimonial image ',"tx_switch"),
'id' => $prefix . 'test_image',
'type' => 'file'
),
array(
'name' => __('Name of the Person ',"tx_switch"),
'id' => $prefix . 'test_name',
'type' => 'text_medium'
),
array(
'name' => __('Designation',"tx_switch"),
'id' => $prefix . 'test_designation',
'type' => 'text_medium'
),
array(
'name' => __('Testimonial ',"tx_switch"),
'id' => $prefix . 'test_description',
'type' => 'wysiwyg'
),
)
);
// Team Meta box
$meta_boxes[] = array(
'id' => 'team',
'title' => __('team Details (Latest team will be displayed on top)',"tx_switch"),
'pages' => array('team'), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => __('Team member Image ',"tx_switch"),
'id' => $prefix . 'team_img',
'type' => 'file'
),
array(
'name' => __('Description',"tx_switch"),
'id' => $prefix . 'team_description',
'type' => 'wysiwyg',
),
array(
'name' => __('Facebook Link',"tx_switch"),
'id' => $prefix . 'team_facebook_link',
'type' => 'text',
),
array(
'name' => __('Twitter Link',"tx_switch"),
'id' => $prefix . 'team_twitter_link',
'type' => 'text',
),
array(
'name' => __('Linkedin Link',"tx_switch"),
'id' => $prefix . 'team_linkedin_link',
'type' => 'text',
),
array(
'name' => __('Dribbble Link',"tx_switch"),
'id' => $prefix . 'team_dribbble_link',
'type' => 'text',
),
)
);
// Portfolio Meta Box
$meta_boxes[] = array(
'id' => 'postfolio',
'title' => __('Portfolio Details (Latest Portfolio will be displayed on top)',"tx_switch"),
'pages' => array('portfolio'), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => __('Live Preview Link',"tx_switch"),
'id' => $prefix . 'portfolio_link',
'type' => 'text_medium'
),
array(
'name' => __('Portfolio Item Image',"tx_switch"),
'id' => $prefix . 'portfolio_img',
'type' => 'file'
),
array(
'name' => __('Large Portfolio Image',"tx_switch"),
'id' => $prefix . 'large_portfolio_img',
'type' => 'file'
),
)
);
return $meta_boxes;
}
add_filter('cmb_meta_boxes', 'tx_switch_cmb');
// Initialize the metabox class
add_action('init', 'tx_initialize_cmb_meta_boxes', 9999);
function tx_initialize_cmb_meta_boxes()
{
if (!class_exists('cmb_Meta_Box')) {
require_once('libs/cmb/init.php');
}
}
function tx_switch_fields()
{
$labels1 = array(
'name' => _x('features', 'Post Type General Name', 'tx_switch'),
'singular_name' => _x('feature', 'Post Type Singular Name', 'tx_switch'),
'menu_name' => __('Features', 'tx_switch'),
'parent_item_colon' => __('Parent feature:', 'tx_switch'),
'all_items' => __('All features', 'tx_switch'),
'view_item' => __('View feature', 'tx_switch'),
'add_new_item' => __('Add New feature', 'tx_switch'),
'add_new' => __('New feature', 'tx_switch'),
'edit_item' => __('Edit feature', 'tx_switch'),
'update_item' => __('Update feature', 'tx_switch'),
'search_items' => __('Search feature', 'tx_switch'),
'not_found' => __('No feature found', 'tx_switch'),
'not_found_in_trash' => __('No features found in Trash', 'tx_switch'),
);
$args1 = array(
'label' => __('feature', 'tx_switch'),
'description' => __('feature', 'tx_switch'),
'labels' => $labels1,
'supports' => array('title'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => get_template_directory_uri() . '/images/menu-icon/feature.png',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type('feature', $args1);
// Testimonial Section
$labels4 = array(
'name' => _x('Testimonials', 'Post Type General Name', 'tx_switch'),
'singular_name' => _x('Testimonial', 'Post Type Singular Name', 'tx_switch'),
'menu_name' => __('Testimonials', 'tx_switch'),
'parent_item_colon' => __('Parent Testimonial:', 'tx_switch'),
'all_items' => __('All Testimonials', 'tx_switch'),
'view_item' => __('View Testimonial', 'tx_switch'),
'add_new_item' => __('Add New Testimonial', 'tx_switch'),
'add_new' => __('New Testimonial', 'tx_switch'),
'edit_item' => __('Edit Testimonial', 'tx_switch'),
'update_item' => __('Update Testimonial', 'tx_switch'),
'search_items' => __('Search Testimonials', 'tx_switch'),
'not_found' => __('No testimonial found', 'tx_switch'),
'not_found_in_trash' => __('No testimonials found in Trash', 'tx_switch'),
);
$args4 = array(
'label' => __('Testimonial', 'tx_switch'),
'description' => __('Testimonial', 'tx_switch'),
'labels' => $labels4,
'supports' => array('title'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => get_template_directory_uri() . '/images/menu-icon/testimonial.png',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type('testimonial', $args4);
// Team section
$labels1 = array(
'name' => _x('team', 'Post Type General Name', 'tx_switch'),
'singular_name' => _x('team', 'Post Type Singular Name', 'tx_switch'),
'menu_name' => __('Team', 'tx_switch'),
'parent_item_colon' => __('Parent team:', 'tx_switch'),
'all_items' => __('All team', 'tx_switch'),
'view_item' => __('View team', 'tx_switch'),
'add_new_item' => __('Add New team', 'tx_switch'),
'add_new' => __('New team member', 'tx_switch'),
'edit_item' => __('Edit team', 'tx_switch'),
'update_item' => __('Update team', 'tx_switch'),
'search_items' => __('Search team', 'tx_switch'),
'not_found' => __('No team found', 'tx_switch'),
'not_found_in_trash' => __('No team found in Trash', 'tx_switch'),
);
$args1 = array(
'label' => __('team', 'tx_switch'),
'description' => __('team', 'tx_switch'),
'labels' => $labels1,
'supports' => array('title'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => get_template_directory_uri() . '/images/menu-icon/team.png',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type('team', $args1);
// Portfolio Custom Field
$labels2 = array(
'name' => _x('Porftolio', 'Post Type General Name', 'tx_switch'),
'singular_name' => _x('Portfolio', 'Post Type Singular Name', 'tx_switch'),
'menu_name' => __('Porftolio', 'tx_switch'),
'parent_item_colon' => __('Parent Portfolio:', 'tx_switch'),
'all_items' => __('All Porftolio', 'tx_switch'),
'view_item' => __('View Portfolio', 'tx_switch'),
'add_new_item' => __('Add New Portfolio', 'tx_switch'),
'add_new' => __('New Portfolio', 'tx_switch'),
'edit_item' => __('Edit Portfolio', 'tx_switch'),
'update_item' => __('Update Portfolio', 'tx_switch'),
'search_items' => __('Search Porftolio', 'tx_switch'),
'not_found' => __('No Portfolio found', 'tx_switch'),
'not_found_in_trash' => __('No Porftolio found in Trash', 'tx_switch'),
);
$args2 = array(
'label' => __('Portfolio', 'tx_switch'),
'description' => __('Portfolio', 'tx_switch'),
'labels' => $labels2,
'supports' => array('title'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => get_template_directory_uri() . '/images/menu-icon/portfolio.png',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type('Portfolio', $args2);
}
add_action('init', 'tx_switch_fields', 0);
add_action( 'init', 'register_taxonomy_filters' );
function register_taxonomy_filters() {
$labels = array(
'name' => __( 'Filters', 'webdgallery' ),
'singular_name' => __( 'Filter', 'webdgallery' ),
'search_items' => __( 'Search Filters', 'webdgallery' ),
'popular_items' => __( 'Popular Filters', 'webdgallery' ),
'all_items' => __( 'All Filters', 'webdgallery' ),
'parent_item' => __( 'Parent Filter', 'webdgallery' ),
'parent_item_colon' => __( 'Parent Filter:', 'webdgallery' ),
'edit_item' => __( 'Edit Filter', 'webdgallery' ),
'update_item' => __( 'Update Filter', 'webdgallery' ),
'add_new_item' => __( 'Add New Filter', 'webdgallery' ),
'new_item_name' => __( 'New Filter', 'webdgallery' ),
'separate_items_with_commas' => __( 'Separate Filters with commas', 'webdgallery' ),
'add_or_remove_items' => __( 'Add or remove Filters', 'webdgallery' ),
'choose_from_most_used' => __( 'Choose from the most used Filters', 'webdgallery' ),
'menu_name' => __( 'Filters', 'webdgallery' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => false,
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => true,
'query_var' => true
);
register_taxonomy( 'filters', array('portfolio'), $args );
}
add_filter( 'post_class', 'theme_t_wp_taxonomy_post_class', 10, 3 );
function theme_t_wp_taxonomy_post_class( $classes, $class, $ID ) {
$taxonomy = 'filters';
$terms = get_the_terms( (int) $ID, $taxonomy );
if( !empty( $terms ) ) {
foreach( (array) $terms as $order => $term ) {
if( !in_array( $term->slug, $classes ) ) {
$classes[] = $term->slug;
}
}
}
return $classes;
}
// TGM Pluign activator
require_once get_template_directory() . '/libs/plugin-activator.php';