Document Gallery - Version 4.4.1

Version Description

  • Enhancement: Added support for %date% and %time% to dg_icon_template.
Download this release

Release Info

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

Code changes from version 4.4 to 4.4.1

Files changed (3) hide show
  1. README.txt +42 -8
  2. document-gallery.php +2 -2
  3. inc/class-document.php +5 -3
README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dan.rossiter, demur
3
  Tags: attachments, library, thumbnail, documents, gallery, word, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 4.2
6
- Tested up to: 4.7
7
- Stable tag: 4.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -283,16 +283,47 @@ you need specific to that document. The filter exposes 5 special tags
283
  which are replaced during gallery generation with document-specific data.
284
  These tags are as follows:
285
 
286
- * **%link%**: The URL that will be loaded when the user clicks the icon.
287
- * **%target%**: The target attribute for the anchor tag (e.g.: _blank, _self).
288
- * **%img%**: The URL pointing the the image that will be displayed.
289
- * **%title%**: The human-readable title of the attachment.
290
- * **%title_attribute%**: The escaped title (above), safe for using HTML tag attributes.
291
  * **%description%**: The attachment description (only present when rendering descriptions).
292
  * **%extension%**: The document file extension.
 
 
 
293
  * **%size%**: The human-readable file size formatted by
294
  [size_format](https://codex.wordpress.org/Function_Reference/size_format).
295
- * **%path%**: The system path pointing to the document.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
  **Filter Thumbnail Generation Methods**
298
 
@@ -439,6 +470,9 @@ To see a list of features planned for the future as well as to propose your own
439
  ideas for future Document Gallery development, take a look at our
440
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
441
 
 
 
 
442
  = 4.4 =
443
  * **Enhancement:** Document Gallery updated to support integration with
444
  [WP Real Media Library](https://codecanyon.net/item/wordpress-real-media-library-media-categories-folders/13155134).
3
  Tags: attachments, library, thumbnail, documents, gallery, word, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 4.2
6
+ Tested up to: 4.8
7
+ Stable tag: 4.4.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
283
  which are replaced during gallery generation with document-specific data.
284
  These tags are as follows:
285
 
286
+ * **%date%**: The date that the attachment was added to WordPress.
 
 
 
 
287
  * **%description%**: The attachment description (only present when rendering descriptions).
288
  * **%extension%**: The document file extension.
289
+ * **%img%**: The URL pointing the the image that will be displayed.
290
+ * **%link%**: The URL that will be loaded when the user clicks the icon.
291
+ * **%path%**: The system path pointing to the document.
292
  * **%size%**: The human-readable file size formatted by
293
  [size_format](https://codex.wordpress.org/Function_Reference/size_format).
294
+ * **%target%**: The target attribute for the anchor tag (e.g.: _blank, _self).
295
+ * **%time%**: The time that the attachment was added to WordPress.
296
+ * **%title%**: The human-readable title of the attachment.
297
+ * **%title_attribute%**: The escaped title (above), safe for using HTML tag attributes.
298
+
299
+
300
+ Below is an example that uses all three above filter methods to convert the output from a div-based
301
+ layout to a table-based layout with no icons, displaying the date of upload in the left column and
302
+ the title as a hyperlink to the attachment in the right column.
303
+
304
+ `function dg_gallery_template($gallery, $use_descriptions) {
305
+ if ( ! $use_descriptions ) {
306
+ $gallery = '<table id="%id%" class="%class%" %data%>%rows%</table>';
307
+ }
308
+ return $gallery;
309
+ }
310
+ add_filter( 'dg_gallery_template', 'dg_gallery_template', 10, 2 );
311
+
312
+ function dg_row_template($row, $use_descriptions) {
313
+ if ( ! $use_descriptions ) {
314
+ $row = '<tr class="%class%">%icons%</tr>';
315
+ }
316
+ return $row;
317
+ }
318
+ add_filter( 'dg_row_template', 'dg_row_template', 10, 2 );
319
+
320
+ function dg_icon_template($icon, $use_descriptions, $id) {
321
+ if ( ! $use_descriptions ) {
322
+ $icon = '<td>%date%</td><td><a href="%link%" target="%target%"><span class="title">%title%</title></td>';
323
+ }
324
+ return $icon;
325
+ }
326
+ add_filter( 'dg_icon_template', 'dg_icon_template', 10, 3 );`
327
 
328
  **Filter Thumbnail Generation Methods**
329
 
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
+
476
  = 4.4 =
477
  * **Enhancement:** Document Gallery updated to support integration with
478
  [WP Real Media Library](https://codecanyon.net/item/wordpress-real-media-library-media-categories-folders/13155134).
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
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' );
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.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' );
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;
17
 
18
  /*==========================================================================
19
  * GETTERS
@@ -109,6 +109,8 @@ class DG_Document {
109
  $this->extension = $wp_filetype['ext'];
110
  $size = @filesize( $this->path );
111
  $this->size = ($size !== false) ? size_format( $size ) : '0';
 
 
112
  }
113
 
114
  /*==========================================================================
@@ -145,8 +147,8 @@ class DG_Document {
145
  $thumb = DG_DefaultThumber::init()->getThumbnail( $this->ID );
146
  }
147
 
148
- $repl = array( $this->link, $thumb, $this->title_attribute, $this->title, $target, $this->extension, $this->size, $this->path, $data );
149
- $find = array( '%link%', '%img%', '%title_attribute%', '%title%', '%target%', '%extension%', '%size%', '%path%', '%data%' );
150
 
151
  // if descriptions then add filterable tag and value to replaced tag
152
  if ( $this->gallery->useDescriptions() ) {
13
  *=========================================================================*/
14
 
15
  // general document data
16
+ private $description, $gallery, $ID, $link, $title, $title_attribute, $path, $extension, $size, $date, $time;
17
 
18
  /*==========================================================================
19
  * GETTERS
109
  $this->extension = $wp_filetype['ext'];
110
  $size = @filesize( $this->path );
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
  $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() ) {