Completed
Push — master ( 56e281...c7bf14 )
by SILENT
02:20
created

extras.php ➔ disable_emojis_remove_dns_prefetch()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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 $strings $classes group-blog.
0 ignored issues
show
Documentation introduced by
The doc-type $strings could not be parsed: Unknown type name "$strings" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
15
 */
16
function strip_body_classes( $classes ) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
17
	// Adds a class of group-blog to blogs with more than 1 published author.
18
	if ( is_multi_author() ) {
19
		$classes[] = 'group-blog';
20
	}
21
22
	return $classes;
23
}
24
add_filter( 'body_class', 'strip_body_classes' );
25
26
/**
27
 * Disable the emoji's
28
 */
29
function disable_emojis() {
30
	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
31
	remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
32
	remove_action( 'wp_print_styles', 'print_emoji_styles' );
33
	remove_action( 'admin_print_styles', 'print_emoji_styles' );
34
	remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
35
	remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
36
	remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
37
	add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
38
	add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
39
} add_action( 'init', 'disable_emojis' );
40
41
/**
42
 * Filter function used to remove the tinymce emoji plugin introduced in WordPress 4.2.
43
 *
44
 * @param array $plugins disable_emojis_tinymce.
45
 * @return array Difference betwen the two arrays.
46
 */
47
function disable_emojis_tinymce( $plugins ) {
48
	if ( is_array( $plugins ) ) {
49
		return array_diff( $plugins, array( 'wpemoji' ) );
50
	} return array();
51
}
52
	/**
53
	 * Remove emoji CDN hostname from DNS prefetching hints.
54
	 */
55
56
add_filter( 'emoji_svg_url', '__return_false' );
57