wordpress修改代码

文章目录
  1. 1. 附加代码
  2. 2. 额外css
  3. 3. footer信息
  4. 4. functions.php修改
  5. 5. header.php百度统计
  6. 6. 插件列表
  7. 7. go.php(放在主题根目录)
  8. 8. js版二维码生成
  9. 9. php二维码生成
  • 参考资料
  • 附加代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    <!--footer.php 附加代码-->
    <div>
    <!--引用fone-awesome-->
    <link href="//cdn.domain.com/wp-content/uploads/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!--返回顶部-->
    <div class="scroll-to-top" style="display: block;">↑顶部</div>
    <script>
    jQuery(document).ready(function($){
    if ($(window).scrollTop() != "0")
    $(".scroll-to-top").fadeIn(1200) //如果距离顶部的距离不为0,显示.scroll-to-top
    var scrollDiv = $(".scroll-to-top");
    $(window).scroll(function()
    {
    if ($(window).scrollTop() == "0")
    $(scrollDiv).fadeOut(350)//如果距离顶部的距离为0,隐藏scrollDiv
    else
    $(scrollDiv).fadeIn(1200)//其他情况下,显示scrollDiv
    });
    $(".scroll-to-top").click(function(){
    $("html, body").animate({
    scrollTop: 0 //点击按钮,滚动回到顶部
    }, 600)
    })

    });
    </script>
    <!--onselectstart:禁止选中 oncontextmenu:右键弹出版权 event.keyCode==27:按esc键表示放弃Esc键阻止网页继续载入,也就是说你按ESC键网页还是继续加载-->
    <body onselectstart="return false;" oncontextmenu="alert('请尊重本网站版权!');return false;" onkeydown="if(event.keyCode==27) return false;">
    <script type="text/javascript">
    document.onmousedown = click; //绑定禁用鼠标右键事件
    document.onkeydown = ctrl_key; //绑定禁用键盘事件
    function click() {
    if (event.button == 2) //单击的鼠标键为右键
    {
    alert('请尊重本网站版权!');
    return false;
    }
    }
    function ctrl_key() {
    if (event.keyCode == 17) { //禁用CTRL+S 保存网页代码
    window.alert("请尊重本网站版权!");
    return false;
    }

    if (event.keyCode == 123) { //禁用F12查看源代码
    alert('请尊重本网站版权!');
    return false;
    }
    }
    </script></body>
    </div>

    额外css

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /* 回顶部 */
    .scroll-to-top {
    display: none;
    width: 70px;
    height: 32px;
    line-height: 32px;
    color: #fff;
    text-align: center;
    background-color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    bottom: 2%;
    position: fixed;
    right: 15px;
    z-index: 999;
    }
    .scroll-to-top:hover {
    opacity: .8;
    }

    footer信息

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <a href="https://twitter.com/GarveyWang"><i class="fa  fa-twitter "></i></a>  
    <a href="/message" title="发邮件给我"><i class="fa fa-envelope-o "></i></a>

    <p class="copyright">© 2018 - 2019 <a href="https://www.domain.com" class="site-name">一桌二椅</a>
    </br>
    <a href="#"><font size="2">我的生活感悟分享</font></a>
    <font size="2"> | </font>
    <a href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" target="_blank"><font size="2">又拍云</font> </a>
    </br>
    <a href="http://www.beian.miit.gov.cn/" target="_blank" class="text okmemo-tmp-unselect"><font size="2">冀ICP备19004041号</font></a>
    </p>

    functions.php修改

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    remove_action('pre_post_update', 'wp_save_post_revision');
    add_action('wp_print_scripts', 'disable_autosave');
    function disable_autosave() {
    wp_deregister_script('autosave');
    }




    add_filter('automatic_updater_disabled', '__return_true'); // 彻底关闭自动更新

    remove_action('init', 'wp_schedule_update_checks'); // 关闭更新检查定时作业

    wp_clear_scheduled_hook('wp_version_check'); // 移除已有的版本检查定时作业

    wp_clear_scheduled_hook('wp_update_plugins'); // 移除已有的插件更新定时作业

    wp_clear_scheduled_hook('wp_update_themes'); // 移除已有的主题更新定时作业

    wp_clear_scheduled_hook('wp_maybe_auto_update'); // 移除已有的自动更新定时作业

    remove_action( 'admin_init', '_maybe_update_core' ); // 移除后台内核更新检查

    remove_action( 'load-plugins.php', 'wp_update_plugins' ); // 移除后台插件更新检查

    remove_action( 'load-update.php', 'wp_update_plugins' );

    remove_action( 'load-update-core.php', 'wp_update_plugins' );

    remove_action( 'admin_init', '_maybe_update_plugins' );

    remove_action( 'load-themes.php', 'wp_update_themes' ); // 移除后台主题更新检查

    remove_action( 'load-update.php', 'wp_update_themes' );

    remove_action( 'load-update-core.php', 'wp_update_themes' );

    remove_action( 'admin_init', '_maybe_update_themes' );

    //修改后台显示更新的代码

    add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); // 关闭核心提示

    add_filter('pre_site_transient_update_plugins', create_function('$a', "return null;")); // 关闭插件提示

    add_filter('pre_site_transient_update_themes', create_function('$a', "return null;")); // 关闭主题提示

    remove_action('admin_init', '_maybe_update_plugins'); // 禁止 WordPress 更新插件

    remove_action('admin_init', '_maybe_update_core'); // 禁止 WordPress 检查更新

    remove_action('admin_init', '_maybe_update_themes'); // 禁止 WordPress 更新主题

    //移除修订版本记录功能
    remove_action ( 'pre_post_update', 'wp_save_post_revision' );



    /* 开始*/


    function ludou_comment_mail_notify($comment_id, $comment_status) {
    // 评论必须经过审核才会发送通知邮件
    if ($comment_status !== 'approve' && $comment_status !== 1)
    return;

    $comment = get_comment($comment_id);

    if ($comment->comment_parent != '0') {
    $parent_comment = get_comment($comment->comment_parent);

    // 邮件接收者email
    $to = trim($parent_comment->comment_author_email);

    // 邮件标题
    $subject = '您在[' . get_option("blogname") . ']的留言有了新的回复';

    // 邮件内容,自行修改,支持HTML
    $message = '<div style="border-right:#000000 1px solid;border-radius:8px;color:#111;font-size:12px;width:702px;border-bottom:#000000 1px solid;font-family:微软雅黑,arial;margin:10px auto 0px;border-top:#000000 1px solid;border-left:#000000 1px solid"><div class="adM">
    </div><div style="width:100%;background:#000000;min-height:60px;color:white;border-radius:6px 6px 0 0"><span style="line-height:60px;min-height:60px;margin-left:30px;font-size:12px">您在<a style="color:#00bbff;font-weight:600;text-decoration:none" href="' . get_option('home') . '" target="_blank">' . get_option('blogname') . '</a> 上的留言有回复啦!</span> </div>
    <div style="margin:0px auto;width:90%">
    <p>' . trim($parent_comment->comment_author) . ', 您好!</p>
    <p>您于' . trim($parent_comment->comment_date) . ' 在文章《' . get_the_title($comment->comment_post_ID) . '》上发表的评论: </p>
    <p style="border-bottom:#ddd 1px solid;border-left:#ddd 1px solid;padding-bottom:20px;background-color:#eee;margin:15px 0px;padding-left:20px;padding-right:20px;border-top:#ddd 1px solid;border-right:#ddd 1px solid;padding-top:20px">' . nl2br($parent_comment->comment_content) . '</p>
    <p>' . trim($comment->comment_author) . ' 于' . trim($comment->comment_date) . ' 给您的回复如下: </p>
    <p style="border-bottom:#ddd 1px solid;border-left:#ddd 1px solid;padding-bottom:20px;background-color:#eee;margin:15px 0px;padding-left:20px;padding-right:20px;border-top:#ddd 1px solid;border-right:#ddd 1px solid;padding-top:20px">' . nl2br($comment->comment_content) . '</p>
    <p>您可以点击 <a style="color:#00bbff;text-decoration:none" href="' . htmlspecialchars(get_comment_link($comment->comment_parent)). '" target="_blank">查看回复的完整內容</a></p>
    <p>感谢您对 <a style="color:#00bbff;text-decoration:none" href="' . get_option('home') . '" target="_blank">' . get_option('blogname') . '</a> 的关注。</p><p>(此邮件由系统自动发出,请勿回复。)</p></div></div>';

    $message_headers = "Content-Type: text/html; charset=\"".get_option('blog_charset')."\"\n";

    // 不用给不填email的评论者和管理员发提醒邮件
    if($to != '' && $to != get_bloginfo('admin_email'))
    @wp_mail($to, $subject, $message, $message_headers);
    }
    }


    // 编辑和管理员的回复直接发送提醒邮件,因为编辑和管理员的评论不需要审核
    add_action('comment_post', 'ludou_comment_mail_notify', 20, 2);

    // 普通访客发表的评论,等博主审核后再发送提醒邮件
    add_action('wp_set_comment_status', 'ludou_comment_mail_notify', 20, 2);

    /* 自动加勾选栏 */
    function add_checkbox() {
    echo '<input type="checkbox" name="comment_mail_notify" id="comment_mail_notify" value="comment_mail_notify" checked="checked" style="margin-left:20px;" /><label for="comment_mail_notify">有人回复时邮件通知我</label>';
    }
    add_action('comment_form', 'add_checkbox');


    /*-----------------------------------------------------------------------------------*/

    /* WordPress保护后台登录地址!
    /*-----------------------------------------------------------------------------------*/
    add_action('login_enqueue_scripts','login_protection');
    function login_protection(){
    if($_GET['admin'] != 'garvey')header('Location: /');
    }

    /*-----------------------------------------------------------------------------------*/
    /* WordPress文章内外链添加go跳转
    /*-----------------------------------------------------------------------------------*/
    function loper_content_nofollow($content){
    preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$content,$matches);
    if($matches){
    foreach($matches[2] as $val){
    if(strpos($val,'://')!==false && strpos($val,home_url())===false && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val)){
    $content=str_replace("href=\"$val\"", "href=\"".get_stylesheet_directory_uri()."/go.php?url=$val\" ",$content);
    }
    }
    }
    return $content;
    }
    add_filter('the_content','loper_content_nofollow',999);
    /*-----------------------------------------------------------------------------------*/
    /* WordPress评论者链接添加go跳转
    /*-----------------------------------------------------------------------------------*/
    function loper_redirect_comment_link($text = ''){
    $text = str_replace('href="', 'href="' . get_stylesheet_directory_uri() . '/go.php?url=', $text);
    $text = str_replace("href='", "href='" . get_stylesheet_directory_uri() . "/go.php?url=", $text);
    return $text;
    }
    add_filter('get_comment_author_link', 'loper_redirect_comment_link', 5);
    add_filter('comment_text', 'loper_redirect_comment_link', 99);




    /*-----------------------------------------------------------------------------------*/
    /* wordpress给评论作者的链接新窗口打开
    /*-----------------------------------------------------------------------------------*/
    function yundanran_get_comment_author_link($url){
    $return=$url;
    $p1="/^<a .*/i";
    $p2="/^<a ([^>]*)>(.*)/i";
    if(preg_match($p1,$return))
    {$return=preg_replace($p2,"<a $1 target='_blank'>$2",$return);}
    return $return;}
    add_filter('get_comment_author_link','yundanran_get_comment_author_link');

    /*-----------------------------------------------------------------------------------*/
    /* WordPress自动生成版权时间
    /*-----------------------------------------------------------------------------------*/
    function comicpress_copyright() {
    global $wpdb;
    $copyright_dates = $wpdb->get_results("
    SELECT
    YEAR(min(post_date_gmt)) AS firstdate,
    YEAR(max(post_date_gmt)) AS lastdate
    FROM
    $wpdb->posts
    WHERE
    post_status = 'publish'");
    $output = '';
    if ($copyright_dates) {
    $copyright = "&copy; " . $copyright_dates[0]->firstdate;
    if ($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
    $copyright.= '-' . $copyright_dates[0]->lastdate;
    }
    $output = $copyright;
    }
    return $output;
    }

    //自定义登录页面的LOGO图片
    function my_custom_login_logo() {
    echo '<style type="text/css">
    .login h1 a {
    background-image:url("https://cdn.domain.com/wp-content/uploads/2019/08/cropped-TB1Yhe0SFXXXXa4apXXXXXXXXXX-901-634-192x192.png") !important;
    height: 85px; //修改为图片的高度
    width: 60px; //修改为图标的宽度
    -webkit-background-size: 250px; //修改为图标的宽度
    background-size: 250px; //修改为图标的宽度
    }
    </style>';
    }
    add_action('login_head', 'my_custom_login_logo');

    //自定义登录页面的LOGO提示为网站名称
    add_filter('login_headertitle', create_function(false,"return get_bloginfo('name');"));

    //自定义登录页面的LOGO链接为首页链接
    add_filter('login_headerurl', create_function(false,"return get_bloginfo('url');"));

    //自定义底部信息
    function custom_html() {
    echo '<p style="text-align:center">©'.get_bloginfo('name').'</p>';
    }
    add_action('login_footer', 'custom_html');

    // 友情链接
    add_filter( 'pre_option_link_manager_enabled', '__return_true' );

    header.php百度统计

    1
    2
    3
    4
    5
    6
    7
    8
    9
    		<script>
    var _hmt = _hmt || [];
    (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?65e9e5c9977346e71532f2f29df03163";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
    })();
    </script>

    插件列表

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Acunetix Secure WordPress	
    Akismet Anti-Spam
    Contact Form 7
    Flamingo
    Media from FTP
    Useso take over Google
    WordPress 导入工具
    WP Cleaner
    WP SMTP
    WP Super Cache
    经典编辑器

    go.php(放在主题根目录)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    <?php  
    /**
    * 带有来路验证和跳转提示功能的跳转页面
    * @auth 孟坤博客
    * @authUrl http://mkblog.cn
    * @data 2017/3/13
    * @url https://mkblog.cn/701
    */

    // 请将这里的网址改为自己的(顶级)域名地址
    $myDomain = 'imwjw.com';

    // 这里用正则提取 $_SERVER["QUERY_STRING"] 而不是直接 get url
    // 是因为如果链接中自身带有 GET 参数则会导致获取不完整
    preg_match('/url=(.*)/i', $_SERVER["QUERY_STRING"], $jumpUrl);

    // 如果没获取到跳转链接,直接跳回首页
    if(!isset($jumpUrl[1])) {
    header("location:/");
    exit();
    }

    $jumpUrl = $jumpUrl[1];

    // 判断是否包含 http:// 头,如果没有则加上
    preg_match('/(http|https):\/\//', $jumpUrl, $matches);

    $url = $matches? $jumpUrl: 'http://'. $jumpUrl;


    // 判断网址是否完整
    preg_match('/[\w-]*\.[\w-]*/i', $url, $matche);

    // 是否需要给出跳转提示
    $echoTips = false;

    if($matche){
    // 如果是本站的链接,不展示动画直接跳转
    if(isMyDomain($url, $myDomain)) {
    header("location:{$url}");
    exit(); // 后续操作不再执行
    }

    $title = '页面加载中,请稍候...';
    $fromUrl = isset($_SERVER["HTTP_REFERER"])? $_SERVER["HTTP_REFERER"]: ''; // 获取来源url

    // 如果来源和跳转后的地址都不是本站,那么就要给出提示
    if(!isMyDomain($fromUrl, $myDomain)) {
    $echoTips = true;
    }
    } else { // 网址参数不完整
    $url = '/';
    $title = '参数错误,正在返回首页...';
    }


    /**
    * 判断是不是自己的域名
    * @param $domain 要进行判断的域名
    * @param $my 自己的域名
    * @return 对比结果
    */
    function isMyDomain($domain, $my) {
    preg_match('/([^\?]*)/i', $domain, $match);
    if(isset($match[1])) $domain = $match[1];
    preg_match('/([\w-]*\.[\w-]*)\/.*/i', $domain.'/', $match);
    if(isset($match[1]) && $match[1] == $my) return true;
    return false;
    }

    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <?php
    if($echoTips) {
    echo '<title>跳转提示</title>';
    } else {
    echo '<meta http-equiv="refresh" content="0;url='.$url.'">';
    echo '<title>'.$title.'</title>';
    }
    ?>
    <style>
    body{background:#fff;font-family:Microsoft Yahei;-webkit-animation:fadeIn 1s linear;animation:fadeIn 1s linear;padding-top:3em}
    @-webkit-keyframes fadeIn{from{opacity:0}
    to{opacity:1}
    }@keyframes fadeIn{from{opacity:0}
    to{opacity:1}
    }#circle{background-color:rgba(0,0,0,0);border:5px solid rgba(0,183,229,0.9);opacity:.9;border-right:5px solid rgba(0,0,0,0);border-left:5px solid rgba(0,0,0,0);border-radius:50px;box-shadow:0 0 35px #2187e7;width:50px;height:50px;margin:0 auto;position:fixed;left:30px;bottom:30px;-moz-animation:spinPulse 1s infinite ease-in-out;-webkit-animation:spinPulse 1s infinite ease-in-out;-o-animation:spinPulse 1s infinite ease-in-out;-ms-animation:spinPulse 1s infinite ease-in-out}
    #circle1{background-color:rgba(0,0,0,0);border:5px solid rgba(0,183,229,0.9);opacity:.9;border-left:5px solid rgba(0,0,0,0);border-right:5px solid rgba(0,0,0,0);border-radius:50px;box-shadow:0 0 15px #2187e7;width:30px;height:30px;margin:0 auto;position:fixed;left:40px;bottom:40px;-moz-animation:spinoffPulse 1s infinite linear;-webkit-animation:spinoffPulse 1s infinite linear;-o-animation:spinoffPulse 1s infinite linear;-ms-animation:spinoffPulse 1s infinite linear}
    @-webkit-keyframes spinPulse{0%{-webkit-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050}
    50%{-webkit-transform:rotate(145deg);opacity:1}
    100%{-webkit-transform:rotate(-320deg);opacity:0}
    }@-webkit-keyframes spinoffPulse{0%{-webkit-transform:rotate(0deg)}
    100%{-webkit-transform:rotate(360deg)}
    }#loading-text{position:fixed;left:110px;bottom:35px;color:#736D6D}
    @media screen and (max-width:600px){#circle,#circle1{left:0;right:0;top:0;bottom:0}
    #circle{margin:120px auto}
    #circle1{margin:130px auto}
    #loading-text{display:block;text-align:center;margin-top:220px;position:static;margin-left:10px}
    }
    .warning{max-width: 500px;margin: 20px auto;}
    .wtitle {font-size: 22px;color: #00bcd4;}
    .wurl {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;color: #827777;}
    .btn {display: inline-block;line-height: 20px;cursor: pointer;border: 1px solid #A9A6A6;padding: 6px 10px;font-size: 14px;text-decoration: none;border-radius:20px;}
    .btn-blue {color: #fff;background-color: #00bcd4;border: 1px solid #00bcd4;}
    .btn:hover {background-color: #A9A6A6;border: 1px solid #A9A6A6;color: #fff;}
    </style>
    </head>
    <body>
    <?php if($echoTips) { ?>
    <div class="warning">
    <p class="wtitle">您将要访问:</p>
    <p class="wurl" title="<?php echo $url;?>"><?php echo $url;?></p>
    <p>该网站不属于本站,我们无法确认该网页是否安全,它可能包含未知的安全隐患。</p>
    <a class="btn btn-blue" href="<?php echo $url;?>" rel="nofollow">继续访问</a>
    <span class="btn" onclick="closePage()">关闭网页</span>
    </div>
    <script>
    function closePage() {
    // 通用窗口关闭
    window.opener=null;
    window.open('','_self');
    window.close();
    // 微信浏览器关闭
    WeixinJSBridge.call('closeWindow');
    }
    </script>
    <?php } else { ?>
    <div id="circle"></div>
    <div id="circle1"></div>
    <p id="loading-text">页面加载中,请稍候...</p>
    <?php } ?>
    </body>
    </html>

    js版二维码生成

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    //放在主题single.php文件内
    <div>
    <center>
    <script src="//libs.cdnjs.net/jquery/1.8.2/jquery.min.js"></script>
    <script src="//libs.cdnjs.net/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
    <div id="output"></div>
    <script type="text/javascript">
    function utf16to8(str) {
    var out, i, len, c;
    out = "";
    len = str.length;
    for (i = 0; i < len; i++) {
    c = str.charCodeAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
    out += str.charAt(i);
    } else if (c > 0x07FF) {
    out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
    out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
    out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
    } else {
    out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
    out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
    }
    }
    return out;
    }
    content = utf16to8('<?php the_permalink(); ?>');
    $('#output').qrcode({
    width: 100,
    height: 100,
    render: "canvas",
    correctLevel: 0,
    text: content
    });
    </script>
    <p><font size="2">扫描二维码,手机查看</font></p>
    </center>
    </div>

    php二维码生成

    1
    2
    3
    4
    5
    6
    <div >
    <center>
    <img src="https://domain.com/wp-content/uploads/qr/?m=0&e=L&p=3&url=<?php the_permalink(); ?>" alt="<?php the_title(); ?>" />
    <p><font size="2">扫描二维码,手机查看</font></p>
    </center>
    </div>

    参考资料