-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
173 lines (159 loc) · 5.11 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
<?php
//Hide admin bar
show_admin_bar( false );
require_once( 'class-wp-bootstrap-navwalker.php' );
//Register menu
register_nav_menus( array(
'main' => 'Main Menu',
) );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'menus' );
}
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery' ) );
add_theme_support( 'post-thumbnails' );
//Load assets
function my_assets() {
if ( ! is_page( 'contact' ) ) {
wp_deregister_script( 'jquery' );
wp_deregister_style( 'contact-form-7' );
wp_deregister_script( 'contact-form-7' );
}
wp_enqueue_script( 'vendors', get_template_directory_uri() . '/js/vendor.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'index', get_template_directory_uri() . '/js/index.min.js', array(), '1.0.0', true );
wp_deregister_script( 'wp-embed' );
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
//Portfolio CPT
add_action( 'init', 'add_portfolio_items' );
function add_portfolio_items() {
register_post_type(
'portfolio-item',
array(
'labels' => array(
'name' => 'Cases',
'singular_name' => 'Case',
'add_new' => 'Add new item',
'add_new_item' => 'Add new item',
'edit' => 'Edit',
'edit_item' => 'Edit',
'new_item' => 'Add new item',
'view' => 'Edit item',
'view_item' => 'Edit item',
'search_items' => 'Search cases',
'not_found' => 'No items',
'not_found_in_trash' => 'Trash is empty',
),
'public' => true,
'hierarchical' => true,
'has_archive' => true,
'menu_position' => 7,
'menu_icon' => 'dashicons-format-gallery',
'taxonomies' => array( 'skills' ),
'show_in_nav_menus' => true,
'supports' => array(
'title',
'editor',
'thumbnail',
),
'can_export' => true,
)
);
}
//Skills taxonomy
add_action( 'init', 'skills_cuctom_taxonomy', 0 );
function skills_cuctom_taxonomy() {
$singular = 'Skill';
$plural = 'Skills';
$labels = array(
'name' => _x( $plural, 'taxonomy general name' ),
'singular_name' => _x( $singular, 'taxonomy singular name' ),
'search_items' => __( 'Search ' . $plural ),
'all_items' => __( 'All ' . $singular ),
'parent_item' => __( 'Parent ' . $singular ),
'parent_item_colon' => __( 'Parent ' . $singular ),
'edit_item' => __( 'Edit ' . $singular ),
'update_item' => __( 'Update ' . $singular ),
'add_new_item' => __( 'Add New ' . $singular ),
'new_item_name' => __( 'New ' . $singular . ' name' ),
'menu_name' => __( $plural ),
);
register_taxonomy( 'skills', array( 'portfolio-item' ), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'skills' ),
) );
}
//Blog CPT
add_action( 'init', 'pf_register_blog_post_type' );
function pf_register_blog_post_type() {
$singular = 'Blog Post';
$plural = 'Blog';
$slug = 'blog';
$labels = array(
'name' => $plural,
'singular_name' => $singular,
'add_new' => 'Add New',
'add_new_item' => 'Add New ' . $singular,
'edit' => 'Edit',
'edit_item' => 'Edit ' . $singular,
'new_item' => 'New ' . $singular,
'view' => 'View ' . $singular,
'view_item' => 'View ' . $singular,
'search_term' => 'Search ' . $plural,
'parent' => 'Parent ' . $singular,
'not_found' => 'No ' . $plural . ' found',
'not_found_in_trash' => 'No ' . $plural . ' in Trash'
);
$args = array(
'labels' => $labels,
'taxonomies' => array( 'post_tag' ),
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => 8,
'menu_icon' => 'dashicons-welcome-write-blog',
'can_export' => true,
'delete_with_user' => false,
'hierarchical' => false,
'has_archive' => true,
'query_var' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'rewrite' => array(
'slug' => $slug,
'with_front' => true,
'pages' => true,
'feeds' => true,
),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'comments',
'revisions'
)
);
register_post_type( $slug, $args );
}
//Add SVG media support
function cc_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
$acf_opt_args = array(
'page_title' => 'Theme Settings',
'menu_title' => 'Theme Settings',
'icon_url' => 'dashicons-hammer',
);
acf_add_options_page( $acf_opt_args );