WordPress 4.2 禁用 Emoji 表情 和修復儀表盤迴響頭像錯位

本文目錄1禁用 Emoji 表情2恢復之前的圖片表情3解決儀表盤頭像錯位

WordPress 4.2 一改之前的圖片表情,改為使用 Emoji 表情 ,而且是直接遠程調用api,可惜的是,這個api服務在國內是無法正常訪問的,這就導致瞭網站加載緩慢,之前的表情無法顯示等問題。好吧,下面就來禁用這個 Emoji 表情,恢復之前的圖片表情。

禁用 Emoji 表情

在主題的 functions.php 添加代碼的代碼即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* Disable the emoji's
 */
function disable_emojis() {
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    remove_action( 'wp_print_styles', 'print_emoji_styles' );
    remove_action( 'admin_print_styles', 'print_emoji_styles' );    
    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );  
    remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
    add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );
/**
 * Filter function used to remove the tinymce emoji plugin.
 * 
 * @param    array  $plugins  
 * @return   array             Difference betwen the two arrays
 */
function disable_emojis_tinymce( $plugins ) {
	return array_diff( $plugins, array( 'wpemoji' ) );
}

/**
* Disable the emoji’s
*/
function disable_emojis() {
remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
add_filter( ‘tiny_mce_plugins’, ‘disable_emojis_tinymce’ );
}
add_action( ‘init’, ‘disable_emojis’ );
/**
* Filter function used to remove the tinymce emoji plugin.
*
* @param array $plugins
* @return array Difference betwen the two arrays
*/
function disable_emojis_tinymce( $plugins ) {
return array_diff( $plugins, array( ‘wpemoji’ ) );
}

恢復之前的圖片表情

在主題的 functions.php 添加代碼的代碼即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
 * WordPress 4.2 修復圖片表情
 * https://www.wpdaxue.com/disable-emoji.html
 */
function smilies_reset() {
    global $wpsmiliestrans, $wp_smiliessearch;
 
    // don't bother setting up smilies if they are disabled
    if ( !get_option( 'use_smilies' ) )
        return;
 
    $wpsmiliestrans = array(
    ':mrgreen:' => 'icon_mrgreen.gif',
    ':neutral:' => 'icon_neutral.gif',
    ':twisted:' => 'icon_twisted.gif',
      ':arrow:' => 'icon_arrow.gif',
      ':shock:' => 'icon_eek.gif',
      ':smile:' => 'icon_smile.gif',
        ':???:' => 'icon_confused.gif',
       ':cool:' => 'icon_cool.gif',
       ':evil:' => 'icon_evil.gif',
       ':grin:' => 'icon_biggrin.gif',
       ':idea:' => 'icon_idea.gif',
       ':oops:' => 'icon_redface.gif',
       ':razz:' => 'icon_razz.gif',
       ':roll:' => 'icon_rolleyes.gif',
       ':wink:' => 'icon_wink.gif',
        ':cry:' => 'icon_cry.gif',
        ':eek:' => 'icon_surprised.gif',
        ':lol:' => 'icon_lol.gif',
        ':mad:' => 'icon_mad.gif',
        ':sad:' => 'icon_sad.gif',
          '8-)' => 'icon_cool.gif',
          '8-O' => 'icon_eek.gif',
          ':-(' => 'icon_sad.gif',
          ':-)' => 'icon_smile.gif',
          ':-?' => 'icon_confused.gif',
          ':-D' => 'icon_biggrin.gif',
          ':-P' => 'icon_razz.gif',
          ':-o' => 'icon_surprised.gif',
          ':-x' => 'icon_mad.gif',
          ':-|' => 'icon_neutral.gif',
          ';-)' => 'icon_wink.gif',
        // This one transformation breaks regular text with frequency.
        //  '8)' => 'icon_cool.gif',
           '8O' => 'icon_eek.gif',
           ':(' => 'icon_sad.gif',
           ':)' => 'icon_smile.gif',
           ':?' => 'icon_confused.gif',
           ':D' => 'icon_biggrin.gif',
           ':P' => 'icon_razz.gif',
           ':o' => 'icon_surprised.gif',
           ':x' => 'icon_mad.gif',
           ':|' => 'icon_neutral.gif',
           ';)' => 'icon_wink.gif',
          ':!:' => 'icon_exclaim.gif',
          ':?:' => 'icon_question.gif',
    );
}
smilies_reset();

