ThemeShaper Forums » Thematic

[closed]

Thematic doesn't use wp_enqueue for head scripts. Why?

(5 posts)
  • Started 2 years ago by pixelfresh
  • Latest reply from pixelfresh
  • This topic is not resolved

Tags:

  1. pixelfresh
    Member

    Perhaps I'm missing something, but shouldn't thematic use the WordPress function wp_enqueue for it's javascripts in the head by default? Currently, it uses the a hacked together function shown below (located in header-extensions.php). Using wp_register and wp_enqueue is standard, would be better for caches due to versioning, and would make getting rid of scripts a lot easier (through deregister), no?

    // Load scripts for the jquery Superfish plugin http://users.tpg.com.au/j_birch/plugins/superfish/#examples
    if (function_exists('childtheme_override_head_scripts'))  {
        function thematic_head_scripts() {
        	childtheme_override_head_scripts();
        }
    } else {
        function thematic_head_scripts() {
    	    $scriptdir_start = "\t";
    	    $scriptdir_start .= '<script type="text/javascript" src="';
    	    $scriptdir_start .= get_bloginfo('template_directory');
    	    $scriptdir_start .= '/library/scripts/';
    
    	    $scriptdir_end = '"></script>';
    
    	    $scripts = "\n";
    	    $scripts .= $scriptdir_start . 'hoverIntent.js' . $scriptdir_end . "\n";
    	    $scripts .= $scriptdir_start . 'superfish.js' . $scriptdir_end . "\n";
    	    $scripts .= $scriptdir_start . 'supersubs.js' . $scriptdir_end . "\n";
    	    $dropdown_options = $scriptdir_start . 'thematic-dropdowns.js' . $scriptdir_end . "\n";
    
    	    $scripts = $scripts . apply_filters('thematic_dropdown_options', $dropdown_options);
    
    	    	$scripts .= "\n";
    	    	$scripts .= "\t";
    	    	$scripts .= '<script type="text/javascript">' . "\n";
    	    	$scripts .= "\t\t" . '/*<![CDATA[*/' . "\n";
    	    	$scripts .= "\t\t" . 'jQuery.noConflict();' . "\n";
    	    	$scripts .= "\t\t" . '/*]]>*/' . "\n";
    	    	$scripts .= "\t";
    	    	$scripts .= '</script>' . "\n";
    
    	    // Print filtered scripts
    	    print apply_filters('thematic_head_scripts', $scripts);
    	}
    
    	if (apply_filters('thematic_use_superfish', TRUE)) {
    		add_action('wp_head','thematic_head_scripts');
    	}
    }
    Posted 2 years ago #
  2. i've been wondering that for a while too. if i need them i usually filter away thematic's version, package them all together as 1 script, and then enqueue that.

    Posted 2 years ago #
  3. pixelfresh
    Member

    Right, I'll probably hook in and do the same, but seems strange that this is necessary. Should be enqueue'ing from the start.

    Posted 2 years ago #
  4. Next version will use enqueue for scripts and CSS.

    Chris

    Posted 2 years ago #
  5. pixelfresh
    Member

    Great to hear, thanks for all your work on this Chris.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.