Document Gallery - Version 4.3.2

Version Description

  • Bug Fix: Bug in editing gallery from post editor has been resolved.
  • Note: Minimum WordPress version has been bumped from 4.1 to 4.2.
Download this release

Release Info

Developer dan.rossiter
Plugin Icon 128x128 Document Gallery
Version 4.3.2
Comparing to
See all releases

Code changes from version 4.3.1 to 4.3.2

CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
  # Changelog
2
 
 
 
 
 
3
  ## 4.3.1
4
  * **Enhancement:** WordPress 4.7 includes native support for PDF thumbnails. Document Gallery was already using some
5
  of this, but this update ensures that DG takes full advantage of the new core functionality, including some new
1
  # Changelog
2
 
3
+ ## 4.3.2
4
+ * **Bug Fix:** Bug in editing gallery from post editor has been resolved.
5
+ * **Note:** Minimum WordPress version has been bumped from 4.1 to 4.2.
6
+
7
  ## 4.3.1
8
  * **Enhancement:** WordPress 4.7 includes native support for PDF thumbnails. Document Gallery was already using some
9
  of this, but this update ensures that DG takes full advantage of the new core functionality, including some new
README.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: dan.rossiter, demur
3
  Tags: attachments, library, thumbnail, documents, gallery, word, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
- Requires at least: 4.1
6
  Tested up to: 4.7
7
- Stable tag: 4.3.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -422,6 +422,10 @@ To see a list of features planned for the future as well as to propose your own
422
  ideas for future Document Gallery development, take a look at our
423
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
424
 
 
 
 
 
425
  = 4.3.1 =
426
  * **Enhancement:** WordPress 4.7 includes native support for PDF thumbnails. Document Gallery was already using some
427
  of this, but this update ensures that DG takes full advantage of the new core functionality, including some new
2
  Contributors: dan.rossiter, demur
3
  Tags: attachments, library, thumbnail, documents, gallery, word, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
+ Requires at least: 4.2
6
  Tested up to: 4.7
7
+ Stable tag: 4.3.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
422
  ideas for future Document Gallery development, take a look at our
423
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
424
 
425
+ = 4.3.2 =
426
+ * **Bug Fix:** Bug in editing gallery from post editor has been resolved.
427
+ * **Note:** Minimum WordPress version has been bumped from 4.1 to 4.2.
428
+
429
  = 4.3.1 =
430
  * **Enhancement:** WordPress 4.7 includes native support for PDF thumbnails. Document Gallery was already using some
431
  of this, but this update ensures that DG takes full advantage of the new core functionality, including some new
admin/media-manager-template.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php /* Custom templates into the DOM */
2
  include_once DG_PATH . 'inc/class-gallery.php';
3
  ?>
4
  <script type="text/html" id="tmpl-dg-settings">
1
+ <?php /* Custom templates into the DOM (based on /wp-includes/media-template.php) */
2
  include_once DG_PATH . 'inc/class-gallery.php';
3
  ?>
4
  <script type="text/html" id="tmpl-dg-settings">
assets/js/gallery.js CHANGED
@@ -45,7 +45,7 @@
45
  tinymce.PluginManager.add('dg', function (editor, url) {
46
  editor.on('LoadContent update.dg undo', function (e) {
47
  $(e.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function () {
48
- retrieveGallery($.parseJSON(decodeURIComponent($(this).data('shortcode'))), $(this));
49
  });
50
  });
51
  });
45
  tinymce.PluginManager.add('dg', function (editor, url) {
46
  editor.on('LoadContent update.dg undo', function (e) {
47
  $(e.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function () {
48
+ retrieveGallery((typeof $(this).data('shortcode') === 'object' ? $(this).data('shortcode') : JSON.parse(decodeURIComponent($(this).data('shortcode')))), $(this));
49
  });
50
  });
51
  });
