使用WordPress一些常用技巧

以下代码片断,增加至伏笔VPS的正题模板函数(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-repeat9;background-image:none9;}</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);

希望以上的文章对各位有用,如果觉得不错给我点个喜欢吧!更多和使用WordPress一些常用技巧相关的问题或者对东京虚拟主机购买有疑惑也欢迎大家咨询。

点赞