-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·193 lines (163 loc) · 3.97 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
<?php
/**
* Main functions and definitions
*
* @package Luuptek WP-Base
*/
/**
* Require helpers
*/
require dirname( __FILE__ ) . '/library/functions/helpers.php';
require dirname( __FILE__ ) . '/library/functions/polylang-fallbacks.php';
/**
* Set theme name which will be referenced from style & script registrations
*
* @return WP_Theme
*/
function luuptek_wp_base_theme() {
return wp_get_theme();
}
/**
* Set custom imagesizes
*
* @return array
*/
function luuptek_wp_base_set_imagesizes() {
return [
[
'name' => 'article_lift',
'width' => 500,
'height' => 277,
'crop' => true,
],
[
'name' => 'hero_slide',
'width' => 1920,
'height' => 700,
'crop' => true,
],
[
'name' => 'square',
'width' => 500,
'height' => 500,
'crop' => true,
],
];
}
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 640;
}
/**
* Set up theme defaults and register support for various WordPress features.
*/
if ( ! function_exists( 'luuptek_wp_base_setup' ) ) :
/**
* WP base setup here
*/
function luuptek_wp_base_setup() {
global $cap, $content_width;
/**
* Load textdomain
*/
load_theme_textdomain( 'luuptek_wp_base', get_template_directory() . '/library/lang' );
/**
* Add editor styling
*/
add_editor_style( asset_uri( 'styles/main.css' ) );
/**
* Require ACF stuff
*/
require_files( dirname( __FILE__ ) . '/library/acf-blocks' );
require_files( dirname( __FILE__ ) . '/library/acf-options' );
/**
* Require some classes
*/
require_files( dirname( __FILE__ ) . '/library/classes' );
/**
* Require custom post types and taxonomies
*/
require_files( dirname( __FILE__ ) . '/library/custom-posts' );
require_files( dirname( __FILE__ ) . '/library/taxonomies' );
/**
* Require metaboxes
*/
require_files( dirname( __FILE__ ) . '/library/metaboxes' );
/**
* Widgets (nav-menus & widgetized areas)
*/
require_files( dirname( __FILE__ ) . '/library/widgets' );
/**
* Hooks
*/
require_files( dirname( __FILE__ ) . '/library/hooks' );
/**
* Theme supports
*/
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'html5', [ 'caption', 'comment-form', 'comment-list', 'gallery', 'search-form', 'script', 'style' ] );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'title-tag' );
add_theme_support( 'align-wide' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'block-template-parts' );
add_theme_support( 'appearance-tools' ); // Will be in WP 6.2
}
/**
* Register custom imagesizes
*/
if ( ! empty( luuptek_wp_base_set_imagesizes() ) ) {
foreach ( luuptek_wp_base_set_imagesizes() as $size ) {
add_image_size( $size['name'], $size['width'], $size['height'], $size['crop'] );
}
}
}
endif; // luuptek_wp_base_setup
add_action( 'after_setup_theme', 'luuptek_wp_base_setup' );
/**
* Add text to theme footer
*/
add_filter(
'admin_footer_text',
function () {
return '<span id="footer-thankyou">' . luuptek_wp_base_theme()->Name . ' by: <a href="' . luuptek_wp_base_theme()->AuthorURI . '" target="_blank">' . luuptek_wp_base_theme()->Author . '</a><span>';
}
);
/**
* Allow svg-uploads
*/
add_filter(
'upload_mimes',
function ( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
);
/**
* Register local ACF-json
*/
add_filter(
'acf/settings/save_json',
function () {
return get_stylesheet_directory() . '/library/acf-data';
}
);
add_filter(
'acf/settings/load_json',
function () {
$paths[] = get_stylesheet_directory() . '/library/acf-data';
return $paths;
}
);
/**
* Update google maps api key for ACF
*/
function update_acf_google_maps_api_key() {
if ( function_exists( 'acf_update_setting' ) ) {
acf_update_setting( 'google_api_key', 'your-api-here' );
}
}
add_action( 'acf/init', 'update_acf_google_maps_api_key' );