iuato

Untitled

Jul 15th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. / Unhook default Thematic functions
  2. function unhook_thematic_functions() {
  3. remove_action( ‘print_media_templates’, ‘td_change_backbone_js_hook’);
  4. add_action(‘print_media_templates’, ‘custom_td_change_backbone_js_hook’);
  5. }
  6. add_action( ‘init’, ‘unhook_thematic_functions’ );
  7.  
  8. /**
  9. * custom gallery setting
  10. */
  11. function custom_td_custom_gallery_settings_hook () {
  12. // define your backbone template;
  13. // the “tmpl-” prefix is required,
  14. // and your input field should have a data-setting attribute
  15. // matching the shortcode name
  16. ?>
  17. <script type=”text/html” id=”tmpl-td-custom-gallery-setting”>
  18. <label class=”setting”>
  19. <span>Gallery Type</span>
  20. <select data-setting=”td_select_gallery_slide”>
  21. <option value=”slide”>TagDiv Slide Gallery</option>
  22. <option value=””>Default </option>
  23. </select>
  24. </label>
  25.  
  26. <label class=”setting”>
  27. <span>Gallery Title</span>
  28. <input type=”text” value=”” data-setting=”td_gallery_title_input” />
  29. </label>
  30. </script>
  31.  
  32. <script>
  33.  
  34. jQuery(document).ready(function(){
  35.  
  36. // add your shortcode attribute and its default value to the
  37. // gallery settings list; $.extend should work as well…
  38. _.extend(wp.media.gallery.defaults, {
  39. td_select_gallery_slide: ”, td_gallery_title_input: ”
  40. });
  41.  
  42. // merge default gallery settings template with yours
  43. wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
  44. template: function(view){
  45. return wp.media.template(‘gallery-settings’)(view)
  46. + wp.media.template(‘td-custom-gallery-setting’)(view);
  47. }
  48. });
  49.  
  50. //console.log();
  51. // wp.media.model.Attachments.trigger(‘change’)
  52. });
  53.  
  54. </script>
  55. <?php
  56. }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment