treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Use Google-Hosted JavaScript Libraries (…still the Right Way

  • Hello All!

    I'm farely new at messing around with Wordpress and in a recent screen-cast #73, http://css-tricks.com/video-screencasts/73-wordpress-theme/3 Chris showed how load Google-Hosted JQuery in the Wordpress function.php page and Chris also has a post on Digging into Wordpress about this too, http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/ ). In that a article they mention using the "admin_is" conditional tip so as not too mess up the Rich-text editor on the admin side. Unfortunately, I'm fairly new to Wordpress and don't know how to go about doing this. Can someone help me do that?

    Here is my function.php file:
    <?php

    automatic_feed_links();

    if( !is_admin()){
    wp_deregister_script('jquery');
    wp_register_script('jquery', (\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"), false, '1.3.2');
    wp_enqueue_script('jquery');
    }
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'before_widget' => '<li id=\"%1$s\" class=\"widget %2$s\">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class=\"widgettitle\">',
    'after_title' => '</h2>',
    ));
    }
    ?>


    And here is my header.php file:
    <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
    <html xmlns=\"http://www.w3.org/1999/xhtml\" <?php language_attributes(); ?>>

    <head profile=\"http://gmpg.org/xfn/11\">

    <meta http-equiv=\"Content-Type\" content=\"<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>\" />

    <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

    <link rel=\"stylesheet\" href=\"<?php bloginfo('stylesheet_url'); ?>\" type=\"text/css\" media=\"screen\" />
    <link rel=\"pingback\" href=\"<?php bloginfo('pingback_url'); ?>\" />
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>

    <script type=\"text/javascript\" src=\"<?php bloginfo('template_url'); ?>/js/fancyzoom.min.js\"></script>
    <script type=\"text/javascript\" charset=\"utf-8\">
    $(document).ready(function() {
    $('#large_box_link').fancyZoom({width:620, height:390});

    });
    </script>
    <script type=\"text/javascript\" src=\"<?php bloginfo('template_url'); ?>/js/fancyzoom.js\"></script>
    </head>

    <body <?php body_class(); ?>>


    Any help someone could give me would be great! My Admin is messed up because of this.

    Thanks,
    Hal
  • Okay, so I just realized that I have the "is_admin" conditional statement in there. So, that is not it. Here are the warnings I'm getting on the admin side:

    Warning: Cannot modify header information - headers already sent by (output started at /home/newhop9/public_html/newsite/wp-content/themes/NHFC/functions.php:1) in /home/newhop9/public_html/newsite/wp-includes/classes.php on line 1586

    Warning: Cannot modify header information - headers already sent by (output started at /home/newhop9/public_html/newsite/wp-content/themes/NHFC/functions.php:1) in /home/newhop9/public_html/newsite/wp-includes/pluggable.php on line 865

    So, if anyone can help me out. That would be awesome!

    Thanks,
    Hal
  • Could you try running through your plugins and other code to see if it's not one of them causing an error? Everything on the script you provided should work.