Document Gallery - Version 3.2

Version Description

  • Enhancement: The long awaited option to open thumbnail links in a new window has been added. Simply use [dg new_window=true].
Download this release

Release Info

Developer demur
Plugin Icon 128x128 Document Gallery
Version 3.2
Comparing to
See all releases

Code changes from version 3.1 to 3.2

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: 3.6
6
  Tested up to: 4.2.2
7
- Stable tag: 3.1
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -55,11 +55,9 @@ In order to include all compatible documents from a given page or post, you
55
  must include the following shortcode in the post: `[dg]`.
56
 
57
  In addition to the default behavior, the plugin provides many options to
58
- customize behavior with various attributes, seen below:
59
 
60
- `[dg [fancy=<true/false>] [attachment_pg=<true/false>]
61
- [category/custom_taxon_name=<**comma-separated list of taxon values**> [relation=<AND/OR>]]
62
- [descriptions=<true/false>] [order=<ASC/DESC>] [orderby=<**see below**>]]`
63
 
64
  Though the shortcode above may seem far from "short," none of the attributes are
65
  required and most users will find that the plugin meets your needs "out of the box"
@@ -67,10 +65,7 @@ without any added attributes.
67
 
68
  **Default Values**
69
 
70
- By default, document gallery will use `no descriptions`, `orderby menu_order`
71
- , `ASC order`, `no attachment_pg links`, and `no images` from the `local post`
72
- if you do not specify otherwise. These defaults can be configured in your dashboard
73
- under `Settings -> Document Gallery`.
74
 
75
  **Attachment Page Option** *(New in Version 1.1)*
76
 
@@ -156,6 +151,10 @@ not included by default). To do this, you would simply set
156
  from the default value. You could also create a gallery which only includes PDFs
157
  by setting `mime_types=application/pdf`.
158
 
 
 
 
 
159
  **Order Option**
160
 
161
  This option works alongside the `orderby` option to determine whether the
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.2.2
7
+ Stable tag: 3.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
55
  must include the following shortcode in the post: `[dg]`.
56
 
57
  In addition to the default behavior, the plugin provides many options to
58
+ customize behavior with various attributes, some of which are shown below:
59
 
60
+ `[dg [fancy=<true/false>] [attachment_pg=<true/false>] [descriptions=<true/false>] [order=<ASC/DESC>] [orderby=<**see below**>]]`
 
 
61
 
62
  Though the shortcode above may seem far from "short," none of the attributes are
63
  required and most users will find that the plugin meets your needs "out of the box"
65
 
66
  **Default Values**
67
 
68
+ Default document gallery behavior can be configured in your dashboard under `Settings -> Document Gallery`.
 
 
 
69
 
70
  **Attachment Page Option** *(New in Version 1.1)*
71
 
151
  from the default value. You could also create a gallery which only includes PDFs
152
  by setting `mime_types=application/pdf`.
153
 
154
+ **New Window Option** *(New in Version 3.2)*
155
+
156
+ If true, clicking one of the documents in your gallery will open the target link in a new window/tab.
157
+
158
  **Order Option**
159
 
160
  This option works alongside the `orderby` option to determine whether the
admin/class-admin.php CHANGED
@@ -298,6 +298,18 @@ class DG_Admin {
298
  'option_name' => DG_OPTION_NAME,
299
  'description' => __('Comma-delimited list of <a href="http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types">MIME types</a>.', 'document-gallery')
300
  ));
 
 
 
 
 
 
 
 
 
 
 
 
301
 
302
  add_settings_field(
303
  'gallery_defaults_post_status', 'post_status',
298
  'option_name' => DG_OPTION_NAME,
299
  'description' => __('Comma-delimited list of <a href="http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types">MIME types</a>.', 'document-gallery')
300
  ));
301
+
302
+ add_settings_field(
303
+ 'gallery_defaults_new_window', 'new_window',
304
+ array(__CLASS__, 'renderCheckboxField'),
305
+ DG_OPTION_NAME, 'gallery_defaults',
306
+ array (
307
+ 'label_for' => 'label_gallery_defaults_new_window',
308
+ 'name' => 'gallery_defaults][new_window',
309
+ 'value' => esc_attr($defaults['new_window']),
310
+ 'option_name' => DG_OPTION_NAME,
311
+ 'description' => __('Open thumbnail links in new window.', 'document-gallery')
312
+ ));
313
 
