Document Gallery - Version 4.4.2

Version Description

  • Enhancement: When pagination is enabled for a gallery, navigating to another page will now scroll the page back to the top of the gallery.
  • Enhancement: Added support for %author% to dg_icon template filter.
Download this release

Release Info

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

Code changes from version 4.4.1 to 4.4.2

CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
  # Changelog
2
 
 
 
 
 
 
 
 
 
3
  ## 4.4
4
  * **Enhancement:** Document Gallery updated to support integration with
5
  [WP Real Media Library](https://codecanyon.net/item/wordpress-real-media-library-media-categories-folders/13155134).
@@ -376,7 +384,7 @@
376
  ## 2.0.2
377
  * **Bug Fix:** Imagick was actually never working... My bad -- it is now! Thanks to
378
  [kaldimar](http://wordpress.org/support/profile/kaldimar) for reporting this.
379
- * **Enhancement:** Document Gallery en el Español por Andrew de
380
  [WebHostingHub](http://www.webhostinghub.com/). (To help translate to another
381
  language, [see here](http://wordpress.org/support/topic/seeking-translators).)
382
 
1
  # Changelog
2
 
3
+ ## 4.4.2
4
+ * **Enhancement:** When pagination is enabled for a gallery, navigating to another page will now scroll the page
5
+ back to the top of the gallery.
6
+ * **Enhancement:** Added support for `%author%` to `dg_icon template` filter.
7
+
8
+ ## 4.4.1
9
+ * **Enhancement:** Added support for `%date%` and `%time%` to `dg_icon_template`.
10
+
11
  ## 4.4
12
  * **Enhancement:** Document Gallery updated to support integration with
13
  [WP Real Media Library](https://codecanyon.net/item/wordpress-real-media-library-media-categories-folders/13155134).
384
  ## 2.0.2
385
  * **Bug Fix:** Imagick was actually never working... My bad -- it is now! Thanks to
386
  [kaldimar](http://wordpress.org/support/profile/kaldimar) for reporting this.
387
+ * **Enhancement:** Document Gallery en el Espa?ol por Andrew de
388
  [WebHostingHub](http://www.webhostinghub.com/). (To help translate to another
389
  language, [see here](http://wordpress.org/support/topic/seeking-translators).)
390
 
README.txt CHANGED
@@ -4,7 +4,7 @@ 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.8
7
- Stable tag: 4.4.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -470,6 +470,11 @@ To see a list of features planned for the future as well as to propose your own
470
  ideas for future Document Gallery development, take a look at our
471
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
472
 
 
 
 
 
 
473
  = 4.4.1 =
474
  * **Enhancement:** Added support for `%date%` and `%time%` to `dg_icon_template`.
475
 
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.8
7
+ Stable tag: 4.4.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
470
  ideas for future Document Gallery development, take a look at our
471
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
472
 
473
+ = 4.4.2 =
474
+ * **Enhancement:** When pagination is enabled for a gallery, navigating to another page will now scroll the page
475
+ back to the top of the gallery.
476
+ * **Enhancement:** Added support for `%author%` to `dg_icon template` filter.
477
+
478
  = 4.4.1 =
479
  * **Enhancement:** Added support for `%date%` and `%time%` to `dg_icon_template`.
480
 
admin/class-admin.php CHANGED
@@ -354,6 +354,7 @@ class DG_Admin {
354
  '<input id="trigger-button' . $ID . '" type="button" value="Select File" class="button" />' .
355
  '</span>' .
356
  '</span>' .
 
357
  '</td></tr></tbody></table>' .
358
  ( is_null( $thumb ) ? '<span class="dashicons dashicons-info"></span><span class="">Please note this attachment hasn&#39;t been used in any Document Gallery instance and so there is no autogenerated thumbnail, in the meantime default one is used instead.</span>' : '' ) . PHP_EOL;
359
  }
354
  '<input id="trigger-button' . $ID . '" type="button" value="Select File" class="button" />' .
355
  '</span>' .
356
  '</span>' .
357
+ '<div class="progress animate invis"><span><span></span></span></div>' .
358
  '</td></tr></tbody></table>' .
359
  ( is_null( $thumb ) ? '<span class="dashicons dashicons-info"></span><span class="">Please note this attachment hasn&#39;t been used in any Document Gallery instance and so there is no autogenerated thumbnail, in the meantime default one is used instead.</span>' : '' ) . PHP_EOL;
360
  }
assets/js/gallery.js CHANGED
@@ -65,7 +65,18 @@
65
  atts['skip'] = atts['limit'] * (split.pop() - 1);
66
  }
67
 
68
- retrieveGallery(atts, target);
 
 
 
 
 
 
 
 
 
 
 
69
  e.preventDefault();
70
  });
71
  }
@@ -94,13 +105,16 @@
94
  * Requests a gallery generated with the given attributes to populate the given target element.
95
  * @param atts array The gallery shortcode attributes.
96
  * @param target element The element to be updated with the AJAX HTML response.
 
97
  */
98
- function retrieveGallery(atts, target) {
99
  // TODO: Cache already-retrieved gallery pages. Need to be careful not to keep too many at a time
100
  // (could consume a lot of memory) & handle caching pages for multiple galleries on a single pages.
101
  if ( typeof atts['id'] === 'undefined' ) {
102
  atts['id'] = wp.media.dgDefaults.id;
103
  }
 
 
104
  $.post(ajaxurl, { action: 'dg_generate_gallery', atts: atts }, function(html) {
105
  var parsedHtml = $($.parseHTML(html));
106
  if ( is_editor && !thumber_pointer_shown && parsedHtml.find(thumber_exts_sel).length ) {
@@ -108,9 +122,16 @@
108
  $('#insert-media-button').trigger('ready.dg');
109
  }
110
 
 
111
  target.replaceWith(parsedHtml);
112
  sizeGalleryIcons(parsedHtml);
113
  resetPendingIcons();
 
 
 
 
 
 
114
  });
115
  }
116
 
@@ -132,7 +153,7 @@
132
  idBatch.push(ids[i]);
133
  }
134
 
135
- if (idBatch.length != 0) {
136
  // request the next batch of icons
137
  $.ajax({
138
  type: 'POST',
65
  atts['skip'] = atts['limit'] * (split.pop() - 1);
66
  }
67
 
68
+ retrieveGallery(atts, target, function (gallery) {
69
+ var adminBarHeight = $('#wpadminbar').height() || 0;
70
+ var targetTop = gallery.offset().top - adminBarHeight;
71
+
72
+ // scroll to gallery if top is not visible
73
+ if ( $(document).scrollTop() > targetTop ) {
74
+ $('html, body').animate({
75
+ scrollTop: targetTop - 20
76
+ }, 'slow');
77
+ }
78
+ });
79
+
80
  e.preventDefault();
81
  });
82
  }
105
  * Requests a gallery generated with the given attributes to populate the given target element.
106
  * @param atts array The gallery shortcode attributes.
107
  * @param target element The element to be updated with the AJAX HTML response.
108
+ * @param callback function If provided, will be invoked once new gallery content is loaded with the updated element passed in.
109
  */
110
+ function retrieveGallery(atts, target, callback) {
111
  // TODO: Cache already-retrieved gallery pages. Need to be careful not to keep too many at a time
112
  // (could consume a lot of memory) & handle caching pages for multiple galleries on a single pages.
113
  if ( typeof atts['id'] === 'undefined' ) {
114
  atts['id'] = wp.media.dgDefaults.id;
115
  }
116
+
117
+ // request new gallery page from server
118
  $.post(ajaxurl, { action: 'dg_generate_gallery', atts: atts }, function(html) {
119
  var parsedHtml = $($.parseHTML(html));
120
  if ( is_editor && !thumber_pointer_shown && parsedHtml.find(thumber_exts_sel).length ) {
122
  $('#insert-media-button').trigger('ready.dg');
123
  }
124
 
125
+ // update gallery element with new content
126
  target.replaceWith(parsedHtml);
127
  sizeGalleryIcons(parsedHtml);
128
  resetPendingIcons();
129
+
130
+ // invoke callback if provided
131
+ if ( typeof callback !== 'undefined' ) {
132
+ // get the new DOM element
133
+ callback($('#' + target.attr('id')));
134
+ }
135
  });
136
  }
137
 
153
  idBatch.push(ids[i]);
154
  }