assets/js/gallery.min.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(b){function h(a){(a||b(".document-gallery[data-icon-width]")).each(function(){var a=b(this).data("icon-width");"undefined"!==typeof a&&b(this).find(".document-icon").width(a+"%")})}function p(){g&&tinymce.PluginManager.add("dg",function(a,d){a.on("LoadContent update.dg undo",function(a){b(a.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function(){k(b.parseJSON(decodeURIComponent(b(this).data("shortcode"))),b(this))})})})}function q(){b("body").delegate(".dg-paginate-wrapper .paginate a",
2
- "click",function(a){var d=b(this).closest(".dg-paginate-wrapper"),e=d.data("shortcode");e.skip=0;var c=b(this).attr("href").split("#")[1].split("=");2<=c.length&&(e.skip=e.limit*(c.pop()-1));k(e,d);a.preventDefault()})}function l(){c=[];f=0;b(".document-gallery img[data-id]").each(function(){var a=b(this).data("id");-1===b.inArray(a,c)&&c.push(a)});m()}function k(a,d){"undefined"===typeof a.id&&(a.id=wp.media.dgDefaults.id);b.post(ajaxurl,{action:"dg_generate_gallery",atts:a},function(a){a=b(b.parseHTML(a));
3
- g&&!n&&a.find(r).length&&(n=!0,b("#insert-media-button").trigger("ready.dg"));d.replaceWith(a);h(a);l()})}function m(){for(var a=[];f<c.length&&4!==a.length;f++)a.push(c[f]);0!=a.length&&b.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"dg_generate_icons",ids:a},success:t,error:function(a){console.error(a.responseText)}})}function t(a){for(var d in a)if(a.hasOwnProperty(d)){var c=b('.document-gallery img[data-id="'+d+'"]');c.removeAttr("data-id");(function(c,d){d.fadeOut("fast",function(){b(this).attr("src",
4
- a[c]);b(this).fadeIn("fast")})})(d,c)}m()}var c,f,g,r='.document-gallery [data-ext="'+"doc docx ppt pptx xls xlsx pub vsd vsdx".split(" ").join('"],[data-ext="')+'"]',n=!1;b(document).ready(function(){g="undefined"!==typeof tinymce;h();l();p();q()})})(jQuery);
1
+ (function(b){function h(a){(a||b(".document-gallery[data-icon-width]")).each(function(){var a=b(this).data("icon-width");"undefined"!==typeof a&&b(this).find(".document-icon").width(a+"%")})}function p(){g&&tinymce.PluginManager.add("dg",function(a,d){a.on("LoadContent update.dg undo",function(a){b(a.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function(){k("object"===typeof b(this).data("shortcode")?b(this).data("shortcode"):JSON.parse(decodeURIComponent(b(this).data("shortcode"))),
2
+ b(this))})})})}function q(){b("body").delegate(".dg-paginate-wrapper .paginate a","click",function(a){var d=b(this).closest(".dg-paginate-wrapper"),e=d.data("shortcode");e.skip=0;var c=b(this).attr("href").split("#")[1].split("=");2<=c.length&&(e.skip=e.limit*(c.pop()-1));k(e,d);a.preventDefault()})}function l(){c=[];f=0;b(".document-gallery img[data-id]").each(function(){var a=b(this).data("id");-1===b.inArray(a,c)&&c.push(a)});m()}function k(a,d){"undefined"===typeof a.id&&(a.id=wp.media.dgDefaults.id);
3
+ b.post(ajaxurl,{action:"dg_generate_gallery",atts:a},function(a){a=b(b.parseHTML(a));g&&!n&&a.find(r).length&&(n=!0,b("#insert-media-button").trigger("ready.dg"));d.replaceWith(a);h(a);l()})}function m(){for(var a=[];f<c.length&&4!==a.length;f++)a.push(c[f]);0!=a.length&&b.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"dg_generate_icons",ids:a},success:t,error:function(a){console.error(a.responseText)}})}function t(a){for(var d in a)if(a.hasOwnProperty(d)){var c=b('.document-gallery img[data-id="'+
4
+ d+'"]');c.removeAttr("data-id");(function(c,d){d.fadeOut("fast",function(){b(this).attr("src",a[c]);b(this).fadeIn("fast")})})(d,c)}m()}var c,f,g,r='.document-gallery [data-ext="'+"doc docx ppt pptx xls xlsx pub vsd vsdx".split(" ").join('"],[data-ext="')+'"]',n=!1;b(document).ready(function(){g="undefined"!==typeof tinymce;h();l();p();q()})})(jQuery);
assets/js/media_manager.js CHANGED
@@ -55,6 +55,7 @@
55
  title: l10n.editdgTitle,
