wordpress插件JS禁用

时间:2019-01-22 13:03:33

标签: javascript wordpress plugins drift

我正试图让这个wordpress插件(DRIFT网络聊天)在工作时间消失,因此它显示在上午09:00(格林尼治标准时间)和下午17:00(格林尼治标准时间),但我似乎无法使其正常工作!

<script> var enableDisable = function(){var GMT_hours = new Date().getGMTHours() ;
    if (GMT_hours > 08 && GMT_hours < 16){
        document.getElementById('checktime').disabled = false;
    }
    else
    {
        document.getElementById('checktime').disabled = true;} }; setInterval(enableDisable, 1000*60); enableDisable(); var t = window.driftt = window.drift = window.driftt || [];if (!t.init) {
    if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
    t.invoked = !0, t.methods = [ "identify", "config", "track", "reset" "debug", "show", "ping", "page", "hide", "off", "on" ], 
    t.factory = function(e) {
      return function() {
        var n = Array.prototype.slice.call(arguments);
        return n.unshift(e), t.push(n), t;
      };
    }, t.methods.forEach(function(e) {
      t[e] = t.factory(e);
    }), t.load = function(t) {
      var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
      o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
      var i = document.getElementsByTagName("script")[0];
      i.parentNode.insertBefore(o, i);};} }(); drift.SNIPPET_VERSION = '0.3.1'; drift.load('n72gzwytbesr');
</script>

请帮助! 以下是一些有帮助的屏幕截图...

ScreenShot 1

ScreenShot 2

ScreenShot 3

这是直接从DRIFT给定的代码...

<!-- Start of Async Drift Code --> 
<script> "use strict"; !function() { var t = window.driftt = window.drift = window.driftt || []; if (!t.init) {
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ], 
t.factory = function(e) {
  return function() {
    var n = Array.prototype.slice.call(arguments);
    return n.unshift(e), t.push(n), t;
  };
}, t.methods.forEach(function(e) {
  t[e] = t.factory(e);
}), t.load = function(t) {
  var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
  o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
  var i = document.getElementsByTagName("script")[0];
  i.parentNode.insertBefore(o, i); }; } }();drift.SNIPPET_VERSION = '0.3.1'; drift.load('n72gzwytbesr');
</script>
<!-- End of Async Drift Code -->

1 个答案:

答案 0 :(得分:0)

虽然可以仅使用javascript来做到这一点,但使用PHP会更容易。

在插件文件include / embed.php中,对此进行更改:

        echo "<!-- Start Drift By WP-Plugin: Drift -->\n";
    echo $drift_tag;
    echo"<!-- end: Drift Code. -->\n";

对此:

      if(date("Hi") < 1700 && date("Hi") > 900){
    echo "<!-- Start Drift By WP-Plugin: Drift -->\n";
    echo $drift_tag;
    echo"<!-- end: Drift Code. -->\n";}

这将完全停止从Drift嵌入任何其他JS,而不是仅仅不加载嵌入内容而是仍然加载JS。