<?php
/**
* WordPress 4.2 修復圖片表情
* https://www.wpdaxue.com/disable-emoji.html
*/
function smilies_reset() {
global $wpsmiliestrans, $wp_smiliessearch; // don’t bother setting up smilies if they are disabled
if ( !get_option( ‘use_smilies’ ) )
return;
$wpsmiliestrans = array(
‘:mrgreen:’ => ‘icon_mrgreen.gif’,
‘:neutral:’ => ‘icon_neutral.gif’,
‘:twisted:’ => ‘icon_twisted.gif’,
‘:arrow:’ => ‘icon_arrow.gif’,
‘:shock:’ => ‘icon_eek.gif’,
‘:smile:’ => ‘icon_smile.gif’,
‘:???:’ => ‘icon_confused.gif’,
‘:cool:’ => ‘icon_cool.gif’,
‘:evil:’ => ‘icon_evil.gif’,
‘:grin:’ => ‘icon_biggrin.gif’,
‘:idea:’ => ‘icon_idea.gif’,
‘:oops:’ => ‘icon_redface.gif’,
‘:razz:’ => ‘icon_razz.gif’,
‘:roll:’ => ‘icon_rolleyes.gif’,
‘:wink:’ => ‘icon_wink.gif’,
‘:cry:’ => ‘icon_cry.gif’,
‘:eek:’ => ‘icon_surprised.gif’,
‘:lol:’ => ‘icon_lol.gif’,
‘:mad:’ => ‘icon_mad.gif’,
‘:sad:’ => ‘icon_sad.gif’,
‘8-)’ => ‘icon_cool.gif’,
‘8-O’ => ‘icon_eek.gif’,
‘:-(‘ => ‘icon_sad.gif’,
‘:-)’ => ‘icon_smile.gif’,
‘:-?’ => ‘icon_confused.gif’,
‘:-D’ => ‘icon_biggrin.gif’,
‘:-P’ => ‘icon_razz.gif’,
‘:-o’ => ‘icon_surprised.gif’,
‘:-x’ => ‘icon_mad.gif’,
‘:-|’ => ‘icon_neutral.gif’,
‘;-)’ => ‘icon_wink.gif’,
// This one transformation breaks regular text with frequency.
// ‘8)’ => ‘icon_cool.gif’,
‘8O’ => ‘icon_eek.gif’,
‘:(‘ => ‘icon_sad.gif’,
‘:)’ => ‘icon_smile.gif’,
‘:?’ => ‘icon_confused.gif’,
‘:D’ => ‘icon_biggrin.gif’,
‘:P’ => ‘icon_razz.gif’,
‘:o’ => ‘icon_surprised.gif’,
‘:x’ => ‘icon_mad.gif’,
‘:|’ => ‘icon_neutral.gif’,
‘;)’ => ‘icon_wink.gif’,
‘:!:’ => ‘icon_exclaim.gif’,
‘:?:’ => ‘icon_question.gif’,
);
}
smilies_reset();

以上2處代碼來自:http://fatesinger.com/75634

解決儀表盤頭像錯位

WordPress 4.2 開始,儀表盤的“活動”小工具的頭像就出現撐破現象,如下圖:

2015-05-16_111011_wpdaxue_com

一直沒見官方修復,好吧,就提供暫時的修復方案吧。將下面的代碼添加到主題的 functions.php :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * WordPress 4.2 修復儀表盤頭像錯位
 * https://www.wpdaxue.com/disable-emoji.html
 */
function fixed_activity_widget_avatar_style(){
  echo '<style type="text/css">
            #activity-widget #the-comment-list .avatar {
            position: absolute;
            top: 13px;
            width: 50px;
            height: 50px;
          }
          </style>';
}
add_action('admin_head', 'fixed_activity_widget_avatar_style' );

/**
* WordPress 4.2 修復儀表盤頭像錯位
* https://www.wpdaxue.com/disable-emoji.html
*/
function fixed_activity_widget_avatar_style(){
echo ‘<style type="text/css">
#activity-widget #the-comment-list .avatar {
position: absolute;
top: 13px;
width: 50px;
height: 50px;
}
</style>’;
}
add_action(‘admin_head’, ‘fixed_activity_widget_avatar_style’ );

刷新你的儀表盤,看看是否OK啦!相信官方會在後續修復這個問題的,到時就不需要這個代碼瞭。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *