-
Notifications
You must be signed in to change notification settings - Fork 45
/
functions.php
349 lines (284 loc) · 10.1 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
<?php
// ******************* Sidebars ****************** //
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Blog',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
}
// ******************* Add Custom Menus ****************** //
add_theme_support( 'menus' );
// ******************* Add Custom Excerpt Lengths ****************** //
function wpe_excerptlength_index($length) {
return 160;
}
function wpe_excerptmore($more) {
return '...<a href="'. get_permalink().'">Read More ></a>';
}
function wpe_excerpt($length_callback='', $more_callback='') {
global $post;
if(function_exists($length_callback)){
add_filter('excerpt_length', $length_callback);
}
if(function_exists($more_callback)){
add_filter('excerpt_more', $more_callback);
}
$output = get_the_excerpt();
$output = apply_filters('wptexturize', $output);
$output = apply_filters('convert_chars', $output);
$output = '<p>'.$output.'</p>';
echo $output;
}
// ******************* Add Post Thumbnails ****************** //
add_theme_support( 'post-thumbnails' );
//set_post_thumbnail_size( 50, 50, true );
add_image_size( 'xlarge', 1200, 1200);
// ******************* Add Custom Post Types & Taxonomies ****************** //
register_post_type('custom', array(
'label' => __('Custom Post Type'),
'singular_label' => __('Custom Post Type'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'query_var' => false,
'has_archive' => false,
'supports' => array('title', 'editor', 'thumbnail')
));
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
register_taxonomy( 'taxo', 'custom', array( 'hierarchical' => true, 'label' => 'Custom Taxonomy', 'query_var' => true, 'rewrite' => true ) );
}
// ******************* ACF Options Page ****************** //
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
}
// ******************* Include Scripts Properly ****************** //
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js", false, null, true );
wp_enqueue_script('jquery');
}
function wpdocs_scripts_method() {
// CSS
wp_register_style( 'primary-stylesheet', get_template_directory_uri() . '/style.css');
wp_enqueue_style( 'primary-stylesheet' );
// JS
wp_register_script( 'custom-scripts', get_stylesheet_directory_uri() . '/js/script.js', array( 'jquery' ), '', true );
wp_enqueue_script('custom-scripts');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_scripts_method' );
// ******************* Add SVG Upload Support ****************** //
function wpcontent_svg_mime_type( $mimes = array() ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'wpcontent_svg_mime_type' );
add_filter( 'wp_get_attachment_image_src', 'fix_wp_get_attachment_image_svg', 10, 4 ); /* the hook */
function fix_wp_get_attachment_image_svg($image, $attachment_id, $size, $icon) {
if (is_array($image) && preg_match('/\.svg$/i', $image[0]) && $image[1] <= 1) {
if(is_array($size)) {
$image[1] = $size[0];
$image[2] = $size[1];
} elseif(($xml = simplexml_load_file($image[0])) !== false) {
$attr = $xml->attributes();
$viewbox = explode(' ', $attr->viewBox);
$image[1] = isset($attr->width) && preg_match('/\d+/', $attr->width, $value) ? (int) $value[0] : (count($viewbox) == 4 ? (int) $viewbox[2] : null);
$image[2] = isset($attr->height) && preg_match('/\d+/', $attr->height, $value) ? (int) $value[0] : (count($viewbox) == 4 ? (int) $viewbox[3] : null);
} else {
$image[1] = $image[2] = null;
}
}
return $image;
}
// ******************* Remove Admin Bar ****************** //
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
show_admin_bar(false);
}
// ******************* Custom Admin Styles ****************** //
// change logo
function my_login_logo() { ?>
<style type="text/css">
body {
background-color: #29375B !important;
}
.login #backtoblog a, .login #nav a {
color: #fff !important;
}
input[type="checkbox"]:focus, input[type="color"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="datetime"]:focus, input[type="email"]:focus, input[type="month"]:focus, input[type="number"]:focus, input[type="password"]:focus, input[type="radio"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="text"]:focus, input[type="time"]:focus, input[type="url"]:focus, input[type="week"]:focus, select:focus, textarea:focus {
border-color: #29375B !important;
box-shadow: none !important;
}
.login #login_error,
.login .message, .login .success {
border-left-color: #f77852 !important;
}
.login #backtoblog a:hover,
.login #nav a:hover,
.login h1 a:hover {
color: #f77852 !important;
}
#login h1 a, .login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/svgs/logo-ss.svg);
height:104px;
width: 142px;
background-size: 100% auto;
background-repeat: no-repeat;
margin-bottom: 30px;
}
.wp-core-ui .button-group.button-large .button,
.wp-core-ui .button.button-large {
background-color: #29375B !important;
border: none;
border-radius: 0;
box-shadow: none;
font-weight: 300;
letter-spacing: 2.4px;
padding: 0 24px;
text-shadow: none;
text-transform: uppercase;
transition: all .25s ease;
}
.wp-core-ui .button-group.button-large .button:hover,
.wp-core-ui .button.button-large:hover {
background: #f77852 !important;
}
#wpadminbar {
background-color: #29375B !important;
}
</style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );
// change logo url
function my_login_logo_url() {
return 'https://studiosimpati.co/';
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
function my_login_logo_url_title() {
return 'Studio Simpatico';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
// custom admin css
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
a,
.wp-core-ui .button-link:hover,
.update-message p::before {
color: #29375B !important;
}
#wpadminbar,
#adminmenu,
#adminmenu .wp-submenu,
#adminmenuback, #adminmenuwrap {
background-color: #29375B !important;
}
#wpadminbar .ab-empty-item,
#wpadminbar a.ab-item,
#wpadminbar > #wp-toolbar span.ab-label,
#wpadminbar > #wp-toolbar span.noticon,
#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a,
#wpadminbar .quicklinks .menupop ul li a:focus,
#wpadminbar .quicklinks .menupop ul li a:focus strong,
#wpadminbar .quicklinks .menupop ul li a:hover,
#wpadminbar .quicklinks .menupop ul li a:hover strong,
#wpadminbar .quicklinks .menupop.hover ul li a:focus,
#wpadminbar .quicklinks .menupop.hover ul li a:hover,
#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:focus,
#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:hover,
#wpadminbar li #adminbarsearch.adminbar-focused::before,
#wpadminbar li .ab-item:focus .ab-icon::before,
#wpadminbar li .ab-item:focus::before,
#wpadminbar li a:focus .ab-icon::before,
#wpadminbar li.hover .ab-icon::before,
#wpadminbar li.hover .ab-item::before,
#wpadminbar li:hover #adminbarsearch::before,
#wpadminbar li:hover .ab-icon::before,
#wpadminbar li:hover .ab-item::before,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover,
#adminmenu li:hover div.wp-menu-image::before,
#adminmenu a,
#adminmenu .wp-submenu a,
#adminmenu li a:focus div.wp-menu-image::before,
#adminmenu div.wp-menu-image::before,
#wpadminbar .ab-icon::before,
#wpadminbar .ab-item::before,
.acf-tooltip a,
.acf-tooltip a[data-event="confirm"]:hover {
color: #fff !important;
}
a:hover,
#adminmenu .wp-submenu a:hover,
.wp-core-ui .button-link,
.plugin-update .update-message p,
.acf-tooltip a[data-event="confirm"],
.acf-tooltip a:hover {
color: #f77852 !important;
}
#wpadminbar .ab-top-menu > li.hover > .ab-item,
#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus,
#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item,
#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus,
#wpadminbar .menupop .ab-sub-wrapper,
#wpadminbar .shortlink-input,
#adminmenu li.menu-top:hover,
#adminmenu li.opensub > a.menu-top,
#adminmenu li > a.menu-top:focus,
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu {
background-color: #f77852 !important;
color: #fff !important;
}
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu,
#adminmenu .awaiting-mod,
#adminmenu .update-plugins {
background: #666 !important;
}
.wp-core-ui .button-primary {
background-color: #29375B !important;
border: none;
border-radius: 0;
box-shadow: none;
color: #fff !important;
font-weight: 300;
letter-spacing: 2.4px;
padding: 0 24px;
text-shadow: none;
text-transform: uppercase;
transition: all .25s ease;
}
.wp-core-ui .button-primary:hover {
background: #f77852 !important;
}
.notice-warning.notice-alt {
border-left-color: #29375B !important;
}
.plugin-update-tr.active td,
.plugins .active th.check-column,
.notice-info {
border-left-color: #f77852 !important;
}
.plugins .active td,
.plugins .active th {
background: #fff;
}
.notice-warning.notice-alt {
background: #eee;
}
</style>';
}
?>