-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfunctions.helpers.php
More file actions
89 lines (81 loc) · 2.97 KB
/
Copy pathfunctions.helpers.php
File metadata and controls
89 lines (81 loc) · 2.97 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
<?php
declare(strict_types=1);
if (! defined('WPINC')) {
return;
}
/**
* ------------------------------------------------------------------------------
* Helper functions
* ------------------------------------------------------------------------------
*/
function inlineSvgAttachment(int $attachmentId): string
{
$type = get_post_mime_type($attachmentId);
if ($type !== 'image/svg+xml') {
return '';
}
return inlineSvg(get_attached_file($attachmentId));
}
function inlineSvg(string $file): string
{
return file_get_contents($file);
}
/**
* ------------------------------------------------------------------------------
* Optimizations
* ------------------------------------------------------------------------------
*/
remove_theme_support('core-block-patterns');
remove_action('admin_print_styles', 'print_emoji_styles'); // Emoji
remove_action('wp_head', 'print_emoji_detection_script', 7); // Emoji
remove_action('admin_print_scripts', 'print_emoji_detection_script'); // Emoji
remove_action('wp_print_styles', 'print_emoji_styles'); // Emoji
remove_filter('wp_mail', 'wp_staticize_emoji_for_email'); // Emoji
remove_filter('the_content_feed', 'wp_staticize_emoji'); // Emoji
remove_filter('comment_text_rss', 'wp_staticize_emoji'); // Emoji
remove_action('wp_head', 'wp_generator'); // Remove WordPress generator meta tag
remove_action('wp_head', 'rsd_link'); // Remove RSD link meta tag
remove_action('wp_head', 'wlwmanifest_link'); // Remove WLW manifest link meta tag
remove_action('wp_head', 'wp_shortlink_wp_head'); // Remove shortlink meta tag
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); // Remove adjacent posts link meta tags
remove_action('wp_head', 'rest_output_link_wp_head'); // Remove REST output link meta tag
add_filter('the_generator', '__return_null'); // Remove generator output
add_filter('login_headerurl', 'home_url'); // Replace the login logo link with home url
add_filter('wp_mail_from', function ($from) {
if (mb_strpos($from, 'wordpress@') !== false) {
return $from;
}
return get_option('admin_email');
}); // Replace mail from with current admin email
// Replace mail from name with site name
add_filter(
'wp_mail_from_name',
function () {
return get_bloginfo('name');
},
);
/**
* ------------------------------------------------------------------------------
* Use custom site logo as login logo
* ------------------------------------------------------------------------------
*/
add_action('login_enqueue_scripts', function (): void {
$custom_logo_id = get_theme_mod('custom_logo');
if (! $custom_logo_id) {
return;
}
$logo = wp_get_attachment_image_src($custom_logo_id, 'full');
if (! $logo) {
return;
}
?>
<style type="text/css">
.login h1 a {
background-image: url('<?php echo esc_url($logo[0]); ?>');
background-size: contain;
width: 100%;
height: 80px;
}
</style>
<?php
});