155
 
156
+ if (idBatch.length !== 0) {
157
  // request the next batch of icons
158
  $.ajax({
159
  type: 'POST',
assets/js/gallery.min.js CHANGED
@@ -1,6 +1,7 @@
1
  var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,d,c){a instanceof String&&(a=String(a));for(var f=a.length,e=0;e<f;e++){var g=a[e];if(d.call(c,g,e,a))return{i:e,v:g}}return{i:-1,v:void 0}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,c){a!=Array.prototype&&a!=Object.prototype&&(a[d]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};
2
  $jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,d,c,f){if(d){c=$jscomp.global;a=a.split(".");for(f=0;f<a.length-1;f++){var e=a[f];e in c||(c[e]={});c=c[e]}a=a[a.length-1];f=c[a];d=d(f);d!=f&&null!=d&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:d})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6-impl","es3");
3
  (function(a){function d(b){(b||a(".document-gallery[data-icon-width]")).each(function(){var b=a(this).data("icon-width");"undefined"!==typeof b&&a(this).find(".document-icon").width(b+"%")})}function c(){l&&tinymce.PluginManager.add("dg",function(b,c){b.on("LoadContent update.dg undo",function(b){a(b.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function(){g("object"===typeof a(this).data("shortcode")?a(this).data("shortcode"):JSON.parse(decodeURIComponent(a(this).data("shortcode"))),
4
- a(this))})})})}function f(){a("body").delegate(".dg-paginate-wrapper .paginate a","click",function(b){var c=a(this).closest(".dg-paginate-wrapper"),d=c.data("shortcode");d.skip=0;var e=a(this).attr("href").split("#")[1].split("=");2<=e.length&&(d.skip=d.limit*(e.pop()-1));g(d,c);b.preventDefault()})}function e(){h=[];k=0;a(".document-gallery img[data-id]").each(function(){var b=a(this).data("id");-1===a.inArray(b,h)&&h.push(b)});m()}function g(b,c){"undefined"===typeof b.id&&(b.id=wp.media.dgDefaults.id);
5
- a.post(ajaxurl,{action:"dg_generate_gallery",atts:b},function(b){b=a(a.parseHTML(b));l&&!n&&b.find(p).length&&(n=!0,a("#insert-media-button").trigger("ready.dg"));c.replaceWith(b);d(b);e()})}function m(){for(var b=[];k<h.length&&4!==b.length;k++)b.push(h[k]);0!=b.length&&a.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"dg_generate_icons",ids:b},success:q,error:function(a){console.error(a.responseText)}})}function q(b){for(var c in b)if(b.hasOwnProperty(c)){var d=a('.document-gallery img[data-id="'+
6
- c+'"]');d.removeAttr("data-id");(function(c,d){d.fadeOut("fast",function(){a(this).attr("src",b[c]);a(this).fadeIn("fast")})})(c,d)}m()}var h,k,l,p='.document-gallery [data-ext="'+"doc docx ppt pptx xls xlsx pub vsd vsdx".split(" ").join('"],[data-ext="')+'"]',n=!1;a(document).ready(function(){l="undefined"!==typeof tinymce;d();e();c();f()})})(jQuery);
 
