Using the REST API (v2) javascript client on a private namespaced route

I am using the latest version of the REST API plugin in a project and I’ve added my routes to a separate namespace (as recommended in the documentation). The javascript client included with the API automatically creates models and collections based on the public routes in the wp/v2 namespace. Does anyone know if it’s possible … Read more

How could I add button next to “edit image” button in “Attachment Details”

How could I add button next to “edit image” button in “Attachment Details” This is the location I would like to add button, Do you have any recommend? 1 Answer 1 I would recommend that you begin by having a look at a question asked more recently here. The best option would be to create … Read more

Customizing the 3.5 “Add Media” popup (Backbone.js)

Here’s yet another question in regard to the new(ish) 3.5 “Add Media” popup and how to customize it! What I’m trying to do I’m attempting to do four main things: 1) Create a custom tab titled “Flickr Uploads”; 2) Customize the text that is displayed in the upload button; 3) Populate the select dropdown with … Read more

Open media frame and select an attachment

I’m using the following piece of code to open a media frame when clicking a link with a data-attachment_id attribute. This attribute holds the id of an attachment that I want to select when the frame opens: jQuery(document).ready(function($){ $( ‘#gallery_images_container’ ).on( ‘click’, ‘a.edit’, function( event ) { var $el = $( this ); var selected … Read more

Add custom class to attachment in media library grid mode

In the above screenshot we are in the media library with grid mode active. I want to add a custom class depending on the attachment filter wp_prepare_attachment_for_js. For example i hook to the filter: public function wp_prepare_attachment_for_js($response, $attachment, $meta) { $response[‘customClass’] = “i-want-this-class”; return $response; } Perhaps it works with Backbone.js to hook into the … Read more

How does REST API cookie authentication work in WP 4.7?

Though I have logged in, I cannot create a post on frontend. WordPress always return 401 Unauthorized response. I have dumped $_COOKIE to make sure logged-in cookie was set and got something like this: array(1) { [“wordpress_logged_in_48f880f2beac6f39fb9ea8d9367e86d6”]=> string(125) “admin|1495526369|PwQIf1tAM5khs2f6LKMgf0T7fP1RwHjl9T6OWW90QfD|6d3373f1a05f2fcbfccc429035b0519a012d3224f725b82d6f253a98862b072d” } I have read entire REST API Handbook and many tuts: When you log in to … Read more