Proper after_setup_theme and wp_head cleanup
Im trying to clean up code in my theme a little bit, remove some of the code that is not used and basically do things the right way, to decrease load time etc.
Currently I have this code:
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: Basically Im calling this function in the theme_setup function above. Is this the correct way to do things?
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) Then later in the code I have this function, to add theme support. When you check the theme setup function, im just doing this: rm_add_theme_support();. Is this the correct way to do it, or should I just copy everything from this fuction and paste it to theme_setup?
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'
)
);
}
Thanks for all the help, hopefully this is not too much code.