-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
263 lines (196 loc) · 11.5 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
<?php
/*add_theme_support( 'post-thumbnails' );*/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
acf_add_options_sub_page('General');
acf_add_options_sub_page('Cases');
acf_add_options_sub_page('Header');
acf_add_options_sub_page('Footer');
}
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "If you like this post, then please consider retweeting it or sharing it on Facebook.";
return $content;
}
add_action('acf/register_fields', 'my_register_fields');
function my_register_fields()
{
include_once('acf-range/acf-range.php');
}
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats' );
add_theme_support( 'menus' );
add_theme_support( 'widgets' );
//Search
add_theme_support('html5',array('search-form'));
function NAME_script_enqueue() {
wp_enqueue_script('customjs', get_template_directory_uri() . '/js/smoothscroll.js', array(), '1.0.0', true);
wp_enqueue_script('toggleclassjs', get_template_directory_uri() . '/js/toggleclass.js', array(), '1.0.0', true);
}
add_action( 'wp_enqueue_scripts', 'NAME_script_enqueue');
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' ),
'extra-menu' => __( 'Extra Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
//BOOTSTRAP
function themebs_enqueue_styles() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'core', get_template_directory_uri() . '/css/style.css' );
}
add_action( 'wp_enqueue_scripts', 'themebs_enqueue_styles');
function themebs_enqueue_scripts() {
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/vendor/bootstrap.bundle.min.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'themebs_enqueue_scripts');
// Add Google Fonts
function startwordpress_google_fonts() {
wp_register_style('Montserrat', 'https://fonts.googleapis.com/css?family=Montserrat:300,400,500');
wp_enqueue_style( 'Montserrat');
}
add_action('wp_print_styles', 'startwordpress_google_fonts');
add_filter( 'body_class', 'my_class_names' );
function my_class_names( $classes ) {
// add 'class-name' to the $classes array
$classes[] = 'whitebg';
// return the $classes array
return $classes;
}
// Register a custom post type called "Team".
// @see get_post_type_labels() for label keys.
function my_team() {
$labels = array(
'name' => _x( 'Team', 'Post type general name', 'textdomain' ),
'singular_name' => _x( 'Team', 'Post type singular name', 'textdomain' ),
'menu_name' => _x( 'Team', 'Admin Menu text', 'textdomain' ),
'name_admin_bar' => _x( 'Team', 'Add New on Toolbar', 'textdomain' ),
'add_new' => __( 'Add New', 'textdomain' ),
'add_new_item' => __( 'Add New Team Member', 'textdomain' ),
'new_item' => __( 'New Team Member', 'textdomain' ),
'edit_item' => __( 'Edit Team Member', 'textdomain' ),
'view_item' => __( 'View Team Member', 'textdomain' ),
'all_items' => __( 'All Team Members', 'textdomain' ),
'search_items' => __( 'Search Team Members', 'textdomain' ),
'parent_item_colon' => __( 'Parent Team Members:', 'textdomain' ),
'not_found' => __( 'No Team Member found.', 'textdomain' ),
'not_found_in_trash' => __( 'No Team Member found in Trash.', 'textdomain' ),
'featured_image' => _x( 'Team Members Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'textdomain' ),
'set_featured_image' => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
'use_featured_image' => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
'archives' => _x( 'Team Members archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'textdomain' ),
'insert_into_item' => _x( 'Insert into Team Members', 'Overrides the “Insert into post”/“Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'textdomain' ),
'uploaded_to_this_item' => _x( 'Uploaded to this Team Members', 'Overrides the “Uploaded to this post”/“Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'textdomain' ),
'filter_items_list' => _x( 'Filter Team Members list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/“Filter pages list”. Added in 4.4', 'textdomain' ),
'items_list_navigation' => _x( 'Team Members list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/“Pages list navigation”. Added in 4.4', 'textdomain' ),
'items_list' => _x( 'Team Members list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/“Pages list”. Added in 4.4', 'textdomain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'team' ),
'capability_type' => 'page',
'has_archive' => true,
'hierarchical' => false,
'orderby' => 'date',
'order' => 'desc',
'menu_position' => null,
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail','page-attributes' ),
'taxonomies' => array( 'post_tag', 'category' ),
);
register_post_type( 'team', $args );
}
add_action( 'init', 'my_team' );
// Register a custom post type called "case".
// @see get_post_type_labels() for label keys.
function my_cases() {
$labels = array(
'name' => _x( 'Cases', 'Post type general name', 'textdomain' ),
'singular_name' => _x( 'Case', 'Post type singular name', 'textdomain' ),
'menu_name' => _x( 'Cases', 'Admin Menu text', 'textdomain' ),
'name_admin_bar' => _x( 'Case', 'Add New on Toolbar', 'textdomain' ),
'add_new' => __( 'Add New', 'textdomain' ),
'add_new_item' => __( 'Add New Case', 'textdomain' ),
'new_item' => __( 'New Case', 'textdomain' ),
'edit_item' => __( 'Edit Case', 'textdomain' ),
'view_item' => __( 'View Case', 'textdomain' ),
'all_items' => __( 'All Cases', 'textdomain' ),
'search_items' => __( 'Search Cases', 'textdomain' ),
'parent_item_colon' => __( 'Parent Cases:', 'textdomain' ),
'not_found' => __( 'No Cases found.', 'textdomain' ),
'not_found_in_trash' => __( 'No Cases found in Trash.', 'textdomain' ),
'featured_image' => _x( 'Cases Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'textdomain' ),
'set_featured_image' => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
'use_featured_image' => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
'archives' => _x( 'Cases archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'textdomain' ),
'insert_into_item' => _x( 'Insert into Case', 'Overrides the “Insert into post”/“Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'textdomain' ),
'uploaded_to_this_item' => _x( 'Uploaded to this Case', 'Overrides the “Uploaded to this post”/“Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'textdomain' ),
'filter_items_list' => _x( 'Filter cases list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/“Filter pages list”. Added in 4.4', 'textdomain' ),
'items_list_navigation' => _x( 'Cases list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/“Pages list navigation”. Added in 4.4', 'textdomain' ),
'items_list' => _x( 'Cases list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/“Pages list”. Added in 4.4', 'textdomain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'cases' ),
'capability_type' => 'page',
'has_archive' => true,
'hierarchical' => false,
'orderby' => 'date',
'order' => 'desc',
'menu_position' => null,
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail','page-attributes' ),
'taxonomies' => array( 'post_tag', 'category' ),
);
register_post_type( 'cases', $args );
}
add_action( 'init', 'my_cases' );
add_filter('use_block_editor_for_post_type', 'd4p_32752_completly_disable_block_editor');
function d4p_32752_completly_disable_block_editor($use_block_editor) {
return false;
}
function my_acf_init() {
acf_update_setting('google_api_key', 'AIzaSyALj8kKpc9WhnsSUFEkYvnz96sMKG5hvUw');
}
add_action('acf/init', 'my_acf_init');
/*
Checks for a yoast primary category, if it exists move the category to the first position in the $categories array.
*/
function yoast_primary_cat_as_first_cat($categories) {
// Check if yoast exists and get the primary category
if ($categories && class_exists('WPSEO_Primary_Term') ) {
// Show the post's 'Primary' category, if this Yoast feature is available, & one is set
$wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_id() );
$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
$term = get_term( $wpseo_primary_term );
// If no error is returned, get primary yoast term
$primary_cat_term_id = (!is_wp_error($term)) ? $term->term_id : null;
// Loop all categories
if($primary_cat_term_id !== null) {
foreach ($categories as $i => $category) {
// Move the primary category to the top of the array
if($category->term_id === $primary_cat_term_id) {
$out = array_splice($categories, $i, 1);
array_splice($categories, 0, 0, $out);
break;
}
}
}
}
return $categories;
}
add_filter( 'get_the_categories', 'yoast_primary_cat_as_first_cat' );
?>