56
  multiple: false,
57
  searchable: false,
 
58
  sortable: true,
59
  display: false,
60
  content: 'browse',
@@ -403,13 +404,16 @@
403
  state = controller.state();
404
 
405
  controller.close();
406
- //state.trigger( 'update', state.get('library') ); // calling for workflow.state update, so just execute its contents
407
- wp.media.editor.insert(wp.media.dg.shortcode(state.get('library')).string().replace(/\sdgorder=/ig, ' order=').replace(/\sdgorderby=/ig, ' orderby='));
 
 
 
408
 
409
  // Restore and reset the default state.
410
  controller.setState(controller.options.state);
411
  controller.reset();
412
- if (typeof tinyMCE != 'undefined') {
413
  tinyMCE.activeEditor.fire('update.dg');
414
  }
415
  }
@@ -515,7 +519,7 @@ if ( typeof window.wp.mce !== 'undefined' && typeof window.wp.mce.views !== 'und
515
 
516
  _.each(this.state, function (state) {
517
  frame.state(state).on('update', function (selection) {
518
- update(media[type].shortcode(selection).string(), type === 'dg');
519
  });
520
  });
521
 
55
  title: l10n.editdgTitle,
56
  multiple: false,
57
  searchable: false,
58
+ date: false,
59
  sortable: true,
60
  display: false,
61
  content: 'browse',
404
  state = controller.state();
405
 
406
  controller.close();
407
+ if ( editing ) {
408
+ state.trigger('update', state.get('library')); // calling for workflow.state update, so just execute its contents
409
+ } else {
410
+ wp.media.editor.insert(wp.media.dg.shortcode(state.get('library')).string().replace(/\sdgorder=/ig, ' order=').replace(/\sdgorderby=/ig, ' orderby='));
411
+ }
412
 
413
  // Restore and reset the default state.
414
  controller.setState(controller.options.state);
415
  controller.reset();
416
+ if (typeof tinyMCE != 'undefined' && tinyMCE.activeEditor !== null) {
417
  tinyMCE.activeEditor.fire('update.dg');
418
  }
419
  }
519
 
520
  _.each(this.state, function (state) {
521
  frame.state(state).on('update', function (selection) {
522
+ update(media[type].shortcode(selection).string().replace(/\sdgorder=/ig, ' order=').replace(/\sdgorderby=/ig, ' orderby='), type === 'dg');
523
  });
524
  });
525
 
