How to retrieve a value from an input field in a media view template

After digging through the media modal code, I came up with the answer to my question: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model(); }, // called when the toolbar button is clicked customAction: function( controller ){ // get the value of a media view template form field using // this.props.get(‘key’), where ‘key’ is … Read more

backbone fetch() not working

fetch returns a promise, so you want to wait until the promise is resolved. For example: new wp.api.models.Post( { id: 1 } ).fetch().then( console.log ); or doing something with the data: new wp.api.models.Post( { id: 1 } ).fetch().then( post => { console.log( post ); } ); To address your comment, Promises are async – so … Read more

Backbone.js and WP API

I haven’t used the WP-API/JSON REST client plugin so far, but this is what I can see in source: The ~/js/models.js is the entry point for all requests, it seems. And every of the wp.api.models (to name a few: Page, Post, Media, Revision, etc.) is just an extension of Backbone.Model. And looking into the actual … Read more

How to Dequeue All WordPress Assets

I’m not sure what more you need that the example there, and remember that some scripts are needed for stuff like the admin bar and are not enqueued if you are not logged in. function wpdocs_dequeue_script() { wp_dequeue_script( ‘jquery-ui-core’ ); } add_action( ‘wp_print_scripts’, ‘wpdocs_dequeue_script’, 100 ); This will dequeue the jquery-ui-core js. Adding more lines … Read more