1
  var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,d,c){a instanceof String&&(a=String(a));for(var f=a.length,e=0;e<f;e++){var g=a[e];if(d.call(c,g,e,a))return{i:e,v:g}}return{i:-1,v:void 0}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,c){a!=Array.prototype&&a!=Object.prototype&&(a[d]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};
2
  $jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,d,c,f){if(d){c=$jscomp.global;a=a.split(".");for(f=0;f<a.length-1;f++){var e=a[f];e in c||(c[e]={});c=c[e]}a=a[a.length-1];f=c[a];d=d(f);d!=f&&null!=d&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:d})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6-impl","es3");
3
  (function(a){function d(b){(b||a(".document-gallery[data-icon-width]")).each(function(){var b=a(this).data("icon-width");"undefined"!==typeof b&&a(this).find(".document-icon").width(b+"%")})}function c(){l&&tinymce.PluginManager.add("dg",function(b,c){b.on("LoadContent update.dg undo",function(b){a(b.target.contentDocument).find('[data-wpview-type="dg"] [data-shortcode]').each(function(){g("object"===typeof a(this).data("shortcode")?a(this).data("shortcode"):JSON.parse(decodeURIComponent(a(this).data("shortcode"))),
4
+ a(this))})})})}function f(){a("body").delegate(".dg-paginate-wrapper .paginate a","click",function(b){var c=a(this).closest(".dg-paginate-wrapper"),d=c.data("shortcode");d.skip=0;var e=a(this).attr("href").split("#")[1].split("=");2<=e.length&&(d.skip=d.limit*(e.pop()-1));g(d,c,function(b){var c=a("#wpadminbar").height()||0;b=b.offset().top-c;a(document).scrollTop()>b&&a("html, body").animate({scrollTop:b-20},"slow")});b.preventDefault()})}function e(){h=[];k=0;a(".document-gallery img[data-id]").each(function(){var b=
5
+ a(this).data("id");-1===a.inArray(b,h)&&h.push(b)});m()}function g(b,c,f){"undefined"===typeof b.id&&(b.id=wp.media.dgDefaults.id);a.post(ajaxurl,{action:"dg_generate_gallery",atts:b},function(b){b=a(a.parseHTML(b));l&&!n&&b.find(p).length&&(n=!0,a("#insert-media-button").trigger("ready.dg"));c.replaceWith(b);d(b);e();"undefined"!==typeof f&&f(a("#"+c.attr("id")))})}function m(){for(var b=[];k<h.length&&4!==b.length;k++)b.push(h[k]);0!==b.length&&a.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"dg_generate_icons",
6
+ ids:b},success:q,error:function(a){console.error(a.responseText)}})}function q(b){for(var c in b)if(b.hasOwnProperty(c)){var d=a('.document-gallery img[data-id="'+c+'"]');d.removeAttr("data-id");(function(c,d){d.fadeOut("fast",function(){a(this).attr("src",b[c]);a(this).fadeIn("fast")})})(c,d)}m()}var h,k,l,p='.document-gallery [data-ext="'+"doc docx ppt pptx xls xlsx pub vsd vsdx".split(" ").join('"],[data-ext="')+'"]',n=!1;a(document).ready(function(){l="undefined"!==typeof tinymce;d();e();c();
7
+ f()})})(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.4.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.4.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.4.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.4.2' );
16
 
17
  if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
18
  add_action( 'admin_notices', 'dg_php_lt_three' );
inc/class-document.php CHANGED
@@ -13,7 +13,7 @@ class DG_Document {
13
  *=========================================================================*/
14
 
15
  // general document data
16
- private $description, $gallery, $ID, $link, $title, $title_attribute, $path, $extension, $size, $date, $time;
17
 
18
  /*==========================================================================
19
  * GETTERS
@@ -111,6 +111,7 @@ class DG_Document {
111
  $this->size = ($size !== false) ? size_format( $size ) : '0';
112
  $this->date = get_post_time( get_option( 'date_format' ), false, $this->ID );
113
  $this->time = get_post_time( get_option( 'time_format' ), false, $this->ID );
 
114
  }
115
 
116
  /*==========================================================================
@@ -147,8 +148,8 @@ class DG_Document {
147
  $thumb = DG_DefaultThumber::init()->getThumbnail( $this->ID );
148
  }
149
 
150
- $repl = array( $this->link, $thumb, $this->title_attribute, $this->title, $target, $this->extension, $this->size, $this->path, $data, $this->date, $this->time );
151
- $find = array( '%link%', '%img%', '%title_attribute%', '%title%', '%target%', '%extension%', '%size%', '%path%', '%data%', '%date%', '%time%' );
152
 
153
  // if descriptions then add filterable tag and value to replaced tag
154
  if ( $this->gallery->useDescriptions() ) {
13
  *=========================================================================*/
14
 
15
  // general document data
16
+ private $description, $gallery, $ID, $link, $title, $title_attribute, $path, $extension, $size, $date, $time, $author;
17
 
18
  /*==========================================================================
19
  * GETTERS
111
  $this->size = ($size !== false) ? size_format( $size ) : '0';
112
  $this->date = get_post_time( get_option( 'date_format' ), false, $this->ID );
113
  $this->time = get_post_time( get_option( 'time_format' ), false, $this->ID );
114
+ $this->author = $attachment->post_author;
115
  }
116
 
117
  /*==========================================================================
148
  $thumb = DG_DefaultThumber::init()->getThumbnail( $this->ID );
149
  }
150
 
151
+ $repl = array( $this->link, $thumb, $this->title_attribute, $this->title, $target, $this->extension, $this->size, $this->path, $data, $this->date, $this->time, $this->author );
152
+ $find = array( '%link%', '%img%', '%title_attribute%', '%title%', '%target%', '%extension%', '%size%', '%path%', '%data%', '%date%', '%time%', '%author%' );
153
 
154
  // if descriptions then add filterable tag and value to replaced tag
155
  if ( $this->gallery->useDescriptions() ) {