assets/js/media_manager.min.js CHANGED
@@ -1,15 +1,15 @@
1
- (function(h,g){if("function"===typeof wp.media.collection){var d,a=wp.media;d=a.view.l10n="undefined"===typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n;jQuery.extend(d,DGl10n);a.controller.dgEdit=a.controller.Library.extend({defaults:{id:"dg-edit",title:d.editdgTitle,multiple:!1,searchable:!1,sortable:!0,display:!1,content:"browse",toolbar:"dg-edit",describe:!0,displaySettings:!0,dragInfo:!0,idealColumnWidth:170,editing:!1,priority:60,syncSelection:!1},initialize:function(){this.get("library")||this.set("library",
2
- new a.model.Selection);this.get("AttachmentView")||this.set("AttachmentView",a.view.Attachment.EditLibrary);a.controller.Library.prototype.initialize.apply(this,arguments)},activate:function(){this.get("library");this.get("library").observe(wp.Uploader.queue);this.frame.on("content:render:browse",this.dgSettings,this);a.controller.Library.prototype.activate.apply(this,arguments)},deactivate:function(){this.get("library").unobserve(wp.Uploader.queue);this.frame.off("content:render:browse",this.dgSettings,
3
- this);a.controller.Library.prototype.deactivate.apply(this,arguments)},dgSettings:function(b){if(this.get("displaySettings")){var c=this.get("library");c&&b&&(c.dg=c.dg||new Backbone.Model,b.sidebar.set({dg:new a.view.Settings.dg({controller:this,model:c.dg,priority:40})}),b.toolbar.set("reverse",{text:d.reverseOrder,priority:80,click:function(){c.reset(c.toArray().reverse())}}))}}});a.controller.dgAdd=a.controller.Library.extend({defaults:g.defaults({id:"dg-library",title:d.addTodgTitle,multiple:"add",
4
- filterable:"uploaded",menu:"dg",toolbar:"dg-add",priority:100,syncSelection:!1},a.controller.Library.prototype.defaults),initialize:function(){this.get("library")||this.set("library",a.query());a.controller.Library.prototype.initialize.apply(this,arguments)},activate:function(){var b=this.get("library"),c=this.frame.state("dg-edit").get("library");this.editLibrary&&this.editLibrary!==c&&b.unobserve(this.editLibrary);b.validator=function(b){return!!this.mirroring.get(b.cid)&&!c.get(b.cid)&&a.model.Selection.prototype.validator.apply(this,
5
- arguments)};b.reset(b.mirroring.models,{silent:!0});b.observe(c);this.editLibrary=c;a.controller.Library.prototype.activate.apply(this,arguments)}});a.view.Settings.dg=a.view.Settings.extend({update:function(b){var c=this.model.get(b),a=this.$('[data-setting="'+b+'"]');a.length&&(a.is("select")?(c=a.find('[value="'+c+'"]'),c.length?(a.find("option").prop("selected",!1),c.prop("selected",!0)):this.model.set(b,a.find(":selected").val())):a.hasClass("button-group")?(b=a.find("button").removeClass("active"),
6
- b.filter('[value="'+c+'"]').addClass("active")):a.is('input[type="text"], input[type="number"], textarea')?a.is(":focus")||a.val(c):a.is('input[type="checkbox"]')&&a.prop("checked",!!c&&"false"!==c))},className:"collection-settings dg-settings",template:a.template("dg-settings")});var e=wp.media.view.MediaFrame.Post;wp.media.view.MediaFrame.Post=e.extend({initialize:function(){e.prototype.initialize.apply(this,arguments);this.states.add([new a.controller.Library({id:"dg",title:d.dgMenuTitle,priority:50,
7
- toolbar:"main-dg",filterable:"all",multiple:"add",editable:!1,library:a.query(this.options.library)}),new a.controller.dgEdit({library:this.options.selection,editing:this.options.editing,menu:"dg"}),new a.controller.dgAdd]);this.on("menu:create:dg",this.createMenu,this);this.on("toolbar:create:main-dg",this.createToolbar,this);this.on("menu:render:dg",this.dgMenu,this);this.on("toolbar:render:main-dg",this.maindgToolbar,this);this.on("toolbar:render:dg-edit",this.dgEditToolbar,this);this.on("toolbar:render:dg-add",
8
- this.dgAddToolbar,this)},dgMenu:function(b){var c=this.lastState(),f=c&&c.id,e=this;b.set({cancel:{text:d.canceldgTitle,priority:20,click:function(){f?e.setState(f):e.close();this.controller.modal.focusManager.focus()}},separateCancel:new a.View({className:"separator",priority:40})})},maindgToolbar:function(b){var c=this;this.selectionStatusToolbar(b);b.set("dg",{style:"primary",text:d.dgButton,priority:60,requires:{selection:!0},click:function(){var b=c.state().get("selection");c.state("dg-edit").set("library",
9
- new a.model.Selection(b.models,{props:b.props.toJSON(),multiple:!0}));this.controller.setState("dg-edit");this.controller.modal.focusManager.focus()}})},dgEditToolbar:function(){var b=this.state().get("editing");this.toolbar.set(new a.view.Toolbar({controller:this,items:{insert:{style:"primary",text:b?d.updatedg:d.insertdg,priority:80,requires:{library:!0},click:function(){var c=this.controller,b=c.state();c.close();wp.media.editor.insert(wp.media.dg.shortcode(b.get("library")).string().replace(/\sdgorder=/ig,
10
- " order=").replace(/\sdgorderby=/ig," orderby="));c.setState(c.options.state);c.reset();"undefined"!=typeof tinyMCE&&tinyMCE.activeEditor.fire("update.dg")}}}}))},dgAddToolbar:function(){this.toolbar.set(new a.view.Toolbar({controller:this,items:{insert:{style:"primary",text:d.addTodg,priority:80,requires:{selection:!0},click:function(){var b=this.controller,c=b.state();b.state("dg-edit").get("library").add(c.get("selection").models);c.trigger("reset");b.setState("dg-edit")}}}}))}});wp.media._dgDefaults=
11
- {id:wp.media.view.settings.post&&wp.media.view.settings.post.id,columns:dgDefaults.columns,fancy:dgDefaults.fancy,relation:dgDefaults.relation,limit:dgDefaults.limit,mime_types:dgDefaults.mime_types,post_status:dgDefaults.post_status,post_type:dgDefaults.post_type,attachment_pg:dgDefaults.attachment_pg,descriptions:dgDefaults.descriptions,new_window:dgDefaults.new_window,paginate:dgDefaults.paginate,dgorder:dgDefaults.order,dgorderby:dgDefaults.orderby};wp.media.dgDefaults=wp.media.view.settings.dgDefaults?
12
- g.extend({},wp.media._dgDefaults,wp.media.view.settings.dgDefaults):wp.media._dgDefaults;wp.media.dg=new wp.media.collection({tag:"dg",editTitle:wp.media.view.l10n.editdgTitle,defaults:wp.media.dgDefaults,setDefaults:function(b){var c=this,a=!g.isEqual(wp.media.dgDefaults,wp.media._dgDefaults);g.each(this.defaults,function(d,e){b[e]=c.coerce(b,e);d!==b[e]||a&&d!==wp.media._dgDefaults[e]||delete b[e]});return b}})}})(jQuery,_);
13
- "undefined"!==typeof window.wp.mce&&"undefined"!==typeof window.wp.mce.views&&function(h,g,d,a){base={state:[],edit:function(a,b){if(-1==a.search(/\sids\s*=/gi)||-1<a.search(/\s(?!(?:ids|attachment_pg|columns|new_window|descriptions|fancy|orderby|order|paginate|limit)\s*=)[\w\-]+\s*=/gi))tinyMCE.activeEditor.windowManager.alert(DGl10n.unfitSCalert);else{var c=this.type,f=d[c].edit(a.replace(/\sorder\s*=/ig," dgorder=").replace(/\sorderby\s*=/ig," dgorderby="));this.pausePlayers&&this.pausePlayers();
14
- _.each(this.state,function(a){f.state(a).on("update",function(a){b(d[c].shortcode(a).string(),"dg"===c)})});f.on("close",function(){f.detach()});f.open()}}};h=_.extend({},base,{state:["dg-edit"],template:d.template("editor-dg"),initialize:function(){d.dg.attachments(this.shortcode,d.view.settings.post.id);var a=this.shortcode.attrs.named,b=this.text,c={};for(prop in a)-1<b.indexOf(" "+prop+"=")&&(c[prop]=a[prop]);-1<b.indexOf(" dgorderby=")&&(c.orderby=a.dgorderby);-1<b.indexOf(" dgorder=")&&(c.order=
15
- a.dgorder);this.render('<div data-shortcode="'+encodeURIComponent(JSON.stringify(c))+'"><div class="loading-placeholder"><div class="dashicons dashicons-admin-media"></div><div class="wpview-loading"><ins></ins></div></div></div>')}});g.register("dg",_.extend({},h))}(window,window.wp.mce.views,window.wp.media,window.jQuery);
1
+ (function(h,g){if("function"===typeof wp.media.collection){var d,a=wp.media;d=a.view.l10n="undefined"===typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n;jQuery.extend(d,DGl10n);a.controller.dgEdit=a.controller.Library.extend({defaults:{id:"dg-edit",title:d.editdgTitle,multiple:!1,searchable:!1,date:!1,sortable:!0,display:!1,content:"browse",toolbar:"dg-edit",describe:!0,displaySettings:!0,dragInfo:!0,idealColumnWidth:170,editing:!1,priority:60,syncSelection:!1},initialize:function(){this.get("library")||
2
+ this.set("library",new a.model.Selection);this.get("AttachmentView")||this.set("AttachmentView",a.view.Attachment.EditLibrary);a.controller.Library.prototype.initialize.apply(this,arguments)},activate:function(){this.get("library");this.get("library").observe(wp.Uploader.queue);this.frame.on("content:render:browse",this.dgSettings,this);a.controller.Library.prototype.activate.apply(this,arguments)},deactivate:function(){this.get("library").unobserve(wp.Uploader.queue);this.frame.off("content:render:browse",
3
+ this.dgSettings,this);a.controller.Library.prototype.deactivate.apply(this,arguments)},dgSettings:function(c){if(this.get("displaySettings")){var b=this.get("library");b&&c&&(b.dg=b.dg||new Backbone.Model,c.sidebar.set({dg:new a.view.Settings.dg({controller:this,model:b.dg,priority:40})}),c.toolbar.set("reverse",{text:d.reverseOrder,priority:80,click:function(){b.reset(b.toArray().reverse())}}))}}});a.controller.dgAdd=a.controller.Library.extend({defaults:g.defaults({id:"dg-library",title:d.addTodgTitle,
4
+ multiple:"add",filterable:"uploaded",menu:"dg",toolbar:"dg-add",priority:100,syncSelection:!1},a.controller.Library.prototype.defaults),initialize:function(){this.get("library")||this.set("library",a.query());a.controller.Library.prototype.initialize.apply(this,arguments)},activate:function(){var c=this.get("library"),b=this.frame.state("dg-edit").get("library");this.editLibrary&&this.editLibrary!==b&&c.unobserve(this.editLibrary);c.validator=function(c){return!!this.mirroring.get(c.cid)&&!b.get(c.cid)&&
5
+ a.model.Selection.prototype.validator.apply(this,arguments)};c.reset(c.mirroring.models,{silent:!0});c.observe(b);this.editLibrary=b;a.controller.Library.prototype.activate.apply(this,arguments)}});a.view.Settings.dg=a.view.Settings.extend({update:function(c){var b=this.model.get(c),e=this.$('[data-setting="'+c+'"]');e.length&&(e.is("select")?(b=e.find('[value="'+b+'"]'),b.length?(e.find("option").prop("selected",!1),b.prop("selected",!0)):this.model.set(c,e.find(":selected").val())):e.hasClass("button-group")?
6
+ (c=e.find("button").removeClass("active"),c.filter('[value="'+b+'"]').addClass("active")):e.is('input[type="text"], input[type="number"], textarea')?e.is(":focus")||e.val(b):e.is('input[type="checkbox"]')&&e.prop("checked",!!b&&"false"!==b))},className:"collection-settings dg-settings",template:a.template("dg-settings")});var f=wp.media.view.MediaFrame.Post;wp.media.view.MediaFrame.Post=f.extend({initialize:function(){f.prototype.initialize.apply(this,arguments);this.states.add([new a.controller.Library({id:"dg",
7
+ title:d.dgMenuTitle,priority:50,toolbar:"main-dg",filterable:"all",multiple:"add",editable:!1,library:a.query(this.options.library)}),new a.controller.dgEdit({library:this.options.selection,editing:this.options.editing,menu:"dg"}),new a.controller.dgAdd]);this.on("menu:create:dg",this.createMenu,this);this.on("toolbar:create:main-dg",this.createToolbar,this);this.on("menu:render:dg",this.dgMenu,this);this.on("toolbar:render:main-dg",this.maindgToolbar,this);this.on("toolbar:render:dg-edit",this.dgEditToolbar,
8
+ this);this.on("toolbar:render:dg-add",this.dgAddToolbar,this)},dgMenu:function(c){var b=this.lastState(),e=b&&b.id,f=this;c.set({cancel:{text:d.canceldgTitle,priority:20,click:function(){e?f.setState(e):f.close();this.controller.modal.focusManager.focus()}},separateCancel:new a.View({className:"separator",priority:40})})},maindgToolbar:function(c){var b=this;this.selectionStatusToolbar(c);c.set("dg",{style:"primary",text:d.dgButton,priority:60,requires:{selection:!0},click:function(){var c=b.state().get("selection");
9
+ b.state("dg-edit").set("library",new a.model.Selection(c.models,{props:c.props.toJSON(),multiple:!0}));this.controller.setState("dg-edit");this.controller.modal.focusManager.focus()}})},dgEditToolbar:function(){var c=this.state().get("editing");this.toolbar.set(new a.view.Toolbar({controller:this,items:{insert:{style:"primary",text:c?d.updatedg:d.insertdg,priority:80,requires:{library:!0},click:function(){var b=this.controller,a=b.state();b.close();c?a.trigger("update",a.get("library")):wp.media.editor.insert(wp.media.dg.shortcode(a.get("library")).string().replace(/\sdgorder=/ig,
10
+ " order=").replace(/\sdgorderby=/ig," orderby="));b.setState(b.options.state);b.reset();"undefined"!=typeof tinyMCE&&null!==tinyMCE.activeEditor&&tinyMCE.activeEditor.fire("update.dg")}}}}))},dgAddToolbar:function(){this.toolbar.set(new a.view.Toolbar({controller:this,items:{insert:{style:"primary",text:d.addTodg,priority:80,requires:{selection:!0},click:function(){var c=this.controller,b=c.state();c.state("dg-edit").get("library").add(b.get("selection").models);b.trigger("reset");c.setState("dg-edit")}}}}))}});
11
+ wp.media._dgDefaults={id:wp.media.view.settings.post&&wp.media.view.settings.post.id,columns:dgDefaults.columns,fancy:dgDefaults.fancy,relation:dgDefaults.relation,limit:dgDefaults.limit,mime_types:dgDefaults.mime_types,post_status:dgDefaults.post_status,post_type:dgDefaults.post_type,attachment_pg:dgDefaults.attachment_pg,descriptions:dgDefaults.descriptions,new_window:dgDefaults.new_window,paginate:dgDefaults.paginate,dgorder:dgDefaults.order,dgorderby:dgDefaults.orderby};wp.media.dgDefaults=wp.media.view.settings.dgDefaults?
12
+ g.extend({},wp.media._dgDefaults,wp.media.view.settings.dgDefaults):wp.media._dgDefaults;wp.media.dg=new wp.media.collection({tag:"dg",editTitle:wp.media.view.l10n.editdgTitle,defaults:wp.media.dgDefaults,setDefaults:function(c){var b=this,a=!g.isEqual(wp.media.dgDefaults,wp.media._dgDefaults);g.each(this.defaults,function(d,f){c[f]=b.coerce(c,f);d!==c[f]||a&&d!==wp.media._dgDefaults[f]||delete c[f]});return c}})}})(jQuery,_);
13
+ "undefined"!==typeof window.wp.mce&&"undefined"!==typeof window.wp.mce.views&&function(h,g,d,a){base={state:[],edit:function(a,c){if(-1==a.search(/\sids\s*=/gi)||-1<a.search(/\s(?!(?:ids|attachment_pg|columns|new_window|descriptions|fancy|orderby|order|paginate|limit)\s*=)[\w\-]+\s*=/gi))tinyMCE.activeEditor.windowManager.alert(DGl10n.unfitSCalert);else{var b=this.type,e=d[b].edit(a.replace(/\sorder\s*=/ig," dgorder=").replace(/\sorderby\s*=/ig," dgorderby="));this.pausePlayers&&this.pausePlayers();
14
+ _.each(this.state,function(a){e.state(a).on("update",function(a){c(d[b].shortcode(a).string().replace(/\sdgorder=/ig," order=").replace(/\sdgorderby=/ig," orderby="),"dg"===b)})});e.on("close",function(){e.detach()});e.open()}}};h=_.extend({},base,{state:["dg-edit"],template:d.template("editor-dg"),initialize:function(){d.dg.attachments(this.shortcode,d.view.settings.post.id);var a=this.shortcode.attrs.named,c=this.text,b={};for(prop in a)-1<c.indexOf(" "+prop+"=")&&(b[prop]=a[prop]);-1<c.indexOf(" dgorderby=")&&
15
+ (b.orderby=a.dgorderby);-1<c.indexOf(" dgorder=")&&(b.order=a.dgorder);this.render('<div data-shortcode="'+encodeURIComponent(JSON.stringify(b))+'"><div class="loading-placeholder"><div class="dashicons dashicons-admin-media"></div><div class="wpview-loading"><ins></ins></div></div></div>')}});g.register("dg",_.extend({},h))}(window,window.wp.mce.views,window.wp.media,window.jQuery);
document-gallery.php CHANGED
@@ -5,14 +5,14 @@ defined( 'WPINC' ) OR exit;
5
  Plugin Name: Document Gallery
