Document Gallery - Version 3.5

Version Description

  • Enhancement: No more waiting a LONG time for your new gallery to load. If you create a new gallery and view it, rendering will complete immediately and the thumbnails will be generated after your gallery initially loads. This should provide a significantly improved user experience!
  • Enhancement: All JS and CSS files are now served compressed, making your WordPress that much faster!
Download this release

Release Info

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

Code changes from version 3.4.2 to 3.5

README.txt CHANGED
@@ -4,7 +4,7 @@ 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: 4.1
6
  Tested up to: 4.3
7
- Stable tag: 3.4.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -438,6 +438,12 @@ To see a list of features planned for the future as well as to propose your own
438
  ideas for future Document Gallery development, take a look at our
439
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
440
 
 
 
 
 
 
 
441
  = 3.4.2 =
442
  * **Bug Fix:** Resolves issues in handling manual thumbnail uploads that were introduced in `3.4`.
443
 
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.3
7
+ Stable tag: 3.5
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
438
  ideas for future Document Gallery development, take a look at our
439
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
440
 
441
+ = 3.5 =
442
+ * **Enhancement:** No more waiting a **LONG** time for your new gallery to load. If you create a new gallery and view
443
+ it, rendering will complete immediately and the thumbnails will be generated after your gallery initially loads.
444
+ This should provide a significantly improved user experience!
445
+ * **Enhancement:** All JS and CSS files are now served compressed, making your WordPress that much faster!
446
+
447
  = 3.4.2 =
448
  * **Bug Fix:** Resolves issues in handling manual thumbnail uploads that were introduced in `3.4`.
449
 
