-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
1771 lines (1510 loc) · 61.8 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
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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* franks functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package franks
*/
if ( ! function_exists( 'franks_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 for post thumbnails.
*/
function franks_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on franks, use a find and replace
* to change 'franks' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'franks', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'menu-1' => esc_html__( 'Primary', 'franks' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'franks_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
) );
}
endif;
add_action( 'after_setup_theme', 'franks_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function franks_content_width() {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'franks_content_width', 640 );
}
add_action( 'after_setup_theme', 'franks_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function franks_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'franks' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'franks' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'franks_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function franks_scripts() {
wp_enqueue_style( 'franks-style', get_stylesheet_uri() );
wp_enqueue_script( 'franks-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'franks-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script( 'franks-custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '20151215', true );
}
add_action( 'wp_enqueue_scripts', 'franks_scripts' );
//FIX: All orders not showing up in woocommerce version <3.5.2 after udpating to wordpress 5.0.3 - Can be removed when Woocommerce is upgraded to V3.5.2
// if(version_compare(get_option( 'woocommerce_version' ),"3.5.2","<=") && version_compare(get_bloginfo( 'version' ),"5.0.3","=") ){
function fix_request_query_args_for_woocommerce( $query_args ) {
if ( isset( $query_args['post_status'] ) && empty( $query_args['post_status'] ) ) {
unset( $query_args['post_status'] );
}
return $query_args;
}
add_filter( 'request', 'fix_request_query_args_for_woocommerce', 1, 1 );
// }
/**
* 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';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
/* Hook into the init action and call wine_boutique_brands_categories when it fires.
This creates the category which is specific and unique to Wine Boutique Events which
is then connected by the taxonomy within the Custom Post Type
*/
// add_action( 'init', 'wine_boutique_brands_categories', 0 );
/* Create a custom taxonomy name it topics for your posts
*/
// function wine_boutique_brands_categories() {
// /* Add new taxonomy, make it hierarchical like categories
// first do the translations part for GUI
// */
// $labels = array(
// 'name' => _x( 'Wine Boutique Brands Categories', 'taxonomy general name' ),
// 'singular_name' => _x( 'Wine Boutique Brand Category', 'taxonomy singular name' ),
// 'search_items' => __( 'Search Wine Boutique Brands Categories' ),
// 'all_items' => __( 'All Wine Boutique Brands Categories' ),
// 'parent_item' => __( 'Parent Wine Boutique Brand Category' ),
// 'parent_item_colon' => __( 'Parent Wine Boutique Brand Category:' ),
// 'edit_item' => __( 'Edit Wine Boutique Brand Category' ),
// 'update_item' => __( 'Update Wine Boutique Brand Category' ),
// 'add_new_item' => __( 'Add New Wine Boutique Brand Category' ),
// 'new_item_name' => __( 'New Wine Boutique Brand Category Name' ),
// 'menu_name' => __( 'Wine Boutique Brands Categories' ),
// );
// /* Registering the taxonomy with name brandscat for Wine Boutique Brands
// */
// register_taxonomy('brandscat',array('post'), array(
// 'hierarchical' => true,
// 'labels' => $labels,
// 'show_ui' => true,
// 'show_admin_column' => true,
// 'query_var' => true,
// 'rewrite' => array( 'slug' => 'brandcat' ),
// ));
// }
/* Creation of the Franks Wine Boutique Brands category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type.
*/
// function franks_wine_boutique_brands() {
// $labels = array(
// 'name' => _x('Wine Boutique Brands', 'post type general name'),
// 'singluar_name' => _x('Wine Boutique Brands', 'post type singular name'),
// 'add_new' => _x('Add New', 'Brands'),
// 'add_new_item' => __('Add New Brands'),
// 'edit_item' => __('Edit Brands'),
// 'new_item' => __('New Brands'),
// 'all_items' => __('All Brands'),
// 'view_item' => __('View Brands'),
// 'search_items' => __('Search Brands'),
// 'not_found' => __('No Brands found'),
// 'not_found_in_trash' => __('No Brands found in Trash'),
// 'parent_item_colon' => '',
// 'menu_name' => 'Wine Boutique Brands'
// );
// $args = array(
// 'labels' => $labels,
// 'description' => 'Holds our Brands and wb_brand specific data',
// 'menu_icon' => 'dashicons-star-empty',
// 'public' => true,
// 'menu_position' => 10,
// 'supports' => array('title', 'page_attributes', 'thumbnail'),
// 'has_archive' => true,
// /* Categories created for this specific CPT*/
// 'taxonomies' => array( 'brandscat' )
// );
// /* Registers the post type mentioned above to be hooked by init
// */
// register_post_type('wb_brand', $args);
// }
// /* Initialisation of the new custom post type
// The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
// */
// add_action('init', 'franks_wine_boutique_brands');
/* Hook into the init action and call wine_boutique_events_categories when it fires.
This creates the category which is specific and unique to Wine Boutique Events which
is then connected by the taxonomy within the Custom Post Type
*/
add_action( 'init', 'wine_boutique_events_categories', 0 );
/* Create a custom taxonomy name it topics for your posts
*/
function wine_boutique_events_categories() {
/* Add new taxonomy, make it hierarchical like categories
first do the translations part for GUI
*/
$labels = array(
'name' => _x( 'Wine Boutique Events Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Wine Boutique Event Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Wine Boutique Events Categories' ),
'all_items' => __( 'All Wine Boutique Events Categories' ),
'parent_item' => __( 'Parent Wine Boutique Event Category' ),
'parent_item_colon' => __( 'Parent Wine Boutique Event Category:' ),
'edit_item' => __( 'Edit Wine Boutique Event Category' ),
'update_item' => __( 'Update Wine Boutique Event Category' ),
'add_new_item' => __( 'Add New Wine Boutique Event Category' ),
'new_item_name' => __( 'New Wine Boutique Event Category Name' ),
'menu_name' => __( 'Wine Boutique Events Categories' ),
);
/* Registering the taxonomy with name eventscat for Wine Boutique Events
*/
register_taxonomy('eventscat',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'eventcat' ),
));
}
/* Creation of the Franks Wine Boutique Events category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type.
*/
function franks_wine_boutique_events() {
$labels = array(
'name' => _x('Wine Boutique Events', 'post type general name'),
'singluar_name' => _x('Wine Boutique Events', 'post type singular name'),
'add_new' => _x('Add New', 'Events'),
'add_new_item' => __('Add New Events'),
'edit_item' => __('Edit Events'),
'new_item' => __('New Events'),
'all_items' => __('All Events'),
'view_item' => __('View Events'),
'search_items' => __('Search Events'),
'not_found' => __('No Events found'),
'not_found_in_trash' => __('No Events found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Wine Boutique Events'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Events and its specific data',
'menu_icon' => 'dashicons-star-filled',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => false,
/* Categories created for this specific CPT*/
'taxonomies' => array( 'eventscat' )
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('events', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_wine_boutique_events');
/* Creation of the Franks Brands category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type*/
function franks_brands() {
$labels = array(
'name' => _x('Franks Brands', 'post type general name'),
'singluar_name' => _x('Franks Brands', 'post type singular name'),
'add_new' => _x('Add New', 'Brands'),
'add_new_item' => __('Add New Brands'),
'edit_item' => __('Edit Brands'),
'new_item' => __('New Brands'),
'all_items' => __('All Brands'),
'view_item' => __('View Brands'),
'search_items' => __('Search Brands'),
'not_found' => __('No Brands found'),
'not_found_in_trash' => __('No Brands found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Franks Brands'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Brands and its specific data',
'menu_icon' => 'dashicons-admin-multisite',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => false,
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('brands', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_brands');
/* Creation of the Franks Shops category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type
*/
function franks_shops() {
$labels = array(
'name' => _x('Franks Shops', 'post type general name'),
'singluar_name' => _x('Franks Shops', 'post type singular name'),
'add_new' => _x('Add New', 'Shops'),
'add_new_item' => __('Add New Shops'),
'edit_item' => __('Edit Shops'),
'new_item' => __('New Shops'),
'all_items' => __('All Shops'),
'view_item' => __('View Shops'),
'search_items' => __('Search Shops'),
'not_found' => __('No Shops found'),
'not_found_in_trash' => __('No Shops found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Franks Shops'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Shops and its specific data',
'menu_icon' => 'dashicons-building',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'page_attributes', 'thumbnail'),
'has_archive' => false,
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('shops', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_shops');
/* Hook into the init action and call franks_top_products_categories when it fires.
This creates the category which is specific and unique to Franks Top Products which
is then connected by the taxonomy within the Custom Post Type
*/
add_action( 'init', 'franks_top_products_categories', 0 );
/* Create a custom taxonomy name it topics for your posts
*/
function franks_top_products_categories() {
/* Add new taxonomy, make it hierarchical like categories
first do the translations part for GUI
*/
$labels = array(
'name' => _x( 'Franks Top Items Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Franks Top Item Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Franks Top Items Categories' ),
'all_items' => __( 'All Franks Top Items Categories' ),
'parent_item' => __( 'Parent Franks Top Item Category' ),
'parent_item_colon' => __( 'Parent Franks Top Item Category:' ),
'edit_item' => __( 'Edit Franks Top Item Category' ),
'update_item' => __( 'Update Franks Top Item Category' ),
'add_new_item' => __( 'Add New Franks Top Item Category' ),
'new_item_name' => __( 'New Franks Top Item Category Name' ),
'menu_name' => __( 'Franks Top Items Categories' ),
);
/* Registering the taxonomy with name topproductscat for Franks Top Products
*/
register_taxonomy('topproductscat',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'topproductcat' ),
));
}
/* Creation of the Franks Top Items category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type.
*/
function franks_top_products() {
$labels = array(
'name' => _x('Franks Top Items', 'post type general name'),
'singluar_name' => _x('Franks Top Items', 'post type singular name'),
'add_new' => _x('Add New', 'Franks Top Item'),
'add_new_item' => __('Add New Franks Top Item'),
'edit_item' => __('Edit Franks Top Item'),
'new_item' => __('New Franks Top Item'),
'all_items' => __('All Franks Top Item'),
'view_item' => __('View Franks Top Item'),
'search_items' => __('Search Franks Top Item'),
'not_found' => __('No Franks Top Item found'),
'not_found_in_trash' => __('No Franks Top Item found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Franks Top Items'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Franks Top Item specific data',
'menu_icon' => 'dashicons-awards',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => true,
/* Categories created for this specific CPT*/
'taxonomies' => array( 'topproductscat' )
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('top-products', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_top_products');
/* Creation of the Franks Loyalty Cards category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type
*/
function franks_loyalty_cards() {
$labels = array(
'name' => _x('Loyalty Cards', 'post type general name'),
'singluar_name' => _x('Loyalty Card', 'post type singular name'),
'add_new' => _x('Add New', 'Loyalty Card'),
'add_new_item' => __('Add New Loyalty Card'),
'edit_item' => __('Edit Loyalty Card'),
'new_item' => __('New Loyalty Card'),
'all_items' => __('All Loyalty Cards'),
'view_item' => __('View Loyalty Card'),
'search_items' => __('Search Loyalty Cards'),
'not_found' => __('No Loyalty Card found'),
'not_found_in_trash' => __('No Loyalty Card found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Loyalty Cards'
);
$args = array(
'labels' => $labels,
'description' => 'Holds the loyalty cards',
'menu_icon' => 'dashicons-id',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'page_attributes', 'thumbnail'),
'has_archive' => false,
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('loyalty-card', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_loyalty_cards');
/* Creation of the Franks Loyalty Cards category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type
*/
function franks_careers() {
$labels = array(
'name' => _x('Careers', 'post type general name'),
'singluar_name' => _x('Career', 'post type singular name'),
'add_new' => _x('Add New', 'Career'),
'add_new_item' => __('Add New Career'),
'edit_item' => __('Edit Career'),
'new_item' => __('New Career'),
'all_items' => __('All Careers'),
'view_item' => __('View Careers'),
'search_items' => __('Search Careers'),
'not_found' => __('No Careers found'),
'not_found_in_trash' => __('No Careers found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Careers'
);
$args = array(
'labels' => $labels,
'description' => 'Holds the Franks Careers',
'menu_icon' => 'dashicons-groups',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => false,
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('careers', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_careers');
/* Hook into the init action and call wine_boutique_brands_categories when it fires.
This creates the category which is specific and unique to Wine Boutique Events which
is then connected by the taxonomy within the Custom Post Type
*/
add_action( 'init', 'video_categories', 0 );
/* Create a custom taxonomy name it topics for your posts
*/
function video_categories() {
/* Add new taxonomy, make it hierarchical like categories
first do the translations part for GUI
*/
$labels = array(
'name' => _x( 'Videos Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Video Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Video Categories' ),
'all_items' => __( 'All Video Categories' ),
'parent_item' => __( 'Parent Video Category' ),
'parent_item_colon' => __( 'Parent Video Category:' ),
'edit_item' => __( 'Edit Video Category' ),
'update_item' => __( 'Update Video Category' ),
'add_new_item' => __( 'Add New Video Category' ),
'new_item_name' => __( 'New Video Category Name' ),
'menu_name' => __( 'Videos Categories' ),
);
register_taxonomy('videoscat',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'videocat' ),
));
}
function franks_videos() {
$labels = array(
'name' => _x('How To Use Videos', 'post type general name'),
'singluar_name' => _x('How To Use Videos', 'post type singular name'),
'add_new' => _x('Add New', 'Videos'),
'add_new_item' => __('Add New Videos'),
'edit_item' => __('Edit Videos'),
'new_item' => __('New Videos'),
'all_items' => __('All Videos'),
'view_item' => __('View Videos'),
'search_items' => __('Search Videos'),
'not_found' => __('No Videos found'),
'not_found_in_trash' => __('No Videos found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'How To Use Videos'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Shops and its specific data',
'menu_icon' => 'dashicons-editor-video',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'page_attributes', 'thumbnail'),
'has_archive' => false,
'taxonomies' => array( 'videoscat' )
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('video', $args);
}
add_action('init', 'franks_videos');
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_heritage');
function franks_heritage() {
$labels = array(
'name' => _x('Franks Heritage', 'post type general name'),
'singluar_name' => _x('Franks Heritage', 'post type singular name'),
'add_new' => _x('Add New', 'Heritage'),
'add_new_item' => __('Add New Heritage post'),
'edit_item' => __('Edit Heritage'),
'new_item' => __('New Heritage'),
'all_items' => __('All Heritage'),
'view_item' => __('View Heritage'),
'search_items' => __('Search Heritage'),
'not_found' => __('No Posts found'),
'not_found_in_trash' => __('No Posts found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Heritage'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Shops and its specific data',
'menu_icon' => 'dashicons-clock',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => false
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('heritage', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'franks_heritage');
function makeup_academy() {
$labels = array(
'name' => _x('Franks Make-Up Academy', 'post type general name'),
'singluar_name' => _x('Franks Make-Up Academy', 'post type singular name'),
'add_new' => _x('Add New', 'Make-Up Academy'),
'add_new_item' => __('Add New Make-Up Academy'),
'edit_item' => __('Edit Make-Up Academy'),
'new_item' => __('New Make-Up Academy'),
'all_items' => __('All Make-Up Academy'),
'view_item' => __('View Make-Up Academy'),
'search_items' => __('Search Make-Up Academy'),
'not_found' => __('No Make-Up Academy found'),
'not_found_in_trash' => __('No Make-Up Academy found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Franks Make-Up Academy'
);
$args = array(
'labels' => $labels,
'description' => 'Holds Make-Up Academy posts',
'menu_icon' => 'dashicons-art',
'public' => true,
'menu_position' => 11,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => false,
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('make-up-academy', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'makeup_academy');
function other_services() {
$labels = array(
'name' => _x('Franks Services', 'post type general name'),
'singluar_name' => _x('Franks Services', 'post type singular name'),
'add_new' => _x('Add New', 'Services'),
'add_new_item' => __('Add New Services'),
'edit_item' => __('Edit Services'),
'new_item' => __('New Services'),
'all_items' => __('All Services'),
'view_item' => __('View Services'),
'search_items' => __('Search Services'),
'not_found' => __('No Services found'),
'not_found_in_trash' => __('No Services found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Franks Services'
);
$args = array(
'labels' => $labels,
'description' => 'Holds Services posts',
'menu_icon' => 'dashicons-hammer',
'public' => true,
'menu_position' => 12,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => false,
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('services', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'other_services');
/* Hook into the init action and call franks_top_products_categories when it fires.
This creates the category which is specific and unique to Franks Top Products which
is then connected by the taxonomy within the Custom Post Type
*/
add_action( 'init', 'dior_expertise_categories', 0 );
/* Create a custom taxonomy name it topics for your posts
*/
function dior_expertise_categories() {
/* Add new taxonomy, make it hierarchical like categories
first do the translations part for GUI
*/
$labels = array(
'name' => _x( 'Dior Expertise Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Dior Expertise Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Dior Expertise Categories' ),
'all_items' => __( 'All Dior Expertise Categories' ),
'parent_item' => __( 'Parent Dior Expertise Category' ),
'parent_item_colon' => __( 'Parent Dior Expertise Category:' ),
'edit_item' => __( 'Edit Dior Expertise Category' ),
'update_item' => __( 'Update Franks Top Item Category' ),
'add_new_item' => __( 'Add New Dior Expertise Category' ),
'new_item_name' => __( 'New Dior Expertise Category Name' ),
'menu_name' => __( 'Dior Expertise Categories' ),
);
/* Registering the taxonomy with name topproductscat for Franks Top Products
*/
register_taxonomy('diorexpertisecat',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'diorexpertisecat' ),
));
}
/* Creation of the Dior Expertise category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type.
*/
function dior_expertise() {
$labels = array(
'name' => _x('Dior Expertise', 'post type general name'),
'singluar_name' => _x('Dior Expertise', 'post type singular name'),
'add_new' => _x('Add New', 'Dior Expertise Item'),
'add_new_item' => __('Add New Dior Expertise Item'),
'edit_item' => __('Edit Dior Expertise Item'),
'new_item' => __('New Dior Expertise Item'),
'all_items' => __('All Dior Expertise Items'),
'view_item' => __('View Dior Expertise Item'),
'search_items' => __('Search Dior Expertise Item'),
'not_found' => __('No Dior Expertise Item found'),
'not_found_in_trash' => __('No Dior Expertise Item found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Dior Expertise'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Dior Expertise Item specific data',
'menu_icon' => 'dashicons-image-filter',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => true,
/* Categories created for this specific CPT*/
'taxonomies' => array( 'diorexpertisecat' )
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('dior-expertise', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'dior_expertise');
add_action( 'init', 'tips_categories', 0 );
/* Create a custom taxonomy name it topics for your posts
*/
function tips_categories() {
/* Add new taxonomy, make it hierarchical like categories
first do the translations part for GUI
*/
$labels = array(
'name' => _x( 'Tips & Tricks Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Tips & Tricks Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Tips & Tricks Categories' ),
'all_items' => __( 'All Tips & Tricks Categories' ),
'parent_item' => __( 'Parent Tips & Tricks Category' ),
'parent_item_colon' => __( 'Parent Tips & Tricks Category:' ),
'edit_item' => __( 'Edit Tips & Tricks Category' ),
'update_item' => __( 'Update Tips & Tricks Category' ),
'add_new_item' => __( 'Add New Tips & Tricks Category' ),
'new_item_name' => __( 'New Tips & Tricks Category Name' ),
'menu_name' => __( 'Tips & Tricks Categories' ),
);
/* Registering the taxonomy with name topproductscat for Franks Top Products
*/
register_taxonomy('tips_category',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'tips_category' ),
));
}
/* Creation of the Dior Expertise category within the Wordpress backend
Information that is inserted into this category is via Advanced Custom Fields
such as images, links, text etc...
From here we are just initialising the custom post type.
*/
function tips_tricks() {
$labels = array(
'name' => _x('Tips & Tricks', 'post type general name'),
'singluar_name' => _x('Tips & Tricks', 'post type singular name'),
'add_new' => _x('Add New', 'Tips & Tricks Item'),
'add_new_item' => __('Add New Tips & Tricks Item'),
'edit_item' => __('Edit Tips & Tricks Item'),
'new_item' => __('New Tips & Tricks Item'),
'all_items' => __('All Tips & Tricks Items'),
'view_item' => __('View Tips & Tricks Item'),
'search_items' => __('Search Tips & Tricks Item'),
'not_found' => __('No Tips & Tricks Item found'),
'not_found_in_trash' => __('No Tips & Tricks Item found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Tips & Tricks'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Tips & Tricks Item specific data',
'menu_icon' => 'dashicons-lightbulb',
'public' => true,
'menu_position' => 10,
'supports' => array('title', 'editor', 'page_attributes', 'thumbnail'),
'has_archive' => true,
/* Categories created for this specific CPT*/
'taxonomies' => array( 'tips_category' )
);
/* Registers the post type mentioned above to be hooked by init
*/
register_post_type('tips', $args);
}
/* Initialisation of the new custom post type
The init method of the $wp object is called next to setup the current user’s settings and the hook add_action( 'init' ) is run.
*/
add_action('init', 'tips_tricks');
add_filter('acf/settings/remove_wp_meta_box', '__return_false');
add_action( 'woocommerce_after_single_product_summary_custom', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary_custom', 'woocommerce_output_related_products', 20 );
/* Start - Code used to set up Woocommerce to use our custom woocommerce templates under franks/woocommerce/ */
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
/* end */
//Number of products to show per page
add_filter('loop_shop_per_page', create_function('$cols', 'return 15;'));
add_action( 'woocommerce_single_product_summary_custom', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary_custom', 'woocommerce_template_single_add_to_cart', 25 );
add_action( 'woocommerce_after_single_product_summary_custom', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary_custom', 'woocommerce_output_related_products', 20 );
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );
function keep_me_logged_in_for_1_year( $expirein ) {
return 31556926; // 1 year in seconds
}
function get_brand($post_name) {
$args = array(
'name' => $post_name,
'post_type' => 'brands',
);
$query = new WP_Query($args);
return $query;
}
function get_how_to_use_link($category_id) {
// get parent category
$parent_cat = get_category(get_parent_category($category_id));
// find category with the same name in How to Use Videos custom post
$link = get_term_link($parent_cat->slug, 'video-category');
// var_dump($parent_cat);
$how_to_container;
if (!isset($link->errors)) {
$how_to_container = how_to_use_html($link);
}
return $how_to_container;
}
function get_parent_category($category_id) {
while ($category_id) {
$cat = get_category($category_id); // get the object for the catid
$category_id = $cat->category_parent; // assign parent ID (if exists) to $catid
// the while loop will continue whilst there is a $catid
// when there is no longer a parent $catid will be NULL so we can assign our $catParent
$catParent = $cat->cat_ID;
}
return $catParent;
}
function how_to_use_html($link) {
$html = '<div class="how-to-use-link">' . "\n";
$html .= '<a href="' . $link . '">How to Use</a>' . "\n";
$html .= '</div>' . "\n";
return $html;
}
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
}
return ! empty( $free ) ? $free : $rates;
}
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 50 );
/* START: Extra checkout fields*/
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
$field = get_field('gift_message_options','option');
//Keys of array
$itemKeys = array();
$default = array("No Message" => "Select a Message:");
foreach($field as $message){
$itemKeys[] = $message['message'];
}
$final = array_combine($itemKeys, $itemKeys);
$final = array_merge($default, $final);
echo '<div id="my_custom_checkout_field"><h2>' . __('Gift') . '</h2>';
woocommerce_form_field( 'gift_wrapping', array(
'type' => 'checkbox',
'class' => array('form-row-wide'),
'label' => __('Gift Wrapping'),
'required' => false,
), $checkout->get_value( 'gift_wrapping' ));
woocommerce_form_field( 'gift_wrap_message', array(
'type' => 'select',
'class' => array('form-row-wide'),