What type of template are WP media-modal’s templates?

Here’s an interesting part from http://underscorejs.org/#template If ERB-style delimiters aren’t your cup of tea, you can change Underscore’s template settings to use different symbols to set off interpolated code. Define an interpolate regex to match expressions that should be interpolated verbatim, an escape regex to match expressions that should be inserted after being HTML-escaped, and … Read more

Can I make use of word-count.js in my own code?

After looking further through the source for word-count.js and then through various WordPress Trac entries I found satisfactory answers to my two questions: Question 1: How can I use the word-count function? To make use of the word count function you have to instantiate the wordcounter utility first: var wc = new window.wp.utils.WordCounter(); and then … Read more

wp_register_script multiple identifiers?

To have the JavaScript Libraries not to load since you already created a bundle of them, do the following: Asumming the following, usual enqueue: function the_js() { wp_enqueue_script(‘bundle_js’, get_template_directory_uri() . ‘/js/bundle.js’, array(), false, false); } add_action(‘wp_enqueue_scripts’, ‘the_js’); and lets say you have in your bundle the following libraries (listing the handles): jquery backbone colorpicker bootstrap_js … Read more

Force core to use .dev JavaScript files

I use a combination of constants on my local install. define(‘CONCATENATE_SCRIPTS’, false); define(‘COMPRESS_SCRIPTS’, false); // <— this is likely the one you’re after define(‘COMPRESS_CSS’, false); define(‘SCRIPT_DEBUG’, true); I’d imagine the second constant listed above is the one you’re after.

Switch to the library tab in the media uploader

After struggling around for days through the poorly documented media modal source code and using code from the gist (thanks, Fabien), I came up with a solution: JS: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model({ custom_data: ” }); this.props.on( ‘change:custom_data’, this.refresh, this ); }, refresh: function() { this.frame.toolbar.get().refresh(); }, // called when the … Read more

single page wordpress

There’s nothing stopping you using AJAX for a singlepage website that loads in other pages dynamically rather than going to a whole new page. I would advise you build the site without the AJAX and then add AJAX on top so that everything degrades gracefully should an error occur or if javascript is turned off. … Read more

WP script versioning breaks cross-site caching?

Use null as $ver param: wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js’, false, null); wp_enqueue_script(‘jquery’); Output: <script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”></script>