Document Gallery - Version 3.0

Version Description

  • Notice: Google Drive support has been removed as recent changes to how the service functions have made it no longer useful in thumbnail generation. A replacement for supporting MS Office filetypes (and other filetypes not supported in existing options) is in the works and we hope to release it soon.
  • Enhancement: Thumbnails can now be manually overridden. To do this, either navigate to Dashboard -> Settings -> Document Gallery -> Thumbnail Management and add the image to the target attachment, or set the thumbnail in the attachment edit window.
  • Enhancement: Users can now specify the number of columns for a gallery.
  • Enhancement: Users can now create galleries with specific filetype(s) by using the mime_types option. Thanks for suggesting this functionality, mepmepmep!
  • Enhancement: Options to include or exclude specific attachments in a gallery have been added.
  • Enhancement: The document gallery CSS has been modified to make all icon images responsive. We've also added the dg_use_default_gallery_style so that developers may completely disabled Document Gallery CSS and replace it with his/her own.
  • Deprecation: The deprecated dg_doc_icon filter has been removed. Developers should use dg_icon_template.
  • Deprecation: The localpost option has been deprecated and will be removed at a future date. If you are currently using localpost=false then it should be replaced by id=-1.
Download this release

Release Info

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

Code changes from version 3.0.0-beta to 3.0

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dan.rossiter, demur
3
  Tags: attachments, thumbnail, documents, gallery, MS office, 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: 3.6
6
- Tested up to: 4.1
7
- Stable tag: 2.3.7
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -432,6 +432,10 @@ ideas for future Document Gallery development, take a look at our
432
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
433
 
434
  = 3.0 =
 
 
 
 
435
  * **Enhancement:** Thumbnails can now be manually overridden. To do this, either navigate to
436
  `Dashboard -> Settings -> Document Gallery -> Thumbnail Management` and add the image
437
  to the target attachment, or set the thumbnail in the attachment edit window.
@@ -442,7 +446,7 @@ ideas for future Document Gallery development, take a look at our
442
  * **Enhancement:** Options to `include` or `exclude` specific attachments in a gallery have been added.
443
  * **Enhancement:** The document gallery CSS has been modified to make all icon images responsive.
444
  We've also added the `dg_use_default_gallery_style` so that developers may completely disabled
445
- Document Gallery styles and replace it with their own.
446
  * **Deprecation:** The deprecated `dg_doc_icon` filter has been removed. Developers should use
447
  `dg_icon_template`.
448
  * **Deprecation:** The `localpost` option has been deprecated and will be removed at a future date.
3
  Tags: attachments, thumbnail, documents, gallery, MS office, 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: 3.6
6
+ Tested up to: 4.1.1
7
+ Stable tag: 3.0
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
432
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
433
 
434
  = 3.0 =
435
+ * **Notice:** Google Drive support has been removed as recent changes to how the service functions
436
+ have made it no longer useful in thumbnail generation. A replacement for supporting MS Office
437
+ filetypes (and other filetypes not supported in existing options) is in the works and we hope
438
+ to release it soon.
439
  * **Enhancement:** Thumbnails can now be manually overridden. To do this, either navigate to
440
  `Dashboard -> Settings -> Document Gallery -> Thumbnail Management` and add the image
441
  to the target attachment, or set the thumbnail in the attachment edit window.
446
  * **Enhancement:** Options to `include` or `exclude` specific attachments in a gallery have been added.
447
  * **Enhancement:** The document gallery CSS has been modified to make all icon images responsive.
448
  We've also added the `dg_use_default_gallery_style` so that developers may completely disabled
449
+ Document Gallery CSS and replace it with his/her own.
450
  * **Deprecation:** The deprecated `dg_doc_icon` filter has been removed. Developers should use
451
  `dg_icon_template`.
452
  * **Deprecation:** The `localpost` option has been deprecated and will be removed at a future date.
