i need some suggestions to simplifying or even optimizing the following WordPress Theme Functions.
The first one removes some Theme features and Default WordPress Header stuff i don’t nedd. The Second adds some Javascript and CSS Files, but only if the user are not an Admin.
<?php
add_action('after_setup_theme', 'remove_theme_features', 11 );
function remove_theme_features() {
$GLOBALS['custom_background'] = 'kill_theme_features';
$GLOBALS['custom_image_header'] = 'kill_theme_features';
remove_theme_support('post-formats');
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
}
class kill_theme_features {
function init() { return false; }
}
if ( !is_admin() ) {
add_action('init', 'hno_init_js');
function hno_init_js() {
wp_enqueue_script('carousel', get_bloginfo('stylesheet_directory') . '/js/carousel/jquery.jcarousel.min.js', array('jquery'), '1', true);
wp_enqueue_script('history', get_bloginfo('stylesheet_directory') . '/js/carousel/jquery.history.min.js', array('jquery'), '1', true);
wp_enqueue_script('galleria', get_bloginfo('stylesheet_directory') . '/js/carousel/jquery.galleria.min.js', array('jquery'), '1', true);
wp_enqueue_script('fancybox_js', get_bloginfo('stylesheet_directory') . '/js/fancybox/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1', true);
wp_enqueue_script('hno', get_bloginfo('stylesheet_directory') . '/js/hno.js', array('jquery'), '1', true);
}
wp_enqueue_style('carousel_css', get_bloginfo('stylesheet_directory') . '/js/carousel/tango/skin.css', array() , false , 'screen' );
wp_enqueue_style('fancybox_css', get_bloginfo('stylesheet_directory') . '/js/fancybox/jquery.fancybox-1.3.4.css', array() , false , 'screen' );
}
?>
Thank you very much!
Regards Steve
Head cleaner is the plugin i use to do all this for me!
I just drop in all my js and css into the head in the standard way, then play around with the functions of head cleaner until I have nice, streamlined code.
http://wordpress.org/extend/plugins/head-cleaner/
not affiliated in any way btw!