| author | ymh <ymh.work@gmail.com> |
| Mon, 17 Jun 2019 17:00:14 +0200 | |
| changeset 24 | 86535a5969b8 |
| parent 22 | 55b01e4ebc64 |
| child 37 | d6e8b9ad5a74 |
| permissions | -rw-r--r-- |
| 0 | 1 |
<?php |
2 |
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); |
|
3 |
function my_theme_enqueue_styles() { |
|
4 |
||
5 |
$parent_style = 'twentynineteen-style'; |
|
6 |
||
7 |
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); |
|
8 |
wp_enqueue_style( 'twentynineteen-child-style', |
|
9 |
get_stylesheet_directory_uri() . '/style.css', |
|
10 |
array( $parent_style ), |
|
11 |
wp_get_theme()->get('Version') |
|
12 |
); |
|
| 22 | 13 |
} |
14 |
||
15 |
/** |
|
16 |
* Disable the emoji's |
|
|
24
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
17 |
* from https://wordpress.org/plugins/disable-emojis/ |
| 22 | 18 |
*/ |
19 |
function disable_emojis() { |
|
|
24
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
20 |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
21 |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
22 |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
23 |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
24 |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
25 |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
26 |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
27 |
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
28 |
add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 ); |
| 22 | 29 |
} |
30 |
add_action( 'init', 'disable_emojis' ); |
|
31 |
||
32 |
/** |
|
33 |
* Filter function used to remove the tinymce emoji plugin. |
|
34 |
* |
|
35 |
* @param array $plugins |
|
|
24
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
36 |
* @return array Difference betwen the two arrays |
| 22 | 37 |
*/ |
38 |
function disable_emojis_tinymce( $plugins ) { |
|
|
24
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
39 |
if ( is_array( $plugins ) ) { |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
40 |
return array_diff( $plugins, array( 'wpemoji' ) ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
41 |
} else { |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
42 |
return array(); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
43 |
} |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
44 |
} |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
45 |
|
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
46 |
|
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
47 |
/** |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
48 |
* Remove emoji CDN hostname from DNS prefetching hints. |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
49 |
* |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
50 |
* @param array $urls URLs to print for resource hints. |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
51 |
* @param string $relation_type The relation type the URLs are printed for. |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
52 |
* @return array Difference betwen the two arrays. |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
53 |
*/ |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
54 |
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
55 |
|
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
56 |
if ( 'dns-prefetch' == $relation_type ) { |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
57 |
|
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
58 |
// Strip out any URLs referencing the WordPress.org emoji location |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
59 |
$emoji_svg_url_bit = 'https://s.w.org/images/core/emoji/'; |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
60 |
foreach ( $urls as $key => $url ) { |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
61 |
if ( strpos( $url, $emoji_svg_url_bit ) !== false ) { |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
62 |
unset( $urls[$key] ); |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
63 |
} |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
64 |
} |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
65 |
|
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
66 |
} |
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
67 |
|
|
86535a5969b8
Style correction + remove emoji from CDN prefetch (cf. disable-emojis plugin)
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
68 |
return $urls; |
| 0 | 69 |
} |