WordPress 修复仪表盘评论头像错位 禁用 Emoji 表情

WordPress 4.2 一改之前的图片表情,改为使用 Emoji 表情 ,而且是直接远程调用api,可惜的是,这个api服务在国内是无法正常访问的,这就导致了网站加载缓慢,之前的表情无法显示等问题。好吧,下面就来禁用这个 Emoji 表情,恢复之前的图片表情。

禁用 Emoji 表情

在主题的 functions.php 添加代码的代码即可:

/**
Disable the emoji's
WordPress 修复仪表盘评论头像错位 禁用 Emoji 表情
*/ 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 添加代码的代码即可:

/**
 * WordPress 4.2 修复图片表情
 * https://www.waizhuti.com/650.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();

解决仪表盘头像错位

WordPress 4.2 开始,仪表盘的“活动”小工具的头像就出现撑破现象,如下图:

歪迪wordpress建站网- WordPress 修复仪表盘评论头像错位 禁用 Emoji 表情

将下面的代码添加到主题的 functions.php :

/**
 * WordPress 4.2 修复仪表盘头像错位
 * https://www.waizhuti.com/650.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' );

好了 教程结束!

赞(0)
分享到: 更多 (0)
广告位招租了啦!!!快来联系
此处应有广告

评论 抢沙发

评论前必须登录!

 



很高兴本文可以为您带来灵感和帮助!

支付宝扫一扫打赏

微信扫一扫打赏

QQ扫一扫打赏