314
  add_settings_field(
315
  'gallery_defaults_post_status', 'post_status',
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.1
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.1');
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.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.2');
16
 
17
  // define helper paths & URLs
18
  define('DG_BASENAME', plugin_basename(__FILE__));
inc/class-document.php CHANGED
@@ -64,9 +64,10 @@ class DG_Document {
64
  $description = ' <p>%description%</p>';
65
  }
66
 
 
67
  $doc_icon =
68
  ' <div class="document-icon">' . PHP_EOL .
69
- ' <a href="%link%"><img src="%img%" title="%title_attribute%" alt="%title_attribute%" /><br>%title%</a>' . PHP_EOL .
70
  ' </div>' . PHP_EOL .
71
  $description;
72
 
64
  $description = ' <p>%description%</p>';
65
  }
66
 
67
+ $target = $this->gallery->openLinkInNewWindow() ? '_blank' : '_self';
68
  $doc_icon =
69
  ' <div class="document-icon">' . PHP_EOL .
70
+ " <a href=\"%link%\" target=\"$target\"><img src=\"%img%\" title=\"%title_attribute%\" alt=\"%title_attribute%\" /><br>%title%</a>" . PHP_EOL .
71
  ' </div>' . PHP_EOL .
72
  $description;
73
 
inc/class-gallery.php CHANGED
@@ -31,6 +31,13 @@ class DG_Gallery {
31
  public function linkToAttachmentPg() {
32
  return $this->atts['attachment_pg'];
33
  }
 
 
 
 
 
 
 
34
 
35
  /**
36
  * @return bool Whether to use "fancy" thumbnails.
@@ -364,6 +371,22 @@ class DG_Gallery {
364
  return $value;
365
  }
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  /**
368
  * Takes the provided value and returns a sanitized value.
369
  * @param string $value The order value to be sanitized.
31
  public function linkToAttachmentPg() {
32
  return $this->atts['attachment_pg'];
33
  }
34
+
35
+ /**
36
+ * @return bool Whether to open thumb links in new window.
37
+ */
38
+ public function openLinkInNewWindow() {
39
+ return $this->atts['new_window'];
40
+ }
41
 
42
  /**
43
  * @return bool Whether to use "fancy" thumbnails.
371
  return $value;
372
  }
373
 
374
+ /**
375
+ * Takes the provided value and returns a sanitized value.
376
+ * @param string $value The new_window value to be sanitized.
377
+ * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
378
+ * @return bool The sanitized new_window value.
379
+ */
380
+ private static function sanitizeNewWindow($value, &$err) {
381
+ $ret = self::toBool($value);
382
+
383
+ if(is_null($ret)) {
384
+ $err = sprintf(self::$binary_err, 'new_window', 'true', 'false', $value);
385
+ }
386
+
387
+ return $ret;
388
+ }
389
+
390
  /**
391
  * Takes the provided value and returns a sanitized value.
392
  * @param string $value The order value to be sanitized.
inc/class-setup.php CHANGED
@@ -74,7 +74,10 @@ class DG_Setup {
74
  'limit' => -1,
75
 
76
  // # of columns to be used in gallery
77
- 'columns' => 4
 
 
 
78
  ),
79
  'css' => array(
80
  // plain text of CSS to be edited by user
@@ -148,6 +151,7 @@ class DG_Setup {
148
  self::twoPointThree($options);
149
  self::threePointZeroBeta($options);
150
  self::threePointOne($options);
 
151
 
152
  // update plugin meta data
153
  $options['meta']['version'] = DG_VERSION;
@@ -288,6 +292,17 @@ class DG_Setup {
288
  }
289
  }
290
 
 
 
 
 
 
 
 
 
 
 
 
291
  /**
292
  * Sets up Document Gallery on all blog(s) activated.
293
  * @param bool $networkwide Whether this is a network-wide update (multisite only).
74
  'limit' => -1,
75
 
76
  // # of columns to be used in gallery
77
+ 'columns' => 4,
78
+
79
+ // whether to open documents in new window
80
+ 'new_window' => false
81
  ),
82
  'css' => array(
83
  // plain text of CSS to be edited by user
151
  self::twoPointThree($options);
152
  self::threePointZeroBeta($options);
153
  self::threePointOne($options);
154
+ self::threePointTwo($options);
155
 
156
  // update plugin meta data
157
  $options['meta']['version'] = DG_VERSION;
292
  }
293
  }
294
 
295
+ /**
296
+ * Adds 'new_window' under gallery options.
297
+ *
298
+ * @param unknown $options
299
+ */
300
+ private static function threePointTwo(&$options) {
301
+ if (version_compare($options['meta']['version'], '3.2', '<')) {
302
+ $options['gallery']['new_window'] = false;
303
+ }
304
+ }
305
+
306
  /**
307
  * Sets up Document Gallery on all blog(s) activated.
308
  * @param bool $networkwide Whether this is a network-wide update (multisite only).