-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
242 lines (219 loc) · 6.59 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
<?php
/** 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.
*/
if(!function_exists('wpdev_setup')){
function wpdev_setup() {
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* This theme does not use a hard-coded <title> tag in the document head,
* WordPress will 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' );
set_post_thumbnail_size( 1568, 9999 );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
'navigation-widgets',
)
);
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
$logo_width = 300;
$logo_height = 100;
add_theme_support(
'custom-logo',
array(
'height' => $logo_height,
'width' => $logo_width,
'flex-width' => true,
'flex-height' => true,
'unlink-homepage-logo' => true,
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
// Add support for Block Styles.
add_theme_support( 'wp-block-styles' );
// Add support for full and wide align images.
add_theme_support( 'align-wide' );
// Add support for editor styles.
add_theme_support( 'editor-styles' );
$editor_stylesheet_path = './assets/css/style-editor.css';
// Enqueue editor styles.
add_editor_style( $editor_stylesheet_path );
// Add custom editor font sizes.
add_theme_support(
'editor-font-sizes',
array(
array(
'name' => esc_html__( 'Small', 'wpdev' ),
'shortName' => esc_html_x( 'S', 'Font size', 'wpdev' ),
'size' => 12,
'slug' => 'small',
),
array(
'name' => esc_html__( 'Normal', 'wpdev' ),
'shortName' => esc_html_x( 'M', 'Font size', 'wpdev' ),
'size' => 16,
'slug' => 'normal',
),
array(
'name' => esc_html__( 'Large', 'wpdev' ),
'shortName' => esc_html_x( 'L', 'Font size', 'wpdev' ),
'size' => 24,
'slug' => 'large',
),
array(
'name' => esc_html__( 'Extra large', 'wpdev' ),
'shortName' => esc_html_x( 'XL', 'Font size', 'wpdev' ),
'size' => 36,
'slug' => 'extra-large',
),
array(
'name' => esc_html__( 'Huge', 'wpdev' ),
'shortName' => esc_html_x( 'XXL', 'Font size', 'wpdev' ),
'size' => 64,
'slug' => 'huge',
),
array(
'name' => esc_html__( 'Gigantic', 'wpdev' ),
'shortName' => esc_html_x( 'XXXL', 'Font size', 'wpdev' ),
'size' => 80,
'slug' => 'gigantic',
),
)
);
// Custom background color.
add_theme_support(
'custom-background',
array(
'default-color' => 'd1e4dd',
)
);
// Editor color palette.
$black = 'hsl(0, 0%, 0%)';
$dark_gray = 'hsl(217, 21%, 20%)';
$gray = 'hsl(216, 15%, 26%)';
$green = "hsl(158, 26%, 86%)";
$blue = "hsl(196, 26%, 86%)";
$purple = "hsl(240, 26%, 86%)";
$red = "hsl(0, 26%, 86%)";
$orange = "hsl(28, 26%, 86%)";
$yellow = "hsl(46, 33%, 90%)";
$white = "hsl(0, 0%, 100%)";
add_theme_support(
'editor-color-palette',
array(
array(
'name' => esc_html__( 'Black', 'wpdev' ),
'slug' => 'black',
'color' => $black,
),
array(
'name' => esc_html__( 'Dark gray', 'wpdev' ),
'slug' => 'dark-gray',
'color' => $dark_gray,
),
array(
'name' => esc_html__( 'Gray', 'wpdev' ),
'slug' => 'gray',
'color' => $gray,
),
array(
'name' => esc_html__( 'Green', 'wpdev' ),
'slug' => 'green',
'color' => $green,
),
array(
'name' => esc_html__( 'Blue', 'wpdev' ),
'slug' => 'blue',
'color' => $blue,
),
array(
'name' => esc_html__( 'Purple', 'wpdev' ),
'slug' => 'purple',
'color' => $purple,
),
array(
'name' => esc_html__( 'Red', 'wpdev' ),
'slug' => 'red',
'color' => $red,
),
array(
'name' => esc_html__( 'Orange', 'wpdev' ),
'slug' => 'orange',
'color' => $orange,
),
array(
'name' => esc_html__( 'Yellow', 'wpdev' ),
'slug' => 'yellow',
'color' => $yellow,
),
array(
'name' => esc_html__( 'White', 'wpdev' ),
'slug' => 'white',
'color' => $white,
),
)
);
// Add support for responsive embedded content.
add_theme_support( 'responsive-embeds' );
// Add support for custom line height controls.
add_theme_support( 'custom-line-height' );
// Add support for experimental link color control.
add_theme_support( 'experimental-link-color' );
// Add support for experimental cover block spacing.
add_theme_support( 'custom-spacing' );
// Add support for custom units.
// This was removed in WordPress 5.6 but is still required to properly support WP 5.5.
add_theme_support( 'custom-units' );
}
}
add_action('after_setup_theme','wpdev_setup');
// Set the content width in pixels, based on the theme's design and stylesheet.
function wpdev_content_width() {
$GLOBALS['content_width'] = apply_filters( 'wpdev_content_width', 750 );
}
add_action( 'after_setup_theme', 'wpdev_content_width', 0 );
// Enqueue scripts and styles.
function wpdev_scripts(){
wp_enqueue_style('wpdev-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get('Version'));
// Threaded comment reply styles.
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'wpdev_scripts');
// Calculate classes for the main <html> element.
function wpdev_the_html_classes() {
$classes = apply_filters( 'wpdev_html_classes', '' );
if ( ! $classes ) {
return;
}
echo 'class="' . esc_attr( $classes ) . '"';
}