-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
151 lines (132 loc) · 4.39 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
<?php
/**
* Functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*/
/**
* Enqueue theme support.
*/
if (!function_exists("lifestewardship_support")) {
function lifestewardship_support() {
// Alignwide and alignfull classes in the block editor.
add_theme_support("align-wide");
// Add support for experimental link color control.
add_theme_support("experimental-link-color");
// Add support for responsive embedded content.
// https://github.com/WordPress/gutenberg/issues/26901
add_theme_support("responsive-embeds");
// Add support for editor styles.
add_theme_support("editor-styles");
// Add support for post thumbnails.
add_theme_support("post-thumbnails");
// Declare that there are no <title> tags and allow WordPress to provide them
add_theme_support("title-tag");
// Experimental support for adding blocks inside nav menus
add_theme_support("block-nav-menus");
// Set default content for site editor.
add_filter("block_editor_settings_all", function ($settings) {
$settings["defaultBlockTemplate"] =
'<!-- wp:group {"layout":{"inherit":true}} --><div class="wp-block-group"><!-- wp:post-content /--></div><!-- /wp:group -->';
return $settings;
});
// Add support for core custom logo.
add_theme_support("custom-logo", [
"height" => 192,
"width" => 192,
"flex-width" => true,
"flex-height" => true,
]);
// Enqueue editor styles.
add_editor_style("style.css");
// Enable RSS feed links.
add_theme_support("automatic-feed-links");
}
}
add_action("after_setup_theme", "lifestewardship_support");
/**
* Enqueue the styles.
*/
function lifestewardship_styles() {
wp_enqueue_style(
"lifestewardship-style",
get_template_directory_uri() . "/style.css",
wp_get_theme()->get("Version"),
);
}
add_action("wp_enqueue_scripts", "lifestewardship_styles");
/**
* Disable the fallback for the core/navigation block.
*/
function lifestewardship_core_navigation_render_fallback() {
return null;
}
add_filter(
"block_core_navigation_render_fallback",
"lifestewardship_core_navigation_render_fallback",
);
/**
* Disable embeds script to improve performance.
*/
function disable_embeds() {
wp_dequeue_script("wp-embed");
}
add_action("wp_footer", "disable_embeds");
/**
* Disable the emojis to improve performance.
*/
function disable_emojis() {
remove_action("wp_head", "print_emoji_detection_script", 7);
remove_action("admin_print_scripts", "print_emoji_detection_script");
remove_action("wp_print_styles", "print_emoji_styles");
remove_action("admin_print_styles", "print_emoji_styles");
remove_filter("the_content_feed", "wp_staticize_emoji");
remove_filter("comment_text_rss", "wp_staticize_emoji");
remove_filter("wp_mail", "wp_staticize_emoji_for_email");
add_filter(
"wp_resource_hints",
"disable_emojis_remove_dns_prefetch",
10,
2,
);
}
add_action("init", "disable_emojis");
/**
* Remove emoji CDN hostname from DNS prefetching hints.
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed for.
* @return array Difference betwen the two arrays.
*/
function disable_emojis_remove_dns_prefetch($urls, $relation_type) {
if ("dns-prefetch" == $relation_type) {
/** This filter is documented in wp-includes/formatting.php */
$emoji_svg_url = apply_filters(
"emoji_svg_url",
"https://s.w.org/images/core/emoji/2/svg/",
);
$urls = array_diff($urls, [$emoji_svg_url]);
}
return $urls;
}
/**
* Add non-movable Post Featured Image block to further align block editor and
* website presentation.
*/
function inline_post_featured_image($post_type) {
$post_type_object = get_post_type_object($post_type);
$post_type_object->template = [
[
"core/post-featured-image",
[
"align" => "wide",
"lock" => ["move" => "true"],
],
],
["core/paragraph"],
];
}
add_action("init", function () {
inline_post_featured_image("page");
inline_post_featured_image("post");
});