^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助,如果有代码出错,请联系站长解决
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 腾讯云3年2核2G新品轻量限时特惠只需408元

xiu主题给评论添加签到按钮

之前就说过分享 xiu 主题的评论签到功能,前段时间折腾就忘了这事了。

1、修改 comments.php,添加下面代码到相应位置

2 核 2G 限时特惠 396 元/3 年    宝塔建站 10850 大礼包

<span data-event="comment-qiandao" class="muted comt-qiandao"><a href="javascript:SIMPALED.Editor.daka()"><i class="glyphicon glyphicon-pencil"></i> 签到</a></span>

陌小雨是添加在下面代码上面的

<?php include(TEMPLATEPATH . '/smiley.php'); ?>

如果你找不到该串代码,请参考这篇文章:https://dedewp.com/1222.html

2、添加 js 代码

jQuery(document).ready(function($) {

  function addEditor(a, b, c) {
    if (document.selection) {
      a.focus();
      sel = document.selection.createRange();
      c  sel.text = b + sel.text + c: sel.text = b;
      a.focus()
    } else if (a.selectionStart || a.selectionStart == '0') {
      var d = a.selectionStart;
      var e = a.selectionEnd;
      var f = e;
      c  a.value = a.value.substring(0, d) + b + a.value.substring(d, e) + c + a.value.substring(e, a.value.length) : a.value = a.value.substring(0, d) + b + a.value.substring(e, a.value.length);
      c  f += b.length + c.length: f += b.length - e + d;
      if (d == e && c) f -= c.length;
      a.focus();
      a.selectionStart = f;
      a.selectionEnd = f
    } else {
      a.value += b + c;
      a.focus()
    }
  }

  var myDate = new Date();
var mytime=myDate.toLocaleTimeString()

  var g = document.getElementById('comment') || 0;
  var h = {
    strong: function() {
      addEditor(g, '<strong>', '</strong>')
    },
    daka: function() {
      addEditor(g, '签到成功!签到时间:' + mytime, ',陌小雨,你很棒!一起加油哦哦~')
    },

  };
  window['SIMPALED'] = {};
  window['SIMPALED']['Editor'] = h

  $body = (window.opera)  (document.compatMode == "CSS1Compat"  $('html') : $('body')) : $('html,body');
  ;

  var wait = 15,
  submit_val = $submit.val();

  function isie6() {
    if ($.browser.msie) {
      if ($.browser.version == "6.0") return true;
    }
    return false;
  }

3、自动提交

 submit.click();

将这个动作添加到第二步中下面代码后面

 addEditor(g, '签到成功!签到时间:' + mytime, ',陌小雨,你很棒!一起加油哦哦~')

 

 

 

赠人玫瑰,手有余香。