2011-07-10 60 views
1

我需要一些建议来简化或甚至优化以下WordPress主题功能。简化或优化WordPress主题功能

第一个删除了一些主题功能和默认的WordPress的标题我没有定义的东西。第二个添加了一些Javascript和CSS文件,但只有当用户不是管理员。

<?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'); 
} 
?> 

非常感谢!

Regards Steve

+1

你可以在一个循环中删除'wp_head'动作,但没有其他的东西可以简化,因为你所有的都是函数调用。有没有你想要解决的具体问题? –

+0

不,没有具体问题。代码运行良好。我只想尽可能保持我的代码清洁,如果有办法改进它,我想知道。而已 :) – gearsdigital

回答