admin/class-admin.php CHANGED
@@ -579,6 +579,31 @@ class DG_Admin {
579
  $responseArr['result'] = true;
580
  $responseArr['deleted'] = $deleted;
581
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
582
  // Thumbnail file manual refresh (one at a time)
583
  // upload value is a marker
584
  elseif ( isset($values['upload']) && isset($_FILES['file']) && isset($ret['thumber']['thumbs'][$ID]) ) {
@@ -862,18 +887,27 @@ class DG_Admin {
862
  $offset = ($sheet - 1) * $limit;
863
 
864
  $att_ids = array_slice($att_ids, $offset, $limit);
865
- $atts = get_posts(
866
- array(
867
- 'post_type' => 'any',
868
- 'post_status' => 'any',
869
- 'numberposts' => -1,
870
- 'post__in' => $att_ids,
871
- 'orderby' => 'post__in'
872
- ));
 
 
 
 
 
 
873
  $titles = array();
 
874
  foreach ($atts as $att) {
875
  $path_parts = pathinfo($att->guid);
876
- $titles[$att->ID] = $att->post_title.'.'.$path_parts['extension'];
 
 
877
  }
878
  unset($atts);
879
 
@@ -884,6 +918,7 @@ class DG_Admin {
884
  '</th>'.
885
  '<th scope="col" class="manage-column column-icon">'.__('Thumbnail', 'document-gallery').'</th>'.
886
  '<th scope="col" class="manage-column column-title '.(($orderby != 'title')?'sortable desc':'sorted '.$order).'"><a href="?'.http_build_query(array_merge($URL_params, array('orderby'=>'title','order'=>(($orderby != 'title')?'asc':(($order == 'asc')?'desc':'asc'))))).'"><span>'.__('File name', 'document-gallery').'</span><span class="sorting-indicator"></span></th>'.
 
887
  '<th scope="col" class="manage-column column-thumbupload"></th>'.
888
  '<th scope="col" class="manage-column column-date '.(($orderby != 'date')?'sortable asc':'sorted '.$order).'"><a href="?'.http_build_query(array_merge($URL_params, array('orderby'=>'date','order'=>(($orderby != 'date')?'desc':(($order == 'asc')?'desc':'asc'))))).'"><span>'.__('Date', 'document-gallery').'</span><span class="sorting-indicator"></span></th>'.
889
  '</tr>';
@@ -927,14 +962,16 @@ class DG_Admin {
927
 
928
  $icon = isset($v['thumb_url']) ? $v['thumb_url'] : DG_Thumber::getDefaultThumbnail($v['thumb_id']);
929
  $title = isset($titles[$v['thumb_id']]) ? $titles[$v['thumb_id']] : '';
 
 
930
  $date = DocumentGallery::localDateTimeFromTimestamp($v['timestamp']);
931
 
932
  echo '<tr data-entry="'.$v['thumb_id'].'"><td scope="row" class="check-column"><input type="checkbox" class="cb-ids" name="' . DG_OPTION_NAME . '[ids][]" value="' .
933
  $v['thumb_id'].'"></td><td class="column-icon media-icon"><img src="' .
934
  $icon.'" />'.'</td><td class="title column-title">' .
935
  ($title ? '<strong><a href="' . home_url('/?attachment_id='.$v['thumb_id']).'" target="_blank" title="'.__('View', 'document-gallery').' \'' .
936
- $title.'\' '.__('attachment page', 'document-gallery').'">'.$title.'</a></strong>' : __('Attachment not found', 'document-gallery')) .
937
- '</td><td class="column-thumbupload">' .
938
  '<span class="manual-download">' .
939
  '<span class="dashicons dashicons-upload"></span>' .
940
  '<span class="html5dndmarker">Drop file here<span> or </span></span>' .
@@ -1081,8 +1118,14 @@ class DG_Admin {
1081
  $i = 0;
1082
  foreach ($log_list as $v) {
1083
  $date = DocumentGallery::localDateTimeFromTimestamp($v[0]);
1084
- $v[2] = preg_replace('/ (attachment #)(\d+) /', ' <a href="' . home_url() . '/?attachment_id=\2" target="_blank">\1<strong>\2</strong></a> ', $v[2]);
 
 
 
 
1085
  $v[2] = preg_replace('/^(\(\w+::\w+\)) /', '<strong>\1</strong> ', $v[2]);
 
 
1086
  $v[2] = preg_replace('/(\(?\w+::\w+\)?)/m', '<i>\1</i>', $v[2]);
1087
 
1088
  echo '<tr><td class="date column-date" data-sort-value="'.$v[0].'"><span class="logLabel date">'.$date.'</span></td>' .
579
  $responseArr['result'] = true;
580
  $responseArr['deleted'] = $deleted;
581
  }
582
+
583
+ // Attachment title update
584
+ // title value is a marker
585
+ elseif ( isset($values['title']) && $ID != -1 ) {
586
+ $attachment = array(
587
+ 'ID' => $ID,
588
+ 'post_title' => rawurldecode(addslashes($values['title']))
589
+ );
590
+ if ( wp_update_post( $attachment ) ) {
591
+ $responseArr['result'] = true;
592
+ }
593
+ }
594
+
595
+ // Attachment description update
596
+ // description value is a marker
597
+ elseif ( isset($values['description']) && $ID != -1 ) {
598
+ $attachment = array(
599
+ 'ID' => $ID,
600
+ 'post_content' => rawurldecode(addslashes($values['description']))
601
+ );
602
+ if ( wp_update_post( $attachment ) ) {
603
+ $responseArr['result'] = true;
604
+ }
605
+ }
606
+
607
  // Thumbnail file manual refresh (one at a time)
608
  // upload value is a marker
609
  elseif ( isset($values['upload']) && isset($_FILES['file']) && isset($ret['thumber']['thumbs'][$ID]) ) {
887
  $offset = ($sheet - 1) * $limit;
888
 
889
  $att_ids = array_slice($att_ids, $offset, $limit);
890
+
891
+ // https://core.trac.wordpress.org/ticket/12212
892
+ $atts = array();
893
+ if (!empty($att_ids)) {
894
+ $atts = get_posts(
895
+ array(
896
+ 'post_type' => 'any',
897
+ 'post_status' => 'any',
898
+ 'numberposts' => -1,
899
+ 'post__in' => $att_ids,
900
+ 'orderby' => 'post__in'
901
+ ));
902
+ }
903
+
904
  $titles = array();
905
+ $contents = array();
906
  foreach ($atts as $att) {
907
  $path_parts = pathinfo($att->guid);
908
+ $titles[$att->ID] = $att->post_title;
909
+ $types[$att->ID] = $path_parts['extension'];
910
+ $contents[$att->ID] = $att->post_content;
911
  }
912
  unset($atts);
913
 
918
  '</th>'.
919
  '<th scope="col" class="manage-column column-icon">'.__('Thumbnail', 'document-gallery').'</th>'.
920
  '<th scope="col" class="manage-column column-title '.(($orderby != 'title')?'sortable desc':'sorted '.$order).'"><a href="?'.http_build_query(array_merge($URL_params, array('orderby'=>'title','order'=>(($orderby != 'title')?'asc':(($order == 'asc')?'desc':'asc'))))).'"><span>'.__('File name', 'document-gallery').'</span><span class="sorting-indicator"></span></th>'.
921
+ '<th scope="col" class="manage-column column-description">'.__('Description', 'document-gallery').'</th>'.
922
  '<th scope="col" class="manage-column column-thumbupload"></th>'.
923
  '<th scope="col" class="manage-column column-date '.(($orderby != 'date')?'sortable asc':'sorted '.$order).'"><a href="?'.http_build_query(array_merge($URL_params, array('orderby'=>'date','order'=>(($orderby != 'date')?'desc':(($order == 'asc')?'desc':'asc'))))).'"><span>'.__('Date', 'document-gallery').'</span><span class="sorting-indicator"></span></th>'.
924
  '</tr>';
962
 
963
  $icon = isset($v['thumb_url']) ? $v['thumb_url'] : DG_Thumber::getDefaultThumbnail($v['thumb_id']);
964
  $title = isset($titles[$v['thumb_id']]) ? $titles[$v['thumb_id']] : '';
965
+ $type = $types[$v['thumb_id']];
966
+ $description = $contents[$v['thumb_id']];
967
  $date = DocumentGallery::localDateTimeFromTimestamp($v['timestamp']);
968
 
969
  echo '<tr data-entry="'.$v['thumb_id'].'"><td scope="row" class="check-column"><input type="checkbox" class="cb-ids" name="' . DG_OPTION_NAME . '[ids][]" value="' .
970
  $v['thumb_id'].'"></td><td class="column-icon media-icon"><img src="' .
971
  $icon.'" />'.'</td><td class="title column-title">' .
972
  ($title ? '<strong><a href="' . home_url('/?attachment_id='.$v['thumb_id']).'" target="_blank" title="'.__('View', 'document-gallery').' \'' .
973
+ $title.'\' '.__('attachment page', 'document-gallery').'"><span class="editable-title">'.$title.'</span> <sup>'.$type.'</sup></a></strong>' : __('Attachment not found', 'document-gallery')) .
974
+ '<span class="dashicons dashicons-edit"></span><span class="edit-controls"><span class="dashicons dashicons-yes"></span> <span class="dashicons dashicons-no"></span></span></td><td class="column-description"><div class="editable-description">'.$description.'</div><span class="dashicons dashicons-edit"></span><span class="edit-controls"><span class="dashicons dashicons-yes"></span> <span class="dashicons dashicons-no"></span></span>'. '</td><td class="column-thumbupload">' .
975
  '<span class="manual-download">' .
976
  '<span class="dashicons dashicons-upload"></span>' .
977
  '<span class="html5dndmarker">Drop file here<span> or </span></span>' .
1118
  $i = 0;
1119
  foreach ($log_list as $v) {
1120
  $date = DocumentGallery::localDateTimeFromTimestamp($v[0]);
1121
+
1122
+ // convert attachment names to links
1123
+ $v[2] = preg_replace('/[ ^](attachment #)(\d+)[., ]/i', ' <a href="' . home_url() . '/?attachment_id=\2" target="_blank">\1<strong>\2</strong></a> ', $v[2]);
1124
+
1125
+ // bold the place where log entry was submitted
1126
  $v[2] = preg_replace('/^(\(\w+::\w+\)) /', '<strong>\1</strong> ', $v[2]);
1127
+
1128
+ // italicize any function references within log entry
1129
  $v[2] = preg_replace('/(\(?\w+::\w+\)?)/m', '<i>\1</i>', $v[2]);
1130
 
1131
  echo '<tr><td class="date column-date" data-sort-value="'.$v[0].'"><span class="logLabel date">'.$date.'</span></td>' .
assets/css/admin.css CHANGED
@@ -1,3 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  div.thumbs-list-wrapper, div.log-list-wrapper{
2
  text-align:center;
3
  margin-top: 1.5em;
@@ -195,7 +227,7 @@ tr.selected:hover{
195
  float: right;
196
  padding-right: 15px;
197
  }
198
- .levelSelector > * {
199
  -webkit-touch-callout: none;
200
  -webkit-user-select: none;
201
  -khtml-user-select: none;
@@ -347,4 +379,92 @@ textarea[readonly], input[readonly], select[readonly] {
347
  }
348
  #document_gallery_gen_box h3 span i b {
349
  font-weight: 500;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  }
1
+ @media screen and (max-width: 782px) {
2
+ .column-title {
3
+ width: 150px;
4
+ }
5
+ .column-date {
6
+ display: table-cell !important;
7
+ width: auto !important;
8
+ }
9
+ .nav-tab-wrapper {
10
+ padding-left: 5px !important;
11
+ padding-right: 5px !important;
12
+ }
13
+ .top .tablenav-pages {
14
+ display: none;
15
+ }
16
+ .bottom .tablenav-pages {
17
+ width: auto !important;
18
+ margin-top: 0px !important;
19
+ }
20
+ .bottom .displaying-num {
21
+ position: inherit !important;
22
+ }
23
+ }
24
+ @media screen and (max-width: 979px) {
25
+ .column-thumbupload {
26
+ display: none;
27
+ }
28
+ .thumbs-list-wrapper {
29
+ margin-top: 0px !important;
30
+ }
31
+ }
32
+
33
  div.thumbs-list-wrapper, div.log-list-wrapper{
34
  text-align:center;
35
  margin-top: 1.5em;
227
  float: right;
228
  padding-right: 15px;
229
  }
230
+ .levelSelector > *, .dashicons {
231
  -webkit-touch-callout: none;
232
  -webkit-user-select: none;
233
  -khtml-user-select: none;
379
  }
380
  #document_gallery_gen_box h3 span i b {
381
  font-weight: 500;
382
+ }
383
+ th.column-description {
384
+ text-align: left !important;
385
+ }
386
+ .editable-description {
387
+ max-height: 70px;
388
+ overflow-y: auto;
389
+ text-align: justify;
390
+ }
391
+ .column-description textarea {
392
+ height: 65px;
393
+ width: 100%;
394
+ }
395
+ td.column-title, td.column-description {
396
+ position: relative;
397
+ }
398
+ td.column-title.trans, td.column-description.trans {
399
+ background-color: inherit;
400
+ transition: background-color 1s linear;
401
+ -moz-transition: background-color 1s linear;
402
+ -o-transition: background-color 1s linear;
403
+ -webkit-transition: background-color 1s linear;
404
+ }
405
+ td .dashicons-edit, td .edit-controls {
406
+ display: none;
407
+ position: absolute;
408
+ top: 5px;
409
+ right: 12px;
410
+ }
411
+ td .dashicons-edit, .edit-controls .dashicons-yes, .edit-controls .dashicons-no {
412
+ z-index: 100;
413
+ font-size: x-large;
414
+ cursor: pointer;
415
+ }
416
+ td .dashicons-edit {
417
+ color: #0074A2;
418
+ }
419
+ .edit-controls:hover {
420
+ opacity: 1;
421
+ }
422
+ .edit-controls {
423
+ opacity: 0.1;
424
+ }
425
+ .edit-controls .dashicons-yes {
426
+ color: green;
427
+ }
428
+ .edit-controls .dashicons-no {
429
+ color: red;
430
+ }
431
+ .responseSuccess {
432
+ background-color: greenyellow !important;
433
+ }
434
+ .responseFail {
435
+ background-color: crimson !important;
436
+ }
437
+ td.column-title .dashicons-edit, td.column-description .dashicons-edit {
438
+ display: block;
439
+ overflow: hidden;
440
+ height: 0;
441
+ opacity: 0;
442
+ transition: opacity 1s ease-out;
443
+ -moz-transition: opacity 1s ease-out;
444
+ -o-transition: opacity 1s ease-out;
445
+ -webkit-transition: opacity 1s ease-out;
446
+ }
447
+ td.column-title:hover .dashicons-edit, td.column-description:hover .dashicons-edit {
448
+ opacity: 1;
449
+ height: auto;
450
+ }
451
+ td.column-title input {
452
+ width: 75%;
453
+ }
454
+ .manual-download {
455
+ display: block;
456
+ text-align: center;
457
+ }
458
+ .editable-description::-webkit-scrollbar, .column-description textarea::-webkit-scrollbar {
459
+ width: 5px;
460
+ height: 5px;
461
+ }
462
+ .editable-description::-webkit-scrollbar-track-piece, .column-description textarea::-webkit-scrollbar-track-piece {
463
+ background-color: #ffffff;
464
+ -webkit-border-radius: 5px;
465
+ }
466
+ .editable-description::-webkit-scrollbar-thumb:vertical, .column-description textarea::-webkit-scrollbar-thumb:vertical {
467
+ height: 5px;
468
+ background-color: #9b9b9b;;
469
+ -webkit-border-radius: 5px;
470
  }
assets/js/admin.js CHANGED
@@ -258,4 +258,98 @@ jQuery(document).ready(function(){
258
  if (!('draggable' in document.createElement('span'))) {
259
  jQuery('.html5dndmarker').hide();
260
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  });
258
  if (!('draggable' in document.createElement('span'))) {
259
  jQuery('.html5dndmarker').hide();
260
  }
261
+
262
+ jQuery( 'td .dashicons-edit' ).click(function() {
263
+ var cell = jQuery( this ).closest('td');
264
+ if (cell.hasClass('column-title')) {
265
+ if (cell.find('a').css('display') == 'none') {
266
+ return;
267
+ }
268
+ cell.find('a').hide().after('<input type="text" value="'+cell.find('.editable-title').text()+'">');
269
+ cell.find('input').focus();
270
+ } else if (cell.hasClass('column-description')) {
271
+ if (cell.find('.editable-description').css('display') == 'none') {
272
+ return;
273
+ }
274
+ cell.find('.editable-description').hide().after('<textarea>'+cell.find('.editable-description').text()+'</textarea>');
275
+ cell.find('textarea').focus();
276
+ } else {
277
+ return;
278
+ }
279
+ jQuery( this ).css('visibility', 'hidden');
280
+ cell.find('.edit-controls').show();
281
+ });
282
+ jQuery( '.edit-controls .dashicons-no' ).click(function() {
283
+ var cell = jQuery( this ).closest('td');
284
+ if (cell.hasClass('column-title')) {
285
+ if (cell.find('a').css('display') != 'none') {
286
+ return;
287
+ }
288
+ cell.find('input').fadeOut('fast', function(){jQuery(this).remove();cell.find('a').fadeIn('fast');});
289
+ } else if (cell.hasClass('column-description')) {
290
+ if (cell.find('.editable-description').css('display') != 'none') {
291
+ return;
292
+ }
293
+ cell.find('textarea').fadeOut('fast', function(){jQuery(this).remove();cell.find('.editable-description').fadeIn('fast');});
294
+ } else {
295
+ return;
296
+ }
297
+ jQuery( this ).closest('.edit-controls').hide();
298
+ cell.find('.dashicons-edit').css('visibility', 'visible');
299
+ });
300
+ jQuery( '.edit-controls .dashicons-yes' ).click(function() {
301
+ var cell = jQuery( this ).closest('td');
302
+ var entry = jQuery(this).closest('tr').data('entry')
303
+ var target = jQuery('#tab-Thumbnail').attr('action');
304
+ var formData= new FormData(jQuery('[data-entry='+entry+']').closest('form')[0]);
305
+ formData.append('document_gallery[entry]', entry);
306
+ formData.append('document_gallery[ajax]', 'true');
307
+ var newContent, updateGoal;
308
+ if (cell.hasClass('column-title')) {
309
+ newContent = cell.find('input');
310
+ updateGoal = cell.find('.editable-title');
311
+ formData.append('document_gallery[title]', encodeURIComponent(newContent.val()));
312
+ } else if (cell.hasClass('column-description')) {
313
+ newContent = cell.find('textarea');
314
+ updateGoal = cell.find('.editable-description');
315
+ formData.append('document_gallery[description]', encodeURIComponent(newContent.val()));
316
+ } else {
317
+ return;
318
+ }
319
+ if (newContent.val()==updateGoal.text()) {
320
+ jQuery( this ).next('.dashicons-no').click();
321
+ return;
322
+ }
323
+ var xhr = new XMLHttpRequest();
324
+ xhr.open('POST', target);
325
+ //var theImg = jQuery('[data-entry='+entry+']').find('.column-icon img');
326
+ xhr.onreadystatechange = function() {
327
+ if (xhr.readyState == 4) {
328
+ cell.addClass('trans');
329
+ if (xhr.responseText.indexOf("\n") == -1) {
330
+ eval('var response = ' + xhr.responseText + ';');
331
+ if (response.result) {
332
+ updateGoal.text(newContent.val());
333
+ cell.find('.dashicons-no').click();
334
+ cell.addClass('responseSuccess').delay(2000).queue(function(){ jQuery(this).removeClass('responseSuccess').dequeue();}).delay(1100).queue(function(){ jQuery(this).removeClass('trans').dequeue();});
335
+ } else {
336
+ shake(newContent);
337
+ cell.addClass('responseFail').delay(1100).queue(function(){ jQuery(this).removeClass('responseFail').dequeue();}).delay(1100).queue(function(){ jQuery(this).removeClass('trans').dequeue();});
338
+ }
339
+ } else {
340
+ shake(newContent);
341
+ cell.addClass('responseFail').delay(1100).queue(function(){ jQuery(this).removeClass('responseFail').dequeue();}).delay(1100).queue(function(){ jQuery(this).removeClass('trans').dequeue();});
342
+ console.log('Invalid response from server:');
343
+ console.log(xhr.responseText);
344
+ }
345
+ }
346
+ }
347
+ xhr.send(formData);
348
+ });
349
+ function shake(target) {
350
+ var offset = 4;
351
+ for( var i = 0; i < 6; i++ ) {
352
+ target.animate( { 'margin-left': "+=" + ( offset = -offset ) + 'px' }, 50);
353
+ }
354
+ }
355
  });
document-gallery.php CHANGED
@@ -5,14 +5,14 @@ defined('WPINC') OR exit;
5
  Plugin Name: Document Gallery
6
  Plugin URI: http://wordpress.org/extend/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
- Version: 3.0.0-beta
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv2
12
  Text Domain: document-gallery
13
  */
14
 
15
- define('DG_VERSION', '3.0.0-beta');
16
 
17
  // define helper paths & URLs
18
  define('DG_BASENAME', plugin_basename(__FILE__));
5
  Plugin Name: Document Gallery
6
  Plugin URI: http://wordpress.org/extend/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
+ Version: 3.0
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv2
12
  Text Domain: document-gallery
13
  */
14
 
15
+ define('DG_VERSION', '3.0');
16
 
17
  // define helper paths & URLs
18
  define('DG_BASENAME', plugin_basename(__FILE__));
inc/class-image-editor-imagick.php CHANGED
@@ -34,7 +34,7 @@ class DG_Image_Editor_Imagick extends WP_Image_Editor_Imagick {
34
  // set correct page number
35
  if (!is_wp_error($ret) && !is_null($this->pg)
36
  && is_callable(array($this->image, 'setIteratorIndex'))) {
37
- $err = __('Failed to set Imagick page number');
38
 
39
  // setIteratorIndex() should return false on failure, but I've found
40
  // reports of it throwing an error so handling both cases.
34
  // set correct page number
35
  if (!is_wp_error($ret) && !is_null($this->pg)
36
  && is_callable(array($this->image, 'setIteratorIndex'))) {
37
+ $err = __('Failed to set Imagick page number', 'document-gallery');
38
 
39
  // setIteratorIndex() should return false on failure, but I've found
40
  // reports of it throwing an error so handling both cases.
inc/class-setup.php CHANGED
@@ -114,7 +114,7 @@ class DG_Setup {
114
  global $dg_options;
115
 
116
  // do update
117
- if (!is_null($dg_options) && (isset($options['version']) || DG_VERSION !== $dg_options['meta']['version'])) {
118
  $blogs = array(null);
119
 
120
  if (is_multisite()) {
@@ -129,7 +129,7 @@ class DG_Setup {
129
  }
130
 
131
  /**
132
- * Runs when update is needed, updating the given blog. If blog is null,
133
  * active blog is updated.
134
  * @param int $blog Blog to update or null if updating current blog.
135
  */
114
  global $dg_options;
115
 
116
  // do update
117
+ if (!is_null($dg_options) && (isset($dg_options['version']) || DG_VERSION !== $dg_options['meta']['version'])) {
118
  $blogs = array(null);
119
 
120
  if (is_multisite()) {
129
  }
130
 
131
  /**
132
+ * Runs when update is needed, updating the given blog. If $blog is null,
133
  * active blog is updated.
134
  * @param int $blog Blog to update or null if updating current blog.
135
  */
inc/class-thumber.php CHANGED
@@ -691,11 +691,12 @@ class DG_Thumber {
691
  * with the ID(s), if such a thumbnails exists.
692
  *
693
  * @param int|array $ids
 
694
  */
695
  public static function deleteThumbMeta($ids) {
696
  $options = self::getOptions();
697
- $modified = false;
698
 
 
699
  foreach ((array)$ids as $id) {
700
  if (isset($options['thumbs'][$id])) {
701
  if (isset($options['thumbs'][$id]['thumber'])) {
@@ -703,11 +704,13 @@ class DG_Thumber {
703
  }
704
 
705
  unset($options['thumbs'][$id]);
706
- $modified = true;
707
  }
708
  }
709
 
710
- if ($modified) { self::setOptions($options); }
 
 
711
  }
712
 
713
  /**
691
  * with the ID(s), if such a thumbnails exists.
692
  *
693
  * @param int|array $ids
694
+ * @return array All IDs that were deleted -- some subset of IDs requested to be deleted.
695
  */
696
  public static function deleteThumbMeta($ids) {
697
  $options = self::getOptions();
 
698
 
699
+ $deleted = array();
700
  foreach ((array)$ids as $id) {
701
  if (isset($options['thumbs'][$id])) {
702
  if (isset($options['thumbs'][$id]['thumber'])) {
704
  }
705
 
706
  unset($options['thumbs'][$id]);
707
+ $deleted[] = $id;
708
  }
709
  }
710
 
711
+ if (count($deleted) > 0) { self::setOptions($options); }
712
+
713
+ return $deleted;
714
  }
715
 
716
  /**