This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
143 lines (115 loc) · 4.34 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
<?php
/**
* Implement Child Theme Scripts and overwrite Google Fonts
*/
function gdpr_child_enqueue_scripts() {
wp_enqueue_style('gdpr-style', get_template_directory_uri() . '/style.css', array(), null); // original style.css
wp_enqueue_style( 'gdpr-child-style', get_stylesheet_directory_uri() . '/style.css', 'gdpr-style', null ); // child style.css
wp_enqueue_style('gdpr-fonts', get_stylesheet_directory_uri() . '/css/fonts.css'); // Localize Google Fonts
}
add_action( 'wp_enqueue_scripts' , 'gdpr_child_enqueue_scripts' );
/**
* Custom Body Class for Child Theme
*/
function gdpr_child_body_class( $classes ) {
$classes[] = 'child';
return $classes;
}
add_action( 'body_class', 'gdpr_child_body_class' );
// INFO: Comments (external links & comments IP)
/**
* Makes every comment and comment author link truely external (except 'respond')
*/
function gdpr_child_external_comment_links( $content ){
return str_replace( "<a ", "<a target='_blank' ", $content );
}
add_filter( "comment_text", "gdpr_child_external_comment_links" );
add_filter( "get_comment_author_link", "gdpr_child_external_comment_links" );
/**
* Removes IP addresses from comments (old entries have to be deleted by hand)
*/
function gdpr_child_remove_comments_ip( $comment_author_ip ) {
return '';
}
add_filter( 'pre_comment_user_ip', 'gdpr_child_remove_comments_ip' );
// INFO: Disable oEmbeds
/**
* Disable oEmbeds
*/
function gdpr_child_disable_embeds() {
remove_action( 'rest_api_init', 'wp_oembed_register_route' ); // JSON API
add_filter( 'embed_oembed_discover', '__return_false' ); // Auto Discover
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); // Results
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // Discovery Links
remove_action( 'wp_head', 'wp_oembed_add_host_js' ); // Frontend JS
add_filter( 'tiny_mce_plugins', 'gdpr_child_disable_embeds_tinymce_plugin' ); // TinyMCE
add_filter( 'rewrite_rules_array', 'gdpr_child_disable_embeds_rewrites' ); // Rerite Rules
remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 ); // oEmbeds Preloader
}
add_action( 'init', 'gdpr_child_disable_embeds', 9999 );
/**
* Remove oEmbed TinyMCE Plugin
*/
function gdpr_child_disable_embeds_tinymce_plugin( $plugins ) {
return array_diff( $plugins, array('wpembed') );
}
/**
* Disable oEmbeds rewrite rules
*/
function gdpr_child_disable_embeds_rewrites( $rules ) {
foreach( $rules as $rule => $rewrite ) {
if (false !== strpos($rewrite, 'embed=true')) {
unset($rules[$rule]);
}
}
return $rules;
}
// INFO: Disable Emojis
/**
* Disable the emoji's
*/
function gdpr_child_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( 'tiny_mce_plugins', 'gdpr_child_disable_emojis_tinymce' );
add_filter( 'wp_resource_hints', 'gdpr_child_disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'gdpr_child_disable_emojis' );
/**
* Remove the tinymce emoji plugin.
*/
function gdpr_child_disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
/**
* Remove DNS prefetching (Emojis).
*/
function gdpr_child_disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
if ( 'dns-prefetch' == $relation_type ) {
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
$urls = array_diff( $urls, array( $emoji_svg_url ) );
}
return $urls;
}
// INFO: Remove global DNS Prefetching
/**
* Remove DNS Prefetching (a.w.org)
*/
function gdpr_child_remove_dns_prefetch() {
remove_action('wp_head', 'wp_resource_hints', 2);
}
add_action( 'init', 'gdpr_child_remove_dns_prefetch');
// INFO: Hide WordPress REST API
// Remove REST API info from head and headers
remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'template_redirect', 'rest_output_link_header', 11 );