下载资源后端资源详情
code-verification.zip
大小:3.44KB
价格:30积分
下载量:0
评分:
5.0
上传者:huayula
更新日期:2024-08-07

code-verification.zip

资源文件列表(大概)

文件名
大小
双击获取更多.url
110B
code-verification.php
4.52KB
script.js
1.3KB
style.css
1.33KB

资源内容介绍

WordPress原创插件:Code-verification 微信或QQ二维码验证引导关注
<?phpif (!defined('ABSPATH')) { exit; // 如果直接访问此文件,则退出。}// 注册并包含CSSfunction content_protect_enqueue_styles() { wp_register_style('content-protect-style', plugins_url('code-verification/style.css')); wp_enqueue_style('content-protect-style');}add_action('wp_enqueue_scripts', 'content_protect_enqueue_styles');// 注册并包含JSfunction content_protect_enqueue_scripts() { wp_register_script('content-protect-script', plugins_url('code-verification/script.js'), array('jquery'), null, true); wp_enqueue_script('content-protect-script');}add_action('wp_enqueue_scripts', 'content_protect_enqueue_scripts');function content_protect_menu() { add_options_page('Content Protect Settings', '二维码设置', 'manage_options', 'content-protect', 'content_protect_options_page');}add_action('admin_menu', 'content_protect_menu');function content_protect_options_page() { ?> <div class="wrap"> <h1>二维码设置</h1> <p style="text-align: left; font-size: 14px; color: #999;">注意事项:换行符号是&lt;br&gt;,如:请扫码关注微信二维码&lt;br&gt发送“验证码”获取密码。 <br>短代码引入文章示例:[protected] 这是隐藏的内容,只有验证密码后才能看到。 [/protected] </p> <form method="post" action="options.php"> <?php settings_fields('content_protect_settings'); ?> <?php do_settings_sections('content-protect'); ?> <table class="form-table"> <tr valign="top"> <th scope="row">设定密码</th> <td><input style="width:200px;" type="text" name="content_protect_password" value="<?php echo esc_attr(get_option('content_protect_password')); ?>" /></td> </tr> <tr valign="top"> <th scope="row">提示内容</th> <td><textarea cols="100" style="height: 100px;" name="content_protect_prompt"><?php echo esc_textarea(get_option('content_protect_prompt')); ?></textarea></td> </tr> <tr valign="top"> <th scope="row">二维码图片</th> <td><input style="width:500px;" type="text" name="content_protect_image" value="<?php echo esc_url(get_option('content_protect_image')); ?>" ></td> </tr> </table> <?php submit_button(); ?> </form> <p style="text-align: center; font-size: 14px; color: #999;">本插件由<a href="https://ds17.cn" target="_blank">大神博客ds17.cn</a>原创,务必保留所有权利,删除必究。</p> </div> <?php}function content_protect_register_settings() { register_setting('content_protect_settings', 'content_protect_password'); register_setting('content_protect_settings', 'content_protect_prompt'); register_setting('content_protect_settings', 'content_protect_image');}add_action('admin_init', 'content_protect_register_settings');function content_protect_shortcode($atts,$content = null) { $atts = shortcode_atts( array( 'password' => get_option('content_protect_password'), ), $atts ); if (isset($_POST['content_protect_password']) &&$_POST['content_protect_password'] == $atts['password']) { setcookie('content_protect_verified', true, time() + 3600, COOKIEPATH, COOKIE_DOMAIN); } if (isset($_COOKIE['content_protect_verified']) &&$_COOKIE['content_protect_verified']) { return do_shortcode($content); } else { $prompt = get_option('content_protect_prompt', '请输入密码查看内容。'); $image = get_option('content_protect_image'); $output = '<div class="content-protect">'; if ($image) { $output .= '<img src="' . esc_url($image) . '" alt="验证图片" />'; } $output .= '<p>' .$prompt . '</p>'; $output .= '<form method="post">'; $output .= '<input type="password" name="content_protect_password" />'; $output .= '<input type="submit" value="验证" />'; $output .= '</form>'; $output .= '</div>'; return $output; }}add_shortcode('protected', 'content_protect_shortcode');

用户评论 (0)

发表评论

captcha