1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Custom functions that act independently of the theme templates |
4
|
|
|
* |
5
|
|
|
* Eventually, some of the functionality here could be replaced by core features. |
6
|
|
|
* |
7
|
|
|
* @package WordPress |
8
|
|
|
* @subpackage Strip |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Adds custom classes to the array of body classes. |
13
|
|
|
* |
14
|
|
|
* @param array $classes group-blog. |
15
|
|
|
* @return array |
16
|
|
|
*/ |
17
|
|
|
function strip_body_classes( $classes ) { |
18
|
|
|
// Adds a class of group-blog to blogs with more than 1 published author. |
19
|
|
|
if ( is_multi_author() ) { |
20
|
|
|
$classes[] = 'group-blog'; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
return $classes; |
24
|
|
|
} |
25
|
|
|
add_filter( 'body_class', 'strip_body_classes' ); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Disable emojis introduced in WordPress 4.2. |
29
|
|
|
*/ |
30
|
|
|
function disable_emojis() { |
31
|
|
|
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); |
32
|
|
|
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); |
33
|
|
|
remove_action( 'wp_print_styles', 'print_emoji_styles' ); |
34
|
|
|
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
35
|
|
|
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); |
36
|
|
|
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); |
37
|
|
|
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); |
38
|
|
|
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); |
39
|
|
|
add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 ); |
40
|
|
|
} add_action( 'init', 'disable_emojis' ); |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Filter function used to remove the tinymce emoji plugin. |
44
|
|
|
* |
45
|
|
|
* @param array $plugins disable_emojis_tinymce. |
46
|
|
|
* @return array Difference betwen the two arrays. |
47
|
|
|
*/ |
48
|
|
|
function disable_emojis_tinymce( $plugins ) { |
49
|
|
|
if ( is_array( $plugins ) ) { |
50
|
|
|
return array_diff( $plugins, array( 'wpemoji' ) ); |
51
|
|
|
} return array(); |
52
|
|
|
} |
53
|
|
|
/** |
54
|
|
|
* Remove emoji CDN hostname from DNS prefetching hints. |
55
|
|
|
* |
56
|
|
|
* @param array $urls URLs to print for resource hints. |
57
|
|
|
* @param string $relation_type The relation type the URLs are printed for. |
58
|
|
|
* @return array Difference betwen the two arrays. |
59
|
|
|
*/ |
60
|
|
|
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { |
61
|
|
|
if ( 'dns-prefetch' !== $relation_type ) { /** This filter is documented in wp-includes/formatting.php */ |
62
|
|
|
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' ); |
63
|
|
|
$urls = array_diff( $urls, array( $emoji_svg_url ) ); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
return $urls; } |
66
|
|
|
|