使用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;"));
/**
 * 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);



给TA打赏
共{{data.count}}人
人已打赏
cj

Linux VPS纯净版Debian/Ubuntu/CentOS/Windows系统一键安装脚本

2019-11-20 10:43:38

cj

一个免费、安全、稳定、高效的发卡系统:ZFAKA安装教程

2019-11-21 7:46:54

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索