6
  Plugin URI: https://wordpress.org/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
- Version: 4.3.1
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv3
12
  Text Domain: document-gallery
13
  */
14
 
15
- define( 'DG_VERSION', '4.3.1' );
16
 
17
  if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
18
  add_action( 'admin_notices', 'dg_php_lt_three' );
5
  Plugin Name: Document Gallery
6
  Plugin URI: https://wordpress.org/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
+ Version: 4.3.2
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv3
12
  Text Domain: document-gallery
13
  */
14
 
15
+ define( 'DG_VERSION', '4.3.2' );
16
 
17
  if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
18
  add_action( 'admin_notices', 'dg_php_lt_three' );
inc/thumbers/class-abstract-thumber.php CHANGED
@@ -145,6 +145,12 @@ abstract class DG_AbstractThumber {
145
  * @return string[] Contains all MIME types supported by WordPress, including custom types added by plugins.
146
  */
147
  protected static function getAllExts() {
148
- return array_keys( array_merge( wp_get_mime_types(), get_allowed_mime_types() ) );
 
 
 
 
 
 
149
  }
150
  }
145
  * @return string[] Contains all MIME types supported by WordPress, including custom types added by plugins.
146
  */
147
  protected static function getAllExts() {
148
+ static $exts = null;
149
+
150
+ if ( is_null( $exts ) ) {
151
+ $exts = array_keys( array_merge( wp_get_mime_types(), get_allowed_mime_types() ) );
152
+ }
153
+
154
+ return $exts;
155
  }
