Quantcast
Viewing all articles
Browse latest Browse all 8245

benolding on "jQuery not loading after upgrade"

Hi -

First, let me say I am in over my head, so apologies in advance if there's a leap in logic here or some other confusion on my part. Any help is appreciated.

I upgraded to the latest version of Wordpress and the custom drop-down menus on our website stopped working. I disabled all the plugins, but that didn't have any effect - the issue appears to be the custom theme we're using.

Ok, that's what I'm sure of. The rest of this is me reading the Internet and trying to make sense of things (sorry in advance if this doesn't make sense).

Looking at the Javascript console in Chrome, I see the following error multiple times:

Uncaught ReferenceError: jQuery is not defined (anonymous function)

So, my conclusion is the theme was loading jQuery in a way that made sense on previous Wordpress versions, but has since been deprecated.

I tried reading about the "right" way to load jQuery with Wordpress, but it sure seems to me the custom theme is doing it correctly (and this is an expression of my ignorance, not confidence). Here's an example code snippet:

function scubanet_init() {
	global $_footer_scripts, $_no_scripts, $_grids, $_ajax;
	if( is_admin() ) $_ajax = 0;
	wp_enqueue_script( 'functions', get_bloginfo( 'template_url' ).'/js/functions.js' );
	wp_enqueue_script( 'jquery' );
	wp_enqueue_script( 'jquery.stageviewer', get_bloginfo( 'template_url' ).'/js/jquery.stageviewer.js', array('jquery','colorbox') );
	if( !is_admin() ) {
		wp_enqueue_script( 'golden_js', get_bloginfo( 'template_url' ).'/golden.js', array( 'jquery' ) );
		wp_enqueue_script( 'hashchange', get_bloginfo( 'template_url' ).'/js/jquery.ba-hashchange.js', array( 'jquery' ) );
		wp_enqueue_script( '_js', dirname( get_bloginfo( 'stylesheet_url' ) ).'/scripts.js', array( 'jquery', 'hashchange' ) );
		add_action( 'wp_print_scripts', 'print_scripts_in_footer' );
	}
	register_taxonomy_for_object_type( 'post_tag', 'page' );

	global $_header_scripts, $_meta;
	$_header_scripts = array( 'jquery', 'jquery.history', 'jw-embedder', 'swfobject' );
	$_meta = apply_filters( '_meta', $_meta );
	wp_enqueue_script( 'comment-reply' );
	$css_url = get_bloginfo('template_url').'/css';
	$css_dir = TEMPLATEPATH.'/css';
	if( file_exists( $css_dir ) && !is_admin() ) {
		$dh = opendir( $css_dir );
		while ( $file = readdir($dh) ) {
			if ( $file != '.' && $file != '..' ) {
				if( $file[0] != '_' ) $csss[] = $file;
			}
		}
		sort($csss);
		foreach($csss as $file) {
			wp_enqueue_style( basename($file), $css_url.'/'.$file );
		}
	}
}
add_action('init','scubanet_init');

These .js files are showing up in the console as having jQuery undefined however.

This code snippet comes from a .php file that is included as the first line of functions.php. It certainly seems like it is the section resulting in the errors in the console view, though I can't be completely confident.


Viewing all articles
Browse latest Browse all 8245

Trending Articles