Last active
December 16, 2016 17:50
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by https://gist.github.com/Fab1en/4586865