Skip to content

Instantly share code, notes, and snippets.

@aesqe
Last active December 16, 2016 17:50
Show Gist options
  • Save aesqe/4996810 to your computer and use it in GitHub Desktop.
Save aesqe/4996810 to your computer and use it in GitHub Desktop.
Adds a button to WordPress 3.5 Backbone-powered uploader/media library modal.
var wpMediaFramePost = wp.media.view.MediaFrame.Post;
wp.media.view.MediaFrame.Post = wpMediaFramePost.extend(
{
mainInsertToolbar: function( view )
{
"use strict";
// first of all, call the original functions from prototype
wpMediaFramePost.prototype.mainInsertToolbar.call(this, view);
var controller = this;
this.selectionStatusToolbar( view );
view.set( "button-name", {
text: "button text",
style: "primary", // button class
priority: 80,
requires: {
// requires an active selection of attachments for the button to be enabled
selection: true
},
// function which will be executed when you click the button
click: function()
{
var state = controller.state(),
selection = state.get("selection");
}
});
}
});
@aesqe
Copy link
Author

aesqe commented Feb 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment