这个功能云落貌似重写了一半,所以现在最新版本的 Git 主题这个功能是不能用的,这里把解决方法记录一下,不过这个功能还是有一点缺陷,看完源码应该明白我说的是什么,如果想更安全,把缓存功能删掉就行了
找到主题目录下的/Git-alpha/include/shortcode.php 文件,将这段代码
// 部分内容输入密码可见 function e_secret($atts, $content = null) { extract(shortcode_atts(array( 'wx' => null ) , $atts)); $notice = ''; $postid = get_the_ID(); $pass_content = get_post_meta($postid, 'pass_content', true); if (!empty($pass_content) && $pass_content != $content) { update_post_meta($postid, 'pass_content', $content, true); } else { add_post_meta($postid, 'pass_content', $content, true); } if ($_COOKIE["pass_ok"] = "10086" ){ $notice .= '<div class="alert alert-info">'.$content.'</div>'; }else{ if ($wx == '1') { $notice .= '<div class="wxbox"><img class="wxpic" src="' . git_get_option('git_mp_qr') . '" alt="' . git_get_option('git_mp_name') . '" title="' . git_get_option('git_mp_name') . '" align="right"><div><span class="yzts" style="font-size:18px;">验证码:</span><input name="e_secret_key" id="verifycode" value="" type="text"><input id="verifybtn" value="提交查看" type="submit" onclick="pass_view();"></div><div class="wxtips">' . git_get_option('git_mp_tips') . '</div><div class="cl"></div></div>'; } else { $notice .= '<div id="e-secret"><label>输入密码查看加密内容:</label><input type="text" id="verifycode" class="euc-y-i" maxlength="50"><input type="submit" class="euc-y-s" value="确定" onclick="pass_view();"><div class="clear"></div></div>'; } } $notice .= '<p id="pass_content"></p>'; echo '<script type="text/javascript"> function pass_view() { var e = document.getElementById("verifycode").value; ajax.post("'.admin_url('admin-ajax.php').'", "action=pass_view&id='.$postid.'&pass=" + e, function(t) { if(t != 0){ document.getElementById("e-secret").style.display = "none", document.getElementById("pass_content").innerHTML = "<div class=\"alert alert-info\">" + t + "</div>"; setCookie("pass_ok", "10086", 30); }else{ alert("密码错误"); } }) } </script>'; return $notice; } add_shortcode('secret', 'e_secret');
改成下面这段代码
// 部分内容输入密码可见 function e_secret($atts, $content = null) { extract(shortcode_atts(array( 'wx' => null ) , $atts)); $notice = ''; $postid = get_the_ID(); $pass_content = get_post_meta($postid, 'pass_content', true); if (!empty($pass_content) && $pass_content != $content) { update_post_meta($postid, 'pass_content', $content, true); } else { add_post_meta($postid, 'pass_content', $content, true); } if ($_COOKIE["pass_ok"] == "10086" ){ $notice .= '<div class="alert alert-info">'.$content.'</div>'; }else{ if ($wx == '1') { $notice .= '<div class="wxbox" id="wx-secret"><img class="wxpic" src="' . git_get_option('git_mp_qr') . '" alt="' . git_get_option('git_mp_name') . '" title="' . git_get_option('git_mp_name') . '" align="right"><div><span class="yzts" style="font-size:18px;">验证码:</span><input name="e_secret_key" id="verifycode" value="" type="text"><input id="verifybtn" value="提交查看" type="submit" onclick="pass_view();"></div><div class="wxtips">' . git_get_option('git_mp_tips') . '</div><div class="cl"></div></div>'; } else { $notice .= '<div id="e-secret"><label>输入密码查看加密内容:</label><input type="text" id="verifycode" class="euc-y-i" maxlength="50"><input type="submit" class="euc-y-s" value="确定" onclick="pass_view();"><div class="clear"></div></div>'; } } $notice .= '<p id="pass_content"></p>'; echo '<script type="text/javascript"> function pass_view() { var e = document.getElementById("verifycode").value; ajax.post("'.admin_url('admin-ajax.php').'", "action=pass_view&id='.$postid.'&pass=" + e, function(t) { if(t != 0){ setCookie("pass_ok", "10086", 30);'; if ($wx == '1') { echo 'document.getElementById("wx-secret").style.display = "none";'; }else{ echo 'document.getElementById("e-secret").style.display = "none";'; } echo 'document.getElementById("pass_content").innerHTML = "<div class=\"alert alert-info\">" + t + "</div>"; }else{ alert("密码错误"); } }) } </script>'; return $notice; } add_shortcode('secret', 'e_secret');
改完后保存即可