-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
136 lines (125 loc) · 5.49 KB
/
functions.php
File metadata and controls
136 lines (125 loc) · 5.49 KB
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
<?php
/**
* ScratchStart Theme bootstrap.
*
* Intentionally free of custom CSS and JavaScript so page builders such as
* Elementor stay in full control and the frontend stays lightning fast.
*/
defined('ABSPATH') || exit;
add_action('after_setup_theme', 'scratchstart_setup');
function scratchstart_setup(): void
{
load_theme_textdomain('scratchstart', get_template_directory() . '/languages');
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');
add_theme_support('responsive-embeds');
add_theme_support('html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
));
register_nav_menus(array(
'header-menu' => __('Header Menu', 'scratchstart'),
'footer-menu' => __('Footer Menu', 'scratchstart'),
));
}
/**
* Decide whether a theme-rendered part should be emitted at all.
*
* The theme is page-builder-first (Elementor, Bricks, Beaver, ...) and ships
* thinner than Hello: by default it renders nothing besides the document
* skeleton (DOCTYPE, <head>, body with wp_head / wp_body_open / wp_footer)
* and a single <main id="main"> wrapper that holds the_content(). Every
* piece of chrome and even the archive loop and comments are opt-in.
* There is no 404.php on purpose: WordPress falls back to index.php so a
* page builder's "Not Found" template can take over via template_include.
*
* Enable parts you actually need from your child theme or a mu-plugin:
*
* add_filter('scratchstart_render_skip_link', '__return_true');
* add_filter('scratchstart_render_header', '__return_true');
* add_filter('scratchstart_render_footer', '__return_true');
* add_filter('scratchstart_render_post_title', '__return_true');
* add_filter('scratchstart_render_post_meta', '__return_true');
* add_filter('scratchstart_render_comments', '__return_true');
* add_filter('scratchstart_render_sidebar', '__return_true');
* add_filter('scratchstart_render_archive_loop', '__return_true');
*/
function scratchstart_should_render(string $part): bool
{
return (bool) apply_filters("scratchstart_render_{$part}", false);
}
add_action('widgets_init', 'scratchstart_widgets_init');
function scratchstart_widgets_init(): void
{
register_sidebar(array(
'name' => __('Main Sidebar', 'scratchstart'),
'id' => 'main-sidebar',
'description' => __('Widgets in this area will be shown on all posts and pages.', 'scratchstart'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
/**
* Optional WordPress core cleanup, all opt-in.
*
* Defaults to no interference with WordPress core. Enable any subset to
* shrink the rendered <head>/<body> when a page builder owns the layout:
*
* add_filter('scratchstart_disable_emojis', '__return_true');
* add_filter('scratchstart_disable_embed_script', '__return_true');
* add_filter('scratchstart_disable_block_library_css', '__return_true');
* add_filter('scratchstart_clean_head', '__return_true');
*
* Or flip them all at once with the master switch:
*
* add_filter('scratchstart_lightning_mode', '__return_true');
*/
add_action('init', 'scratchstart_apply_core_cleanup');
function scratchstart_apply_core_cleanup(): void
{
$lightning = (bool) apply_filters('scratchstart_lightning_mode', false);
if ($lightning || apply_filters('scratchstart_disable_emojis', false)) {
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_scripts', 'print_emoji_detection_script');
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('emoji_svg_url', '__return_false');
add_filter('tiny_mce_plugins', static function (array $plugins): array {
return array_values(array_diff($plugins, array('wpemoji')));
});
}
if ($lightning || apply_filters('scratchstart_disable_embed_script', false)) {
add_action('wp_footer', static function (): void {
wp_dequeue_script('wp-embed');
});
}
if ($lightning || apply_filters('scratchstart_disable_block_library_css', false)) {
add_action('wp_enqueue_scripts', static function (): void {
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('global-styles');
wp_dequeue_style('classic-theme-styles');
}, 100);
}
if ($lightning || apply_filters('scratchstart_clean_head', false)) {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('template_redirect', 'wp_shortlink_header', 11);
remove_action('wp_head', 'rest_output_link_wp_head');
remove_action('template_redirect', 'rest_output_link_header', 11);
remove_action('wp_head', 'wp_oembed_add_discovery_links');
}
}