removing wordpress generated code from the head section?

Specifically, I’m talking about the following which gets added automatically:

1) <script type='text/javascript' src='http://mysite.com/wp-includes/js/l10n.js?ver=20101110'></script>

Read More

2) <script type="text/javascript">
//<![CDATA[
var _wpcf7 = { cached: 1 };
//]]>
</script>

3) <link rel="stylesheet" href="http://disqus.com/stylesheets/theme/disqus.css?v=2.0" type="text/css" media="screen" />

4)

<style type='text/css'> 
#wpadminbar .quicklinks li#wp-admin-bar-stats {height:28px}
#wpadminbar .quicklinks li#wp-admin-bar-stats a {height:28px;padding:0}
#wpadminbar .quicklinks li#wp-admin-bar-stats a img {padding:4px 11px}
</style>

Not sure about #1, I know #2 is generated by the Contact Form 7 plugin, #3 is Disqus, and #4 is from the new admin bar in 3.1 and although I added show_admin_bar( false ); to my functions file, the styles still show up in my head section. Anyway to get rid of all or at least some of these?

Related posts

Leave a Reply

3 comments

  1. 1) Normally not (that’s the translation mechanism offered for javscript strings), but you can probably de-register that l10n script. But be warned that some plugins and the site might not work as intended any longer.

    2) Yes, by uninstalling the contact form 7 plugin.

    3) Yes, by removing the disqus plugin.

    4) If disabling the admin bar did not work, please report this as a bug in wordpress trac. I assume it left’s over a registered hook to be removed, but that’s just an assumption.

  2. 4) Plugins > WordPress.com Stats. Uncheck Admin Bar. Unfortunately, it doesn’t saved but you can easily fix it.

    
    Index: stats/stats.php
    ===================================================================
    --- stats/stats.php     (revision 361838)
    +++ stats/stats.php     (working copy)
    @@ -351,8 +351,7 @@
    
                            case 'save_options' :
                                    $options = stats_get_options();
    -                               if ( isset($_POST['admin_bar']) )
    -                                       $options['admin_bar'] = (bool) $_POST['admin_bar'];
    +                               $options['admin_bar'] = isset($_POST['admin_bar']) && $_POST['admin_bar'];
                                    $options['wp_me'] = isset($_POST['wp_me']) && $_POST['wp_me'];
                                    $options['reg_users'] = isset($_POST['reg_users']) && $_POST['reg_users'];
    
    

    … or use this until someone report the bug:

    
    add_action( 'plugins_loaded', 'remove_stats_admin_bar_head' );
        function remove_stats_admin_bar_head() {
            remove_action( 'wp_head', 'stats_admin_bar_head', 100 );
        }
    
    
  3. You can de-register #1 by doing, but as hakre said it probably best to keep it;

    function my_removal_thang() {
    wp_deregister_script( 'l10n' );
    }
    add_action('init', 'my_removal_thang');