Rat's

使用WordPress一些常用技巧
以下代码片段,添加至自己的主题模板函数(functions.php)添加登陆界面背景,每天从bing更新/** ...
扫描右侧二维码阅读全文
02
2017/04

使用WordPress一些常用技巧

以下代码片段,添加至自己的主题模板函数(functions.php)

添加登陆界面背景,每天从bing更新

/**
 * Login head.
 */
function custom_login_head(){
$str=file_get_contents('https://global.bing.com/HPImageArchive.aspx?idx=0&n=1');
if(preg_match("/<url>(.+?)<\/url>/ies",$str,$matches)){
$imgurl='https://global.bing.com'.$matches[1];
    echo'<style type="text/css">body{background: url('.$imgurl.');width:100%;height:100%;background-image:url('.$imgurl.');-moz-background-size: 100% 100%;-o-background-size: 100% 100%;-webkit-background-size: 100% 100%;background-size: 100% 100%;-moz-border-image: url('.$imgurl.') 0;background-repeat:no-repeat\9;background-image:none\9;}</style>';
}}
add_action('login_head', 'custom_login_head');

保护wp-admin目录

/**
 * Protected WP-Login.
 */
function login_protection(){
 if($_GET['key'] != 'Login')header('Location: https://xx.com/');
}
add_action('login_enqueue_scripts', 'login_protection');

移除WordPress版本号

/**
 * Remove Version.
 */
remove_action( 'wp_head', 'wp_generator' ) ;
remove_action( 'wp_head', 'wlwmanifest_link' ) ;
remove_action( 'wp_head', 'rsd_link' ) ;

禁止WordPress更新

/**
 * Close update.
 */
remove_action('admin_init', '_maybe_update_core');
remove_action('admin_init', '_maybe_update_plugins');
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;"));

移除后台WordPress的LOGO

/**
 * Remove their logo 
 */
function annointed_admin_bar_remove() {
 global $wp_admin_bar;
 $wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。
最后修改:2017 年 04 月 02 日 07 : 22 PM

发表评论 取消回复

2 条评论

  1. 皮卡

    听着你右上角的音乐,特别入迷,直接把后台网易云关了,然后就这样当做背景音乐,一直用了一下午了

    1. Rat's
      @皮卡

      歌曲很久没更新了。