Wordpress入门到优化

必要插件

  • Autoptimize 优化你的网站, 整合并压缩 CSS 和 JavaScript 代码。
  • 云对象存储服务 一些文件资源可以扔上去
  • 注意:插件不宜过多,则情安装,以上两步足可以让网站速度有大的提升,若还不满意可以再加个CDN试一把。

一些必要设置

functions.php文件中进行修改

  • 设置隐藏顶部导航
1
add_filter('show_admin_bar', '__return_false');
  • 设置写文章自动推送百度搜索引擎
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if(!function_exists('Baidu_Submit')){
function Baidu_Submit($post_ID) {
$WEB_TOKEN = 'xxxxx'; //这里请换成你的网站的百度主动推送的token值
$WEB_DOMAIN = get_option('home');
//已成功推送的文章不再推送
if(get_post_meta($post_ID,'Baidusubmit',true) == 1) return;
$url = get_permalink($post_ID);
$api = 'http://data.zz.baidu.com/urls?site='.$WEB_DOMAIN.'&token='.$WEB_TOKEN;
$request = new WP_Http;
$result = $request->request( $api , array( 'method' => 'POST', 'body' => $url , 'headers' => 'Content-Type: text/plain') );
$result = json_decode($result['body'],true);
//如果推送成功则在文章新增自定义栏目Baidusubmit,值为1
if (array_key_exists('success',$result)) {
add_post_meta($post_ID, 'Baidusubmit', 1, true);
}
}
add_action('publish_post', 'Baidu_Submit', 0);
}

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 版权信息
1
2
3
4
5
6
7
8
9

function my_admin_footer_text(){
return '';
}
function my_update_footer(){
return '';
}
add_filter( 'admin_footer_text', 'my_admin_footer_text', 10 );
add_filter( 'update_footer', 'my_update_footer', 50 );
  • 隐藏dashboard面板的一些模块
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

function remove_dashboard_widgets() {
global $wp_meta_boxes;

//unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); //快速发布
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); //WordPress China 博客
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); //其它WordPress新闻
//unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); //近期草稿

unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);//链入链接
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); //概况
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); //插件
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);//近期评论
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );


function remove_screen_options(){ return false;}
add_filter('screen_options_show_screen', 'remove_screen_options');


add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
$screen->remove_help_tabs();
return $old_help;
}
  • 投稿者图片上传支持
1