PluginProbe
Disable Emojis (GDPR friendly) / trunk
Disable Emojis (GDPR friendly) vtrunk
1.9.3 1.9.1 1.9.2 1.9 1.8 trunk 1.0 1.1 1.2 1.4 1.5 1.5.1 1.5.2 1.5.3 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8
disable-emojis / src / EmojiModule.php

EmojiModule.php in Disable Emojis (GDPR friendly) trunk, at src/EmojiModule.php

54 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace RyanHellyer\DisableEmojis;
6
7 class EmojiModule
8 {
9 public function __construct()
10 {
11 add_action('init', [$this, 'disableEmojis']);
12 }
13
14 public function disableEmojis(): void
15 {
16 remove_action('wp_head', 'print_emoji_detection_script', 7);
17 remove_action('admin_print_scripts', 'print_emoji_detection_script');
18 remove_action('wp_print_styles', 'print_emoji_styles');
19 remove_action('admin_print_styles', 'print_emoji_styles');
20 remove_filter('the_content_feed', 'wp_staticize_emoji');
21 remove_filter('comment_text_rss', 'wp_staticize_emoji');
22 remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
23 add_filter('tiny_mce_plugins', [$this, 'disableEmojisTinymce']);
24 add_filter('wp_resource_hints', [$this, 'disableEmojisRemoveDnsPrefetch'], 10, 2);
25 }
26
27 /**
28 * @param string[] $plugins
29 * @return string[]
30 */
31 public function disableEmojisTinymce(array $plugins): array
32 {
33 return array_diff($plugins, ['wpemoji']);
34 }
35
36 /**
37 * @param string[] $urls
38 * @return string[]
39 */
40 public function disableEmojisRemoveDnsPrefetch(array $urls, string $relation_type): array
41 {
42 if ($relation_type === 'dns-prefetch') {
43 $emoji_svg_url_bit = 'https://s.w.org/images/core/emoji/';
44 foreach ($urls as $key => $url) {
45 if (strpos($url, $emoji_svg_url_bit) !== false) {
46 unset($urls[$key]);
47 }
48 }
49 }
50
51 return $urls;
52 }
53 }
54