最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Add back in child theme what the parent theme removed with remove_action

programmeradmin2浏览0评论

My parent theme removes the emoji fallback script that makes emoji show up as images:

// parent theme's functions.php
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');

I want to add it back in the child theme (to make this configuration survive theme updates) but if I just add_action it either doesn't work at all or works for the wp-emoji.js script but not for the CSS styles (print_emoji_styles) – emojis appear enormous, SVG spreads to all the available space.

If I disable the two lines in the parent theme everything works as expected.

What is going on, what should I look for to figure out the correct orchestration here?

My parent theme removes the emoji fallback script that makes emoji show up as images:

// parent theme's functions.php
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');

I want to add it back in the child theme (to make this configuration survive theme updates) but if I just add_action it either doesn't work at all or works for the wp-emoji.js script but not for the CSS styles (print_emoji_styles) – emojis appear enormous, SVG spreads to all the available space.

If I disable the two lines in the parent theme everything works as expected.

What is going on, what should I look for to figure out the correct orchestration here?

Share Improve this question edited Dec 18, 2019 at 19:48 Leeroy asked Dec 18, 2019 at 19:21 LeeroyLeeroy 1113 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Choosing a higher priority for both the script AND the styles seems to work:

add_action('wp_head', 'print_emoji_detection_script', 8);
add_action('wp_print_styles', 'print_emoji_styles', 8);
发布评论

评论列表(0)

  1. 暂无评论