Created
December 18, 2012 17:01
-
-
Save johnpbloch/4329763 to your computer and use it in GitHub Desktop.
Add a custom page to the new media manager in WordPress that only shows attachments uploaded to this post with no controls to change it. This is undoubtedly bad programming, but that javascript is a huge mess of undocumented code with little to no help in figuring out how to extend it.
This file contains hidden or 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
(function($){ | |
var media = wp.media, | |
jeditor = { | |
oldMainMenu : media.view.MediaFrame.Post.prototype.mainMenu, | |
init : function(){ | |
media.view.MediaFrame.Post.prototype.mainMenu = function(view){ | |
jeditor.oldMainMenu(view); | |
var jState = new media.controller.Library({ | |
id: 'test', | |
library: media.query({uploadedTo: media.view.settings.post.id}), | |
title: 'Test Library', | |
router: false | |
}), | |
jMenuItem = new media.view.MenuItem({ | |
id: 'test', | |
text: 'Test', | |
priority: 200, | |
controller: view.controller, | |
state: jState | |
}); | |
jState.set('menuItem', jMenuItem); | |
view.controller.states.add(jState); | |
view.set({ | |
'test': jMenuItem, | |
'sep2': { | |
className: 'separator', | |
priority: 199 | |
} | |
}) | |
}; | |
} | |
}; | |
$(jeditor.init); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment