我试图清理一下我主题中的代码,删除一些未使用的代码,基本上以正确的方式做事,以减少加载时间等。
目前我有以下代码:
add_action(\'after_setup_theme\', \'rm_theme_setup\');
// start theme setup
function rm_theme_setup() {
add_action(\'init\', \'rm_head_cleanup\'); // * 1) calling the function below
add_action(\'wp_head\', \'rm_remove_recent_comments_style\', 1);
add_filter(\'gallery_style\', \'rm_remove_gallery_style\');
rm_add_theme_support(); // * 2) calling the function to add theme support
}
1) This is the wp_head cleanup part: 基本上,我在上面的theme\\u setup函数中调用这个函数。这是正确的做事方式吗?
function rm_head_cleanup() {
remove_action(\'wp_head\', \'feed_links_extra\', 3);
remove_action(\'wp_head\', \'feed_links\', 2);
remove_action(\'wp_head\', \'rsd_link\');
remove_action(\'wp_head\', \'wlwmanifest_link\');
remove_action(\'wp_head\', \'index_rel_link\');
remove_action(\'wp_head\', \'parent_post_rel_link\', 10, 0);
remove_action(\'wp_head\', \'start_post_rel_link\', 10, 0);
remove_action(\'wp_head\', \'adjacent_posts_rel_link_wp_head\', 10, 0);
remove_action(\'wp_head\', \'wp_generator\');
remove_action(\'wp_head\', \'wp_shortlink_wp_head\');
add_filter(\'style_loader_src\', \'rm_remove_wp_ver_css_js\');
add_filter(\'style_loader_tag\', \'rm_clean_style_tags\');
add_filter(\'script_loader_src\', \'rm_remove_wp_ver_css_js\');
}
2) 后来在代码中我有了这个函数,
to add theme support. 当您检查主题设置功能时,我只是这样做:rm\\u add\\u theme\\u support();。这是正确的方法吗,还是我应该复制此功能中的所有内容并将其粘贴到theme\\u设置?
function rm_add_theme_support() {
add_theme_support(\'post-thumbnails\');
// remove the default thumbnails
update_option(\'thumbnail_size_h\', 0);
update_option(\'thumbnail_size_w\', 0);
update_option(\'medium_size_h\', 0);
update_option(\'medium_size_w\', 0);
update_option(\'large_size_h\', 0);
update_option(\'large_size_w\', 0);
// set_post_thumbnail_size(200, 200, true);
add_image_size(\'rm-slide\', 960, 500);
add_image_size(\'rm-service-image\', 380, 9999);
add_image_size(\'rm-service-thumbnail\', 80, 60, true);
add_theme_support(\'menus\');
register_nav_menus(
array(
\'main-nav\' => \'Main menu\'
)
);
}
感谢所有的帮助,希望这不是太多的代码。