修复积分插件 myCRED 日志时区相差8小时的问题

在测试 myCRED 这个积分插件的过程中,发现 myCRED 在积分日志中的时间和本地实际时间相差8小时(国内服务器可能大多会遇到该问题),如果你也遇到这个问题,可以将下面的代码添加到当前主题的 functions.php 文件中,一般即可解决:

/*
修复积分插件 myCRED 日志时区相差8小时的问题
<blockquote class="wp-embedded-content" data-secret="0ehpMTEzmU"><a href="https://www.wpdaxue.com/fix-for-mycred-backend-log-entry-time-error.html">修复积分插件 myCRED 日志时区相差8小时的问题</a></blockquote>/*! This file is auto-generated */!function(c,d){"use strict";var e=!1,o=!1;if(d.querySelector)if(c.addEventListener)e=!0;if(c.wp=c.wp||{},!c.wp.receiveEmbedMessage)if(c.wp.receiveEmbedMessage=function(e){var t=e.data;if(t)if(t.secret||t.message||t.value)if(!/[^a-zA-Z0-9]/.test(t.secret)){for(var r,a,i,s=d.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),n=d.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),o=0;o&lt;n.length;o++)n[o].style.display=&quot;none&quot;;for(o=0;o&lt;s.length;o++)if(r=s[o],e.source===r.contentWindow){if(r.removeAttribute(&quot;style&quot;),&quot;height&quot;===t.message){if(1e3&lt;(i=parseInt(t.value,10)))i=1e3;else if(~~i&lt;200)i=200;r.height=i}if(&quot;link&quot;===t.message)if(a=d.createElement(&quot;a&quot;),i=d.createElement(&quot;a&quot;),a.href=r.getAttribute(&quot;src&quot;),i.href=t.value,i.host===a.host)if(d.activeElement===r)c.top.location.href=t.value}}},e)c.addEventListener(&quot;message&quot;,c.wp.receiveEmbedMessage,!1),d.addEventListener(&quot;DOMContentLoaded&quot;,t,!1),c.addEventListener(&quot;load&quot;,t,!1);function t(){if(!o){o=!0;for(var e,t,r,a=-1!==navigator.appVersion.indexOf(&quot;MSIE 10&quot;),i=!!navigator.userAgent.match(/Trident.*rv:11./),s=d.querySelectorAll(&quot;iframe.wp-embedded-content&quot;),n=0;n&lt;s.length;n++){if(!(r=(t=s[n]).getAttribute(&quot;data-secret&quot;)))r=Math.random().toString(36).substr(2,10),t.src+=&quot;#?secret=&quot;+r,t.setAttribute(&quot;data-secret&quot;,r);if(a||i)(e=t.cloneNode(!0)).removeAttribute(&quot;security&quot;),t.parentNode.replaceChild(e,t);t.contentWindow.postMessage({message:&quot;ready&quot;,secret:r},&quot;*&quot;)}}}}(window,document);
 */
if(!function_exists('cwp_set_current_timezone')){
    function cwp_set_current_timezone($timezone){
        if( false===stripos( $timezone,':' ) ){
            $timezone_name = $timezone;
        }else{
            $timezone = strtolower($timezone);
            $timezone = str_replace(array('utc','UTC'), '', $timezone) ;      
            $timezone = preg_replace('/[^0-9]/', '', $timezone) * 36;
            $timezone_name = timezone_name_from_abbr(null, $timezone, true);
            if( false===$timezone_name ){
                $timezone_name = timezone_name_from_abbr(null, -10* 3600, false);
            }
        }
        if(function_exists('date_default_timezone_set')){
            date_default_timezone_set($timezone_name);
            return $timezone_name;
        }
        return false;
    }
}
 
if(function_exists('date_default_timezone_set')){
    $timezone = '+0:00';
    cwp_set_current_timezone( $timezone );
}

来源:

https://www.wpdaxue.com/fix-for-mycred-backend-log-entry-time-error.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33090.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?