admin/class-admin.php CHANGED
@@ -114,7 +114,7 @@ class DG_Admin {
114
  public static function enqueueScriptsAndStyles( $hook ) {
115
  if ( in_array( $hook, array( DG_Admin::$hook, 'post.php', 'post-new.php' ), true ) ) {
116
  // Settings Page
117
- wp_enqueue_style( 'document-gallery-admin', DG_URL . 'assets/css/admin.css', null, DG_VERSION );
118
 
119
  // gracefully degrade for older WP versions
120
  if ( version_compare( get_bloginfo( 'version' ), '3.8', '<' ) ) { ?>
@@ -127,14 +127,14 @@ class DG_Admin {
127
  </style>
128
  <?php }
129
 
130
- wp_enqueue_script( 'document-gallery-admin', DG_URL . 'assets/js/admin.js', array( 'jquery' ), DG_VERSION, true );
131
  wp_localize_script( 'document-gallery-admin', 'dg_admin_vars', array( 'upload_limit' => wp_max_upload_size() ) );
132
  if ( $hook !== self::$hook ) { //if $hook is 'post.php' or 'post-new.php'
133
  wp_localize_script( 'document-gallery-admin', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
134
 
135
  // Media Manager
136
  global $dg_options;
137
- wp_enqueue_script( 'document-gallery-media-manager', DG_URL . 'assets/js/media_manager.js', array( 'media-views' ), DG_VERSION, true );
138
  wp_localize_script( 'document-gallery-media-manager', 'DGl10n', array(
139
  'documentGalleryMenuTitle' => __( 'Create Document Gallery', 'document-gallery' ),
140
  'documentGalleryButton' => __( 'Create a new Document Gallery', 'document-gallery' ),
@@ -469,20 +469,6 @@ class DG_Admin {
469
  'description' => __( 'Number of days to keep old log entries (0 disables purging).', 'document-gallery' )
470
  ) );
471
 
472
- add_settings_field(
473
- 'advanced_thumb_timeout', __( 'Thumbnail Generation Timeout', 'document-gallery' ),
474
- array( __CLASS__, 'renderTextField' ),
475
- DG_OPTION_NAME, 'advanced',
476
- array(
477
- 'label_for' => 'label_advanced_thumb_timeout',
478
- 'name' => 'timeout',
479
- 'value' => esc_attr( $dg_options['thumber']['timeout'] ),
480
- 'type' => 'number" min="1" step="1',
481
- 'option_name' => DG_OPTION_NAME,
482
- 'description' => __( 'Max number of seconds to wait for thumbnail generation before defaulting to filetype icons.', 'document-gallery' ) .
483
- ' <em>' . __( 'Note that generation will continue where timeout happened next time the gallery is loaded.', 'document-gallery' ) . '</em>'
484
- ) );
485
-
486
  add_settings_field(
487
  'advanced_gs', __( 'Ghostscript Absolute Path', 'document-gallery' ),
488
  array( __CLASS__, 'renderTextField' ),
@@ -808,17 +794,6 @@ class DG_Admin {
808
  }
809
  }
810
 
811
- // handle setting timeout
812
- if ( isset( $values['timeout'] ) ) {
813
- $timeout = (int) $values['timeout'];
814
- if ( $timeout > 0 ) {
815
- $ret['thumber']['timeout'] = $timeout;
816
- } else {
817
- add_settings_error( DG_OPTION_NAME, 'thumber-timeout',
818
- __( 'Invalid timeout given: ', 'document-gallery' ) . $values['timeout'] );
819
- }
820
- }
821
-
822
  // logging settings
823
  $ret['logging']['enabled'] = isset( $values['logging_enabled'] );
824
  if ( isset( $values['logging_purge_interval'] ) ) {
@@ -868,7 +843,7 @@ class DG_Admin {
868
  public static function renderCssSection() {
869
  global $dg_options; ?>
870
  <p><?php printf(
871
- __( 'Enter custom CSS styling for use with document galleries. To see which ids and classes you can style, take a look at <a href="%s" target="_blank">style.css</a>.' ),
872
  DG_URL . 'assets/css/style.css' ); ?></p>
873
  <table class="form-table">
874
  <tbody>
114
  public static function enqueueScriptsAndStyles( $hook ) {
115
  if ( in_array( $hook, array( DG_Admin::$hook, 'post.php', 'post-new.php' ), true ) ) {
116
  // Settings Page
117
+ DG_Util::enqueueAsset( 'document-gallery-admin', 'assets/css/admin.css' );
118
 
119
  // gracefully degrade for older WP versions
120
  if ( version_compare( get_bloginfo( 'version' ), '3.8', '<' ) ) { ?>
127
  </style>
128
  <?php }
129
 
130
+ DG_Util::enqueueAsset( 'document-gallery-admin', 'assets/js/admin.js', array( 'jquery' ) );
131
  wp_localize_script( 'document-gallery-admin', 'dg_admin_vars', array( 'upload_limit' => wp_max_upload_size() ) );
132
  if ( $hook !== self::$hook ) { //if $hook is 'post.php' or 'post-new.php'
133
  wp_localize_script( 'document-gallery-admin', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
134
 
135
  // Media Manager
136
  global $dg_options;
137
+ DG_Util::enqueueAsset( 'document-gallery-media-manager', 'assets/js/media_manager.min.js', array( 'media-views' ) );
138
  wp_localize_script( 'document-gallery-media-manager', 'DGl10n', array(
139
  'documentGalleryMenuTitle' => __( 'Create Document Gallery', 'document-gallery' ),
140
  'documentGalleryButton' => __( 'Create a new Document Gallery', 'document-gallery' ),
469
  'description' => __( 'Number of days to keep old log entries (0 disables purging).', 'document-gallery' )
470
  ) );
471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  add_settings_field(
473
  'advanced_gs', __( 'Ghostscript Absolute Path', 'document-gallery' ),
474
  array( __CLASS__, 'renderTextField' ),
794
  }
795
  }
796
 
 
 
 
 
 
 
 
 
 
 
 
797
  // logging settings
798
  $ret['logging']['enabled'] = isset( $values['logging_enabled'] );
799
  if ( isset( $values['logging_purge_interval'] ) ) {
843
  public static function renderCssSection() {
844
  global $dg_options; ?>
845
  <p><?php printf(
846
+ __( 'Enter custom CSS styling for use with document galleries. To see which ids and classes you can style, take a look at <a href="%s" target="_blank">style.css</a>.', 'document-gallery' ),
847
  DG_URL . 'assets/css/style.css' ); ?></p>
848
  <table class="form-table">
849
  <tbody>
assets/css/admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ @media screen and (max-width:782px){.column-title{width:150px}.column-date{display:table-cell !important;width:auto !important}.nav-tab-wrapper{padding-left:5px !important;padding-right:5px !important}.top .tablenav-pages{display:none}.bottom .tablenav-pages{width:auto !important;margin-top:0 !important}.bottom .displaying-num{position:inherit !important}}@media screen and (max-width:979px){.column-thumbupload{display:none}.thumbs-list-wrapper{margin-top:0 !important}}div.thumbs-list-wrapper,div.log-list-wrapper{text-align:center;margin-top:1.5em}div.thumbs-list-wrapper>div,div.log-list-wrapper>div{margin:0 auto;display:inline-block}#ThumbsTable,#LogTable{border:0;box-shadow:none;-webkit-box-shadow:none;-moz-box-shadow:none;border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;background:#b9c9fe;color:#039;width:100%;margin:10px auto}#ThumbsTable tbody,#LogTable tbody{background:#e8edff;color:#669}#ThumbsTable>tbody>tr:hover,#LogTable>tbody>tr:hover{background:#d0dafd}#ThumbsTable>tbody>tr:not(:last-child) td,#LogTable>tbody>tr:not(:last-child) td{border-bottom:1px solid #b9c9fe}#ThumbsTable td,#ThumbsTable th,#LogTable td,#LogTable th{text-align:center;vertical-align:middle;margin:0;padding:4px}#LogTable td{text-align:left}td.title.column-title,.column-thumbupload{text-align:left !important}td.column-icon.media-icon{height:70px}td.media-icon img{width:auto;height:auto;max-width:80px;max-height:60px;border:0}#ThumbsTable img{display:block;margin:5px auto}#LogTable td>pre,.spoiler-body>pre,.expander pre,.collapser pre{margin:0;display:inline-block;white-space:pre-line}tr.selected{background:#b6adce}tr.selected:hover{background:#d8d3e5 !important}.check-column,.column-icon{white-space:nowrap;width:80px}.column-thumbupload{white-space:nowrap;width:35%}#document_gallery_gen_box .column-thumbupload{width:auto;padding-left:7em}.nav-tab:before,.deleteSelected:before,.clearLog:before,.expandAll:before,.collapseAll:before,.logLabel.date:before,.collapser:after,.expander:after{display:inline-block;-webkit-font-smoothing:antialiased;font:normal 20px/1 'dashicons';vertical-align:text-bottom;padding-right:5px}.General-tab:before{content:'\f108'}.Thumbnail-tab:before{content:'\f233'}.Logging-tab:before{content:'\f163'}.Advanced-tab:before{content:'\f332'}.deleteSelected:before,.clearLog:before{content:'\f182'}.expandAll:before{content:'\f211'}.collapseAll:before{content:'\f506'}.expandAll,.collapseAll{display:none}#ThumbsTable .title a:after,#LogTable>tbody a:after{content:'\f504';display:inline-block;-webkit-font-smoothing:antialiased;font-family:'dashicons';font-size:inherit;font-style:normal;font-variant:normal;font-weight:normal;line-height:1;vertical-align:inherit;padding-left:5px}#LogTable>tbody a{-webkit-transition:none;transition:none;text-decoration:none;outline:0}#LogTable>tbody pre strong{font-weight:bolder}#LogTable>tbody a:active,#LogTable>tbody a:hover{color:#2ea2cc}.levelSelector{float:right}.logLabel{padding:0 10px;color:#fff !important;text-decoration:none;font-weight:bolder;border:none !important;float:left;margin-left:1px;margin-top:1px;-webkit-border-radius:100px;-moz-border-radius:100px;border-radius:100px;cursor:context-menu}.logLabel.warning{background:#f89406}.logLabel.detail{background:#3a87ad}.logLabel.error{background:#c00}.logLabel.date{background:#999;font-weight:inherit}.logLabel.date:before{font-size:inherit;vertical-align:middle;padding-bottom:.2em;content:'\f469'}.spoiler-body{padding:1px 6px 2px;display:none;border-top:1px solid #c3cbd1;background:#f5f5f5}.column-entry{text-align:left !important}.expander pre,.collapser pre{vertical-align:middle;float:left;white-space:pre-wrap}.expander,.collapser{display:table;vertical-align:middle;width:100%;cursor:pointer}.expander>div,.collapser>div{display:table-cell;vertical-align:middle;height:100%}.dashicons.dashicons-arrow-down-alt2,.dashicons.dashicons-arrow-up-alt2{float:right;padding-right:15px}.levelSelector>*,.dashicons{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.levelSelector>input[type=checkbox]{display:none}.levelSelector>input[type=checkbox]+label{color:#6b6b6b;font-weight:bolder;margin:4px 0;overflow:auto;text-align:center;padding:3px 8px;display:table-cell;background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#FFF,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#FFF),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#FFF,#e6e6e6);background-image:-o-linear-gradient(top,#FFF,#e6e6e6);background-image:linear-gradient(to bottom,#FFF,#e6e6e6);background-repeat:repeat-x;border:1px solid #CCC;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-bottom-color:#b3b3b3;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF',endColorstr='#FFE6E6E6',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.levelSelector>input[type=checkbox]+label:first-of-type{border-top-left-radius:4px;border-bottom-left-radius:4px}.levelSelector>input[type=checkbox]+label:last-of-type{border-top-right-radius:4px;border-bottom-right-radius:4px}.levelSelector>input[type=checkbox]:checked+label{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.levelSelector>input[type=checkbox]+label.errorLevel{color:#c00}.levelSelector>input[type=checkbox]:checked+label.errorLevel{background-color:#c00;color:#FFF}.levelSelector>input[type=checkbox]+label.warningLevel{color:#f89406}.levelSelector>input[type=checkbox]:checked+label.warningLevel{background-color:#f89406;color:#FFF}.levelSelector>input[type=checkbox]+label.detailLevel{color:#3a87ad}.levelSelector>input[type=checkbox]:checked+label.detailLevel{background-color:#3a87ad;color:#FFF}.noLog{font-size:x-large;display:block;width:100%;text-align:center;margin-top:20ex;line-height:150%}.loggingON,.loggingOFF{font-weight:bolder}.loggingON{color:green}.loggingOFF{color:red}th input{margin-left:0 !important;margin-top:1px !important}td input{margin-right:0 !important}textarea[readonly],input[readonly],select[readonly]{background-color:#dcdcdc}.nowrap{white-space:nowrap}.column-level{white-space:nowrap;width:6em}.column-date{width:16em !important}.column-thumbupload{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.column-thumbupload>*{visibility:hidden}.column-thumbupload .dashicons{font-size:x-large;padding-top:2px;padding-left:16px;padding-right:10px;vertical-align:text-bottom}#ThumbsTable tr:hover .column-thumbupload>*,#document_gallery_gen_box #ThumbsTable tr .column-thumbupload>*{visibility:visible}.dragover{outline:3px dashed #83b4d8}.html5dndmarker span{padding:0 10px}.buttons-area input:first-child,.invis{display:none !important}#document_gallery_gen_box h3 span{font-weight:100}#document_gallery_gen_box h3 span i b{font-weight:500}th.column-description{text-align:left !important}.editable-description{max-height:70px;overflow-y:auto;text-align:justify}.column-description textarea{height:65px;width:100%}td.column-title,td.column-description{position:relative}td.column-title.trans,td.column-description.trans{background-color:inherit;transition:background-color 1s linear;-o-transition:background-color 1s linear;-moz-transition:background-color 1s linear;-webkit-transition:background-color 1s linear}td .dashicons-edit,td .edit-controls{display:none;position:absolute;top:5px;right:12px}td .dashicons-edit,.edit-controls .dashicons-yes,.edit-controls .dashicons-no,.edit-controls .dashicons-update{z-index:100;font-size:x-large;cursor:pointer;width:auto;height:auto}td .dashicons-edit,.edit-controls .dashicons-update{color:#0074a2}.edit-controls:hover,.edit-controls.waiting{opacity:1}.edit-controls{opacity:.1}.edit-controls .dashicons-yes{color:green}.edit-controls .dashicons-no{color:red}.edit-controls.waiting .dashicons-yes,.edit-controls.waiting .dashicons-no{display:none}.edit-controls .dashicons-update{display:none;cursor:default}.edit-controls.waiting .dashicons-update,.deleteSelected.waiting:before{display:block;-webkit-animation:spin 1s linear infinite;-moz-animation:spin 1s linear infinite;animation:spin 1s linear infinite}.deleteSelected.waiting:before{content:'\f463';width:auto;height:auto;display:inline-block;padding:0}@-moz-keyframes spin{100%{-moz-transform:rotate(360deg)}}@-webkit-keyframes spin{100%{-webkit-transform:rotate(360deg)}}@keyframes spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.responseSuccess{background-color:greenyellow !important}.responseFail{background-color:crimson !important}td.column-title .dashicons-edit,td.column-description .dashicons-edit{height:0;opacity:0;display:block;overflow:hidden;transition:opacity 1s ease-out;-o-transition:opacity 1s ease-out;-moz-transition:opacity 1s ease-out;-webkit-transition:opacity 1s ease-out}td.column-title:hover .dashicons-edit,td.column-description:hover .dashicons-edit{opacity:1;height:auto}td.column-title input{width:75%}.manual-download{display:block;text-align:center}.editable-description::-webkit-scrollbar,.column-description textarea::-webkit-scrollbar{width:5px;height:5px}.editable-description::-webkit-scrollbar-track-piece,.column-description textarea::-webkit-scrollbar-track-piece{background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.editable-description::-webkit-scrollbar-thumb:vertical,.column-description textarea::-webkit-scrollbar-thumb:vertical{height:5px;background-color:#9b9b9b;-webkit-border-radius:5px}.document-gallery-settings label.setting{margin:2px 0}.document-gallery-settings label.setting table{width:100%;padding-right:8px}.document-gallery-settings label.setting table tr td:last-of-type,.document-gallery-settings label.setting table tr td:last-of-type *{text-align:right !important;float:none !important;margin:auto 0 !important}.document-gallery-settings label.setting table tr td:last-of-type select{max-width:none !important}.document-gallery-settings label.setting table tr td span{text-align:left !important;float:none !important}.progress{border:0;width:100%;height:18px;position:relative;background-color:#f1f1f1;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px;-webkit-box-shadow:inset 0 -1px 1px rgba(255,255,255,0.3);-moz-box-shadow:inset 0 -1px 1px rgba(255,255,255,0.3);box-shadow:inset 0 -1px 1px rgba(255,255,255,0.3)}.column-thumbupload .progress{visibility:visible !important}.progress>span{border:0;height:100%;display:block;overflow:hidden;position:relative;-webkit-transition:width .5s linear;-moz-transition:width .5s linear;-o-transition:width .5s linear;transition:width .5s linear;background-color:#7ad03a;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px;background-image:linear-gradient(90deg,#2bc253 37%,#54f054 69%);background-image:-moz-linear-gradient(90deg,#2bc253 37%,#54f054 69%);background-image:-o-linear-gradient(90deg,#2bc253 37%,#54f054 69%);background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#2bc253),color-stop(1,#54f054));-webkit-box-shadow:inset 0 2px 9px rgba(255,255,255,0.3),inset 0 -2px 6px rgba(0,0,0,0.4);-moz-box-shadow:inset 0 2px 9px rgba(255,255,255,0.3),inset 0 -2px 6px rgba(0,0,0,0.4);box-shadow:inset 0 2px 9px rgba(255,255,255,0.3),inset 0 -2px 6px rgba(0,0,0,0.4)}.progress>span:after,.progress.animate>span>span{top:0;left:0;right:0;bottom:0;z-index:1;content:'';overflow:hidden;position:absolute;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px;background-image:-webkit-gradient(linear,0 0,100% 100%,color-stop(.25,rgba(255,255,255,.2)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.2)),color-stop(.75,rgba(255,255,255,.2)),color-stop(.75,transparent),to(transparent));background-image:-moz-linear-gradient(315deg,rgba(255,255,255,.2) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.2) 50%,rgba(255,255,255,.2) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(315deg,rgba(255,255,255,.2) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.2) 50%,rgba(255,255,255,.2) 75%,transparent 75%,transparent);background-image:linear-gradient(315deg,rgba(255,255,255,.2) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.2) 50%,rgba(255,255,255,.2) 75%,transparent 75%,transparent);-webkit-background-size:50px 50px;-moz-background-size:50px 50px;background-size:50px 50px;-webkit-animation:move 2s linear infinite;-moz-animation:move 2s linear infinite;-ms-animation:move 2s linear infinite;animation:move 2s linear infinite}@-webkit-keyframes move{0{background-position:0 0}100%{background-position:50px 50px}}@-moz-keyframes move{0{background-position:0 0}100%{background-position:50px 50px}}@-ms-keyframes move{0{background-position:0 0}100%{background-position:50px 50px}}@keyframes move{0{background-position:0 0}100%{background-position:50px 50px}}.progress.animate>span:after{display:none}.progress.success>span{background-color:green;width:100% !important;background-image:none !important}.progress.fail>span{background-color:red;background-image:none !important}.progress.nostripes>span>span,.progress.nostripes>span:after,.progress.success>span>span,.progress.success>span:after,.progress.fail>span>span,.progress.fail>span:after{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none;background-image:none}
assets/css/style.min.css ADDED
@@ -0,0 +1 @@
 
1
+ div.document-icon{text-align:center}div.document-icon img{width:89px;max-width:100%;border:0}div.document-icon a{font-size:10px;line-height:12px}div.document-icon{margin:5px 0 0}div.document-icon{display:inline-block;vertical-align:top;overflow:hidden}div.document-icon-wrapper{width:100%;padding:0;text-align:left}div.descriptions.document-icon-wrapper div.document-icon{max-width:115px;padding:0 3px 0 0;float:left}div.descriptions.document-icon-wrapper{vertical-align:middle;text-align:inherit}div.descriptions.document-icon-wrapper img{width:65px;max-width:100%}div.descriptions.document-icon-wrapper:before,div.descriptions.document-icon-wrapper:after{content:"";display:table}div.descriptions.document-icon-wrapper:after{clear:both}div.descriptions.document-icon-wrapper{zoom:1}
assets/js/admin.js CHANGED
@@ -227,7 +227,7 @@ jQuery(document).ready(function () {
227
  if (xhr.readyState == 4) {
228
  if (xhr.status == 200 && xhr.responseText.indexOf("\n") == -1) {
229
  jQuery(progressBarValue).parent().addClass('success');
230
- eval('var response = ' + xhr.responseText + ';');
231
  if (response.result) {
232
  // check if generated thumbnail has the same url
233
  if (response.url === theImg.attr('src')) {
@@ -369,7 +369,7 @@ jQuery(document).ready(function () {
369
  cell.addClass('trans');
370
  cell.find('.edit-controls').removeClass('waiting');
371
  if (xhr.responseText.indexOf("\n") == -1) {
372
- eval('var response = ' + xhr.responseText + ';');
373
  if (response.result) {
374
  if (cell.hasClass('column-description')) {
375
  updateGoal.html(newContent.val());
227
  if (xhr.readyState == 4) {
228
  if (xhr.status == 200 && xhr.responseText.indexOf("\n") == -1) {
229
  jQuery(progressBarValue).parent().addClass('success');
230
+ var response = jQuery.parseJSON(xhr.responseText);
231
  if (response.result) {
232
  // check if generated thumbnail has the same url
233
  if (response.url === theImg.attr('src')) {
369
  cell.addClass('trans');
370
  cell.find('.edit-controls').removeClass('waiting');
371
  if (xhr.responseText.indexOf("\n") == -1) {
372
+ var response = jQuery.parseJSON(xhr.responseText);
373
  if (response.result) {
374
  if (cell.hasClass('column-description')) {
375
  updateGoal.html(newContent.val());
assets/js/admin.min.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function(){function l(a){a=a||event;if(a.dataTransfer.types)for(var b=0;b<a.dataTransfer.types.length;b++)if("Files"==a.dataTransfer.types[b]){a.stopPropagation();a.preventDefault();a.dataTransfer.dropEffect="none";break}}function p(a){a=a||event;if(a.originalEvent.dataTransfer.types)for(var b=0;b<a.originalEvent.dataTransfer.types.length;b++)if("Files"==a.originalEvent.dataTransfer.types[b])return a.stopPropagation(),a.preventDefault(),a.originalEvent.dataTransfer.dropEffect=
2
+ "move",!1}function q(a){a=a||event;if(a.originalEvent.dataTransfer.types)for(var b=0;b<a.originalEvent.dataTransfer.types.length;b++)if("Files"==a.originalEvent.dataTransfer.types[b]){this.classList.add("dragover");f[jQuery(this).data("entry")]=f[jQuery(this).data("entry")].add(jQuery(a.target));break}}function r(a){a=a||event;if(a.originalEvent.dataTransfer.types)for(var b=0;b<a.originalEvent.dataTransfer.types.length;b++)if("Files"==a.originalEvent.dataTransfer.types[b]){f[jQuery(this).data("entry")]=
3
+ f[jQuery(this).data("entry")].not(a.target);0===f[jQuery(this).data("entry")].length&&this.classList.remove("dragover");break}}function t(a){a=a||event;if(a.originalEvent.dataTransfer.types)for(var b=0;b<a.originalEvent.dataTransfer.types.length;b++)if("Files"==a.originalEvent.dataTransfer.types[b]){a.stopPropagation();a.preventDefault();m(a.originalEvent.dataTransfer.files,jQuery(this).data("entry"));f[jQuery(this).data("entry")]=jQuery();this.classList.remove("dragover");break}}function u(a){a=
4
+ a||event;m(a.target.files,jQuery(this).closest("tr").data("entry"))}function m(a,b){for(var h=0,e;e=a[h];h++)if(0==e.type.indexOf("image/")&&"undefined"!=typeof dg_admin_vars.upload_limit&&e.size<=parseInt(dg_admin_vars.upload_limit)){var d=jQuery("[data-entry="+b+"]"),g=new FormData(d.closest("form")[0]);"undefined"!=typeof ajax_object&&"undefined"!=typeof ajax_object.ajax_url?(h=ajax_object.ajax_url,g.append("action","dg_upload_thumb")):h=jQuery("#tab-Thumbnail").attr("action");g.append("document_gallery[entry]",
5
+ b);g.append("document_gallery[ajax]","true");g.append("document_gallery[upload]","true");g.append("file",e);var c=new XMLHttpRequest;c.open("POST",h);var f=d.find(".column-icon img"),k=d.find(".progress > *:first");c.onreadystatechange=function(){if(4==c.readyState){if(200==c.status&&-1==c.responseText.indexOf("\n")){jQuery(k).parent().addClass("success");var a=jQuery.parseJSON(c.responseText);a.result&&(a.url===f.attr("src")?f.attr("src",f.attr("src")+"?"+(new Date).getTime()):f.attr("src",a.url))}else jQuery(k).parent().addClass("fail"),
6
+ console.log("Invalid response from server:"),console.log(c.responseText);setTimeout(function(){d.find(".column-thumbupload > *").toggleClass("invis");jQuery(k).parent().removeClass("success fail")},5E3)}};c.onload=function(){k.width("100%")};c.upload.onprogress=function(a){a.lengthComputable&&k.width((a.loaded/a.total*100|0)+"%")};k.width(0);d.find(".column-thumbupload > *").toggleClass("invis");c.send(g);break}else console.log("Attempt to upload improper file %c"+e.name+":","font-weight:bold;"),
7
+ 0!=e.type.indexOf("image/")&&console.log("\tIs not an image - "+e.type),"undefined"!=typeof dg_admin_vars.upload_limit&&e.size>parseInt(dg_admin_vars.upload_limit)&&console.log("\tIs too big - "+e.size+"b; (Limit is "+dg_admin_vars.upload_limit+"b)")}function n(a){for(var b=4,h=0;6>h;h++)a.animate({"margin-left":"+="+(b=-b)+"px"},50)}jQuery(".cb-ids").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("tr").addClass("selected"):jQuery(this).closest("tr").removeClass("selected")});
8
+ jQuery("th input:checkbox").change(function(){jQuery(this).is(":checked")?jQuery("#ThumbsTable tbody tr").addClass("selected"):jQuery("#ThumbsTable tbody tr").removeClass("selected")});jQuery("input.current-page").bind("keypress",{},function(a){13==(a.keyCode?a.keyCode:a.which)&&(a.preventDefault(),jQuery(location).attr("href","?"+jQuery.param(jQuery.extend(URL_params,{sheet:this.value}))))});jQuery("select.limit_per_page").change(function(){jQuery(location).attr("href","?"+jQuery.param(jQuery.extend(URL_params,
9
+ {limit:this.value})))});jQuery("#tab-Thumbnail").submit(function(a){a.preventDefault();if(0<jQuery(".cb-ids:checked").length){a=jQuery(this).attr("action");var b=jQuery(this).serialize()+"&document_gallery%5Bajax%5D=true&document_gallery%5Bcleanup%5D=true";jQuery(".deleteSelected").addClass("waiting").attr("disabled","disabled");jQuery.post(a,b,function(a){if(a.result){a=a.deleted;for(var b in a)jQuery("input[type=checkbox][value="+a[b]+"]").closest("tr").fadeOut("slow",0,function(){jQuery(this).slideUp("slow",
10
+ function(){jQuery(this).remove()})})}jQuery(".deleteSelected").removeClass("waiting").removeAttr("disabled")}).fail(function(){console.log("Problem in reaching the server");jQuery(".deleteSelected").removeClass("waiting").removeAttr("disabled")})}return!1});jQuery("#tab-Advanced #options-dump").click(function(){jQuery(this).select()});jQuery(".expander").click(function(){getSelection().toString()||(jQuery(this).next().slideToggle("slow"),jQuery(this).find(".dashicons").toggleClass("dashicons-arrow-down-alt2 dashicons-arrow-up-alt2"),
11
+ jQuery(this).toggleClass("expander collapser"),jQuery(this).attr("title",jQuery(this).hasClass("expander")?"Click to Expand":"Click to Collapse"))});jQuery(".spoiler-body").length&&(jQuery(".expandAll, .collapseAll").addClass("button"),jQuery(".expandAll").click(function(a){a.preventDefault();jQuery(".expander").trigger("click")}),jQuery(".collapseAll").click(function(a){a.preventDefault();jQuery(".collapser").trigger("click")}));jQuery(".levelSelector input").change(function(){"all"==jQuery(this).val()?
12
+ (jQuery(".levelSelector input").not("[value='all']").prop("checked",jQuery(this).is(":checked")),jQuery(this).is(":checked")?jQuery("#LogTable tbody tr").show():jQuery("#LogTable tbody tr").hide()):(jQuery(this).is(":checked")?jQuery("#LogTable tbody tr:has(span."+jQuery(this).val()+")").show():jQuery("#LogTable tbody tr:has(span."+jQuery(this).val()+")").hide(),jQuery(".levelSelector input:checked").not("[value='all']").length+1==jQuery('.levelSelector input[type="checkbox"]').length?jQuery('.levelSelector input[value="all"]').prop("checked",
13
+ !0):jQuery('.levelSelector input[value="all"]').prop("checked",!1))});jQuery("#LogTable .manage-column.column-date").click(function(){jQuery(this).toggleClass("asc desc");var a=jQuery("#LogTable > tbody"),b=a.children("tr");a.append(b.get().reverse())});window.addEventListener("dragover",l,!1);window.addEventListener("drop",l,!1);var f={};jQuery("#ThumbsTable tbody tr").each(function(){jQuery(this).on("dragenter",q).on("dragover",p).on("dragleave",r).on("drop",t);f[jQuery(this).data("entry")]=jQuery();
14
+ jQuery(this).find("input:button").on("click",function(){jQuery(this).prevAll("input:file").click()});jQuery(this).find("input:file").on("change",u)});"draggable"in document.createElement("span")||jQuery(".html5dndmarker").hide();jQuery("td .dashicons-edit").click(function(){var a=jQuery(this).closest("td");if(a.hasClass("column-title")){if("none"==a.find("a").css("display"))return;a.find("a").hide().after('<input type="text" value="'+a.find(".editable-title").text()+'">');a.find("input").focus()}else if(a.hasClass("column-description")){if("none"==
15
+ a.find(".editable-description").css("display"))return;a.find(".editable-description").hide().after("<textarea>"+a.find(".editable-description").html()+"</textarea>");a.find("textarea").focus()}else return;jQuery(this).css("visibility","hidden");a.find(".edit-controls").show()});jQuery(".edit-controls .dashicons-no").click(function(){var a=jQuery(this).closest("td");if(a.hasClass("column-title")){if("none"!=a.find("a").css("display"))return;a.find("input").fadeOut("fast",function(){jQuery(this).remove();
16
+ a.find("a").fadeIn("fast")})}else if(a.hasClass("column-description")){if("none"!=a.find(".editable-description").css("display"))return;a.find("textarea").fadeOut("fast",function(){jQuery(this).remove();a.find(".editable-description").fadeIn("fast")})}else return;jQuery(this).closest(".edit-controls").hide();a.find(".dashicons-edit").css("visibility","visible")});jQuery(".edit-controls .dashicons-yes").click(function(){var a=jQuery(this).closest("td"),b=jQuery(this).closest("tr").data("entry"),f=
17
+ jQuery("#tab-Thumbnail").attr("action"),e=new FormData(jQuery("[data-entry="+b+"]").closest("form")[0]);e.append("document_gallery[entry]",b);e.append("document_gallery[ajax]","true");var d,g;if(a.hasClass("column-title"))d=a.find("input"),g=a.find(".editable-title"),e.append("document_gallery[title]",encodeURIComponent(d.val()));else if(a.hasClass("column-description"))d=a.find("textarea"),g=a.find(".editable-description"),e.append("document_gallery[description]",encodeURIComponent(d.val()));else return;
18
+ if(d.val()==g.text()||a.hasClass("column-description")&&d.val()==g.html())jQuery(this).next(".dashicons-no").click();else{var c=new XMLHttpRequest;c.open("POST",f);c.onreadystatechange=function(){4==c.readyState&&(a.addClass("trans"),a.find(".edit-controls").removeClass("waiting"),-1==c.responseText.indexOf("\n")?jQuery.parseJSON(c.responseText).result?(a.hasClass("column-description")?g.html(d.val()):g.text(d.val()),a.find(".dashicons-no").click(),a.addClass("responseSuccess").delay(2E3).queue(function(){jQuery(this).removeClass("responseSuccess").dequeue()}).delay(1100).queue(function(){jQuery(this).removeClass("trans").dequeue()})):
19
+ (n(d),a.addClass("responseFail").delay(1100).queue(function(){jQuery(this).removeClass("responseFail").dequeue()}).delay(1100).queue(function(){jQuery(this).removeClass("trans").dequeue()})):(n(d),a.addClass("responseFail").delay(1100).queue(function(){jQuery(this).removeClass("responseFail").dequeue()}).delay(1100).queue(function(){jQuery(this).removeClass("trans").dequeue()}),console.log("Invalid response from server:"),console.log(c.responseText)))};jQuery(this).closest(".edit-controls").addClass("waiting");
20
+ c.send(e)}})});
assets/js/gallery.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ // distinct list of all attachment IDs populated
3
+ var ids = [];
4
+
5
+ // current index in pendingIcons
6
+ var i = 0;
7
+
8
+ // find all document-icons without icons generated and start processing
9
+ jQuery(document).ready(function() {
10
+ jQuery('.document-icon[data-dg-id]').each(function() {
11
+ var id = jQuery(this).data('dg-id');
12
+
13
+ // if we have multiple galleries, we could have multiple elements
14
+ // needing the same icon amd no need to request multiple times
15
+ if (-1 === jQuery.inArray(id, ids)) {
16
+ ids.push(id);
17
+ }
18
+ });
19
+
20
+ retrieveNextIcons();
21
+ });
22
+
23
+ /**
24
+ * Sends AJAX request to server requesting some of the not-yet-generated icons (if any).
25
+ */
26
+ function retrieveNextIcons() {
27
+ // max number of icons to retrieve per AJAX request
28
+ var batchLimit = 2;
29
+
30
+ // IDs already retrieved
31
+ var idBatch = [];
32
+
33
+ for (; i < ids.length; i++) {
34
+ if (idBatch.length === batchLimit) {
35
+ break;
36
+ }
37
+
38
+ idBatch.push(ids[i]);
39
+ }
40
+
41
+ if (idBatch.length != 0) {
42
+ // request the next batch of icons
43
+ jQuery.post(ajaxurl, { action: 'dg_generate_icons', ids: idBatch }, processRetrievedThumbnails);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Find all of the relevant elements and set the img src, then start next batch of thumbnail retrieval.
49
+ * @param response Associative array mapping attachment ID to thumbnail URL.
50
+ */
51
+ function processRetrievedThumbnails(response) {
52
+ for (var id in response) {
53
+ if (response.hasOwnProperty(id)) {
54
+ var target = jQuery('.document-icon[data-dg-id="' + id + '"] img');
55
+ if (target.attr('src') !== response[id]) {
56
+ (function(id, target) {
57
+ target.fadeOut('fast', function () {
58
+ jQuery(this).attr('src', response[id]);
59
+ jQuery(this).fadeIn('fast');
60
+ })
61
+ })(id, target);
62
+ }
63
+ }
64
+ }
65
+
66
+ // start next batch once this response is processed
67
+ retrieveNextIcons();
68
+ }
69
+ })();
assets/js/gallery.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ (function(){function d(){for(var a=[];c<b.length&&2!==a.length;c++)a.push(b[c]);0!=a.length&&jQuery.post(ajaxurl,{action:"dg_generate_icons",ids:a},e)}function e(a){for(var b in a)if(a.hasOwnProperty(b)){var c=jQuery('.document-icon[data-dg-id="'+b+'"] img');c.attr("src")!==a[b]&&function(b,c){c.fadeOut("fast",function(){jQuery(this).attr("src",a[b]);jQuery(this).fadeIn("fast")})}(b,c)}d()}var b=[],c=0;jQuery(document).ready(function(){jQuery(".document-icon[data-dg-id]").each(function(){var a=jQuery(this).data("dg-id");
2
+ -1===jQuery.inArray(a,b)&&b.push(a)});d()})})();
assets/js/media_manager.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ (function(g,f){var a=wp.media;l10n=a.view.l10n="undefined"===typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n;jQuery.extend(l10n,DGl10n);a.controller.DocumentGalleryEdit=a.controller.Library.extend({defaults:{id:"document-gallery-edit",title:l10n.editDocumentGalleryTitle,multiple:!1,searchable:!1,sortable:!0,display:!1,content:"browse",toolbar:"document-gallery-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.gallerySettings,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.gallerySettings,this);a.controller.Library.prototype.deactivate.apply(this,arguments)},gallerySettings:function(c){if(this.get("displaySettings")){var b=this.get("library");b&&c&&(b.gallery=b.gallery||new Backbone.Model,c.sidebar.set({document_gallery:new a.view.Settings.DocumentGallery({controller:this,model:b.gallery,priority:40})}),c.toolbar.set("reverse",{text:l10n.reverseOrder,priority:80,click:function(){b.reset(b.toArray().reverse())}}))}}});a.controller.DocumentGalleryAdd=a.controller.Library.extend({defaults:f.defaults({id:"document-gallery-library",
4
+ title:l10n.addToDocumentGalleryTitle,multiple:"add",filterable:"uploaded",menu:"document-gallery",toolbar:"document-gallery-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("document-gallery-edit").get("library");this.editLibrary&&this.editLibrary!==b&&c.unobserve(this.editLibrary);
5
+ c.validator=function(c){return!!this.mirroring.get(c.cid)&&!b.get(c.cid)&&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.DocumentGallery=a.view.Settings.extend({className:"collection-settings gallery-settings document-gallery-settings",template:a.template("document-gallery-settings")});var d=wp.media.view.MediaFrame.Post;wp.media.view.MediaFrame.Post=
6
+ d.extend({initialize:function(){d.prototype.initialize.apply(this,arguments);this.states.add([new a.controller.Library({id:"document-gallery",title:l10n.documentGalleryMenuTitle,priority:50,toolbar:"main-document-gallery",filterable:"all",multiple:"add",editable:!1,library:a.query(this.options.library)}),new a.controller.DocumentGalleryEdit({library:this.options.selection,editing:this.options.editing,menu:"document-gallery"}),new a.controller.DocumentGalleryAdd]);this.on("menu:create:document-gallery",
7
+ this.createMenu,this);this.on("toolbar:create:main-document-gallery",this.createToolbar,this);this.on("menu:render:document-gallery",this.documentGalleryMenu,this);this.on("toolbar:render:main-document-gallery",this.mainDocumentGalleryToolbar,this);this.on("toolbar:render:document-gallery-edit",this.documentGalleryEditToolbar,this);this.on("toolbar:render:document-gallery-add",this.documentGalleryAddToolbar,this)},documentGalleryMenu:function(c){var b=this.lastState(),e=b&&b.id,d=this;c.set({cancel:{text:l10n.cancelDocumentGalleryTitle,
8
+ priority:20,click:function(){e?d.setState(e):d.close();this.controller.modal.focusManager.focus()}},separateCancel:new a.View({className:"separator",priority:40})})},mainDocumentGalleryToolbar:function(a){var b=this;this.selectionStatusToolbar(a);a.set("document-gallery",{style:"primary",text:l10n.documentGalleryButton,priority:60,requires:{selection:!0},click:function(){var a=b.state().get("selection");b.state("document-gallery-edit").set("library",a);this.controller.setState("document-gallery-edit");
9
+ this.controller.modal.focusManager.focus()}})},documentGalleryEditToolbar:function(){var c=this.state().get("editing");this.toolbar.set(new a.view.Toolbar({controller:this,items:{insert:{style:"primary",text:c?l10n.updateDocumentGallery:l10n.insertDocumentGallery,priority:80,requires:{library:!0},click:function(){var a=this.controller,c=a.state();a.close();wp.media.editor.insert(wp.media.gallery.shortcode(c.get("library")).string().replace(/^\[gallery/ig,"[dg").replace(/DGorderby/ig,"orderby"));a.setState(a.options.state);
10
+ a.reset()}}}}))},documentGalleryAddToolbar:function(){this.toolbar.set(new a.view.Toolbar({controller:this,items:{insert:{style:"primary",text:l10n.addToDocumentGallery,priority:80,requires:{selection:!0},click:function(){var a=this.controller,b=a.state();a.state("document-gallery-edit").get("library").add(b.get("selection").models);b.trigger("reset");a.setState("document-gallery-edit")}}}}))}})})(jQuery,_);
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.4.2
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.4.2' );
16
 
17
  // define helper paths & URLs
18
  define( 'DG_BASENAME', plugin_basename( __FILE__ ) );
@@ -77,12 +77,17 @@ if ( is_admin() ) {
77
  if ( DG_Admin::doRegisterSettings() ) {
78
  add_action( 'admin_init', array( 'DG_Admin', 'registerSettings' ) );
79
  }
 
 
 
80
  } else {
81
  // styling for gallery
82
  if ( apply_filters( 'dg_use_default_gallery_style', true ) ) {
83
  add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryStyle' ) );
84
  }
85
  add_action( 'wp_print_scripts', array( 'DocumentGallery', 'printCustomStyle' ) );
 
 
86
  }
87
 
88
  // adds 'dg' shortcode
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.5
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.5' );
16
 
17
  // define helper paths & URLs
18
  define( 'DG_BASENAME', plugin_basename( __FILE__ ) );
77
  if ( DG_Admin::doRegisterSettings() ) {
78
  add_action( 'admin_init', array( 'DG_Admin', 'registerSettings' ) );
79
  }
80
+
81
+ add_action( 'wp_ajax_dg_generate_icons', array( 'DocumentGallery', 'ajaxGenerateIcons' ) );
82
+ add_action( 'wp_ajax_nopriv_dg_generate_icons', array( 'DocumentGallery', 'ajaxGenerateIcons' ) );
83
  } else {
84
  // styling for gallery
85
  if ( apply_filters( 'dg_use_default_gallery_style', true ) ) {
86
  add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryStyle' ) );
87
  }
88
  add_action( 'wp_print_scripts', array( 'DocumentGallery', 'printCustomStyle' ) );
89
+
90
+ add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryScript' ) );
91
  }
92
 
93
  // adds 'dg' shortcode
inc/class-document-gallery.php CHANGED
@@ -33,7 +33,14 @@ class DocumentGallery {
33
  * Enqueue standard DG CSS.
34
  */
35
  public static function enqueueGalleryStyle() {
36
- wp_enqueue_style( 'document-gallery', DG_URL . 'assets/css/style.css', null, DG_VERSION );
 
 
 
 
 
 
 
37
  }
38
 
39
  /**
@@ -45,6 +52,13 @@ class DocumentGallery {
45
  if ( ! empty( $dg_options['css']['text'] ) ) {
46
  echo '<style type="text/css">' . $dg_options['css']['text'] . '</style>' . PHP_EOL;
47
  }
 
 
 
 
 
 
 
48
  }
49
 
50
  /*==========================================================================
@@ -62,6 +76,21 @@ class DocumentGallery {
62
  * HELPER FUNCTIONS
63
  *=========================================================================*/
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  /**
66
  * @param int $blog ID of the blog to be retrieved in multisite env.
67
  *
@@ -105,7 +134,7 @@ class DocumentGallery {
105
  */
106
  public static function addValidation() {
107
  add_filter( 'pre_update_option_' . DG_OPTION_NAME, array(
108
- 'DocumentGallery',
109
  'validateOptionsStructure'
110
  ), 10, 2 );
111
  }
33
  * Enqueue standard DG CSS.
34
  */
35
  public static function enqueueGalleryStyle() {
36
+ DG_Util::enqueueAsset( 'document-gallery', 'assets/css/style.css' );
37
+ }
38
+
39
+ /**
40
+ * Enqueue script for Document Gallery frontend.
41
+ */
42
+ public static function enqueueGalleryScript() {
43
+ DG_Util::enqueueAsset( 'document-gallery', 'assets/js/gallery.js', array( 'jquery' ) );
44
  }
45
 
46
  /**
52
  if ( ! empty( $dg_options['css']['text'] ) ) {
53
  echo '<style type="text/css">' . $dg_options['css']['text'] . '</style>' . PHP_EOL;
54
  }
55
+
56
+ // need AJAX URL variable in frontend
57
+ ?>
58
+ <script type="text/javascript">
59
+ var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
60
+ </script>
61
+ <?php
62
  }
63
 
64
  /*==========================================================================
76
  * HELPER FUNCTIONS
77
  *=========================================================================*/
78
 
79
+ /**
80
+ * Accepts AJAX request containing list of IDs to be generated and returned.
81
+ */
82
+ public static function ajaxGenerateIcons() {
83
+ $ret = array();
84
+
85
+ if ( array_key_exists( 'ids', $_REQUEST ) ) {
86
+ foreach ($_REQUEST['ids'] as $id) {
87
+ $ret[$id] = DG_Thumber::getThumbnail($id);
88
+ }
89
+ }
90
+
91
+ wp_send_json($ret);
92
+ }
93
+
94
  /**
95
  * @param int $blog ID of the blog to be retrieved in multisite env.
96
  *
134
  */
135
  public static function addValidation() {
136
  add_filter( 'pre_update_option_' . DG_OPTION_NAME, array(
137
+ __CLASS__,
138
  'validateOptionsStructure'
139
  ), 10, 2 );
140
  }
inc/class-document.php CHANGED
@@ -50,19 +50,33 @@ class DG_Document {
50
  * Returns HTML representing this Document.
51
  * @filter dg_icon_template Filters the DG icon HTML. Passes a single
52
  * bool value indicating whether the gallery is using descriptions or not.
53
- * @return string
54
  */
55
  public function __toString() {
56
  include_once DG_PATH . 'inc/class-thumber.php';
 
57
 
58
- $thumb = $this->gallery->useFancyThumbs()
59
- ? DG_Thumber::getThumbnail( $this->ID )
60
- : DG_Thumber::getDefaultThumbnail( $this->ID );
61
- $target = $this->gallery->openLinkInNewWindow() ? '_blank' : '_self';
62
-
63
- $repl = array( $this->link, $thumb, $this->title_attribute, $this->title, $target, $this->extension, $this->size, $this->path );
64
- $find = array( '%link%', '%img%', '%title_attribute%', '%title%', '%target%', '%extension%', '%size%', '%path%' );
65
  $description = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  // if descriptions then add filterable tag and value to replaced tag
68
  if ( $this->gallery->useDescriptions() ) {
@@ -72,7 +86,7 @@ class DG_Document {
72
  }
73
 
74
  $doc_icon =
75
- ' <div class="document-icon">' . PHP_EOL .
76
  ' <a href="%link%" target="%target%"><img src="%img%" title="%title_attribute%" alt="%title_attribute%" /><br>%title%</a>' . PHP_EOL .
77
  ' </div>' . PHP_EOL .
78
  $description;
50
  * Returns HTML representing this Document.
51
  * @filter dg_icon_template Filters the DG icon HTML. Passes a single
52
  * bool value indicating whether the gallery is using descriptions or not.
53
+ * @return string The gallery HTML.
54
  */
55
  public function __toString() {
56
  include_once DG_PATH . 'inc/class-thumber.php';
57
+ $options = DG_Thumber::getOptions();
58
 
59
+ $thumb = null;
60
+ $data = '';
 
 
 
 
 
61
  $description = '';
62
+ $target = $this->gallery->openLinkInNewWindow() ? '_blank' : '_self';
63
+
64
+ if ( $this->gallery->useFancyThumbs() ) {
65
+ if ( array_key_exists( $this->ID, $options['thumbs'] ) ) {
66
+ // icon has already been generated so include it in generated gallery
67
+ $thumb = DG_Thumber::getThumbnail( $this->ID, 1, false );
68
+ } else {
69
+ // include a data-* attribute for client side to asynchronously request icon after gallery load
70
+ $data = ' data-dg-id="' . $this->ID . '"';
71
+ }
72
+ }
73
+
74
+ if ( is_null($thumb) ) {
75
+ $thumb = DG_Thumber::getDefaultThumbnail( $this->ID );
76
+ }
77
+
78
+ $repl = array( $this->link, $thumb, $this->title_attribute, $this->title, $target, $this->extension, $this->size, $this->path );
79
+ $find = array( '%link%', '%img%', '%title_attribute%', '%title%', '%target%', '%extension%', '%size%', '%path%' );
80
 
81
  // if descriptions then add filterable tag and value to replaced tag
82
  if ( $this->gallery->useDescriptions() ) {
86
  }
87
 
88
  $doc_icon =
89
+ ' <div class="document-icon"'. $data . '>' . PHP_EOL .
90
  ' <a href="%link%" target="%target%"><img src="%img%" title="%title_attribute%" alt="%title_attribute%" /><br>%title%</a>' . PHP_EOL .
91
  ' </div>' . PHP_EOL .
92
  $description;
inc/class-setup.php CHANGED
@@ -35,9 +35,7 @@ class DG_Setup {
35
  // max width to generate thumbnails
36
  'width' => 200,
37
  // max height to generate thumbnails
38
- 'height' => 200,
39
- // time after which to quite trying to generate new thumbanils for gallery
40
- 'timeout' => 30
41
  ),
42
  'gallery' => array(
43
  // default: link directly to file (true to link to attachment pg)
@@ -138,6 +136,7 @@ class DG_Setup {
138
  self::threePointTwo( $options );
139
  self::threePointThree( $options );
140
  self::threePointFour( $options );
 
141
 
142
  // update plugin meta data
143
  $options['meta']['version'] = DG_VERSION;
@@ -338,6 +337,18 @@ class DG_Setup {
338
  }
339
  }
340
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  /**
342
  * Sets up Document Gallery on all blog(s) activated.
343
  *
35
  // max width to generate thumbnails
36
  'width' => 200,
37
  // max height to generate thumbnails
38
+ 'height' => 200
 
 
39
  ),
40
  'gallery' => array(
41
  // default: link directly to file (true to link to attachment pg)
136
  self::threePointTwo( $options );
137
  self::threePointThree( $options );
138
  self::threePointFour( $options );
139
+ self::threePointFive( $options );
140
 
141
  // update plugin meta data
142
  $options['meta']['version'] = DG_VERSION;
337
  }
338
  }
339
 
340
+ /**
341
+ * There is no longer a concept of gallery load timeout. Missing thumbnails are asynchronously generated after
342
+ * a gallery is first rendered via AJAX requests.
343
+ *
344
+ * @param array $options The options to be modified.
345
+ */
346
+ private static function threePointFive( &$options ) {
347
+ if ( version_compare( $options['meta']['version'], '3.5', '<' ) ) {
348
+ unset( $options['thumber']['timeout'] );
349
+ }
350
+ }
351
+
352
  /**
353
  * Sets up Document Gallery on all blog(s) activated.
354
  *
inc/class-thumber.php CHANGED
@@ -65,11 +65,6 @@ class DG_Thumber {
65
  * @return string URL to the thumbnail.
66
  */
67
  public static function getThumbnail( $ID, $pg = 1, $generate_if_missing = true ) {
68
- static $start = null;
69
- if ( is_null( $start ) ) {
70
- $start = time();
71
- }
72
-
73
  $options = self::getOptions();
74
 
75
  // if we haven't saved a thumb, generate one
@@ -79,11 +74,6 @@ class DG_Thumber {
79
  return null;
80
  }
81
 
82
- // prevent page timing out or user waiting too long for page
83
- if ( ( time() - $start ) > $options['timeout'] ) {
84
- return self::getDefaultThumbnail( $ID, $pg );
85
- }
86
-
87
  // do the processing
88
  $file = get_attached_file( $ID );
89
 
65
  * @return string URL to the thumbnail.
66
  */
67
  public static function getThumbnail( $ID, $pg = 1, $generate_if_missing = true ) {
 
 
 
 
 
68
  $options = self::getOptions();
69
 
70
  // if we haven't saved a thumb, generate one
74
  return null;
75
  }
76
 
 
 
 
 
 
77
  // do the processing
78
  $file = get_attached_file( $ID );
79
 
inc/class-util.php CHANGED
@@ -96,4 +96,25 @@ class DG_Util {
96
 
97
  return $default;
98
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
96
 
97
  return $default;
98
  }
99
+
100
+ /**
101
+ * Wrapper method which handles deciding whether to include minified assets. Minified files are not used
102
+ * in WP_DEBUG mode to make troubleshooting easier.
103
+ *
104
+ * @param $handle string Unique identifier for the script/style.
105
+ * @param $src string Relative path to asset from DG_URL.
106
+ * @param array $deps Any assets depended on by asset to be enqueued.
107
+ * @param bool $in_footer For scripts, dictates whether to put in footer.
108
+ */
109
+ public static function enqueueAsset( $handle, $src, $deps = array(), $in_footer = true ) {
110
+ if ( !defined('WP_DEBUG') || !WP_DEBUG ) {
111
+ $src = preg_replace('/^(.*)\.(css|js)$/', '$1.min.$2', $src, 1);
112
+ }
113
+
114
+ if ( preg_match( '/.js/', $src ) ) {
115
+ wp_enqueue_script( $handle, DG_URL . $src, $deps, DG_VERSION, $in_footer );
116
+ } else {
117
+ wp_enqueue_style( $handle, DG_URL . $src, $deps, DG_VERSION );
118
+ }
119
+ }
120
  }