156
  }
inc/thumbers/thumber-co/class-thumber-client.php CHANGED
@@ -144,12 +144,18 @@ class DG_ThumberClient extends ThumberClient {
144
  public function getMimeTypes() {
145
  global $dg_options;
146
  if ( empty( $dg_options['thumber-co']['mime_types'] ) ) {
 
 
147
  // avoid values being removed as a result of current user but also include any MIME types
148
  // that are added outside of the default WP values
149
  $wp_types = array_merge( wp_get_mime_types(), get_allowed_mime_types() );
 
 
 
 
 
 
150
 
151
- $allowed = array_intersect( $wp_types, parent::getMimeTypes() );
152
- $dg_options['thumber-co']['mime_types'] = array_keys( $allowed );
153
  DocumentGallery::setOptions( $dg_options );
154
  }
155
 
144
  public function getMimeTypes() {
145
  global $dg_options;
146
  if ( empty( $dg_options['thumber-co']['mime_types'] ) ) {
147
+ $dg_options['thumber-co']['mime_types'] = array();
148
+
149
  // avoid values being removed as a result of current user but also include any MIME types
150
  // that are added outside of the default WP values
151
  $wp_types = array_merge( wp_get_mime_types(), get_allowed_mime_types() );
152
+ $allowed = array_keys( array_intersect( $wp_types, parent::getMimeTypes() ) );
153
+ foreach ( $allowed as $exts ) {
154
+ foreach ( explode( '|', $exts ) as $ext ) {
155
+ $dg_options['thumber-co']['mime_types'][] = $ext;
156
+ }
157
+ }
158
 
 
 
159
  DocumentGallery::setOptions( $dg_options );
160
  }
161