Document Gallery - Version 2.0.1

Version Description

  • Bug Fix: Resolves issue with 2.0 where DG options were not properly initialized when the plugin was updated. This caused the settings page to behave oddly and many other things throughout to not work as expected when you updated through the dashboard. Thanks to jawhite & rigbypa for reporting this!
Download this release

Release Info

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

Code changes from version 2.0 to 2.0.1

Files changed (4) hide show
  1. README.txt +8 -1
  2. admin/class-admin.php +1 -1
  3. document-gallery.php +5 -24
  4. inc/class-setup.php +19 -13
README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: dan.rossiter
3
  Tags: attachments, thumbnail, documents, gallery, MS office, pdf
4
  Requires at least: 3.6
5
  Tested up to: 3.8.1
6
- Stable tag: 2.0
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -259,6 +259,13 @@ Note that the display inherits styling from your active theme.
259
  forum](http://wordpress.org/support/plugin/document-gallery) if you have
260
  ideas)!
261
 
 
 
 
 
 
 
 
262
  = 2.0 =
263
  * **Enhancement:** This release is a **BIG** deal! We are introducing true
264
  document thumbnails (rather than the boring static images that were the same
3
  Tags: attachments, thumbnail, documents, gallery, MS office, pdf
4
  Requires at least: 3.6
5
  Tested up to: 3.8.1
6
+ Stable tag: 2.0.1
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
259
  forum](http://wordpress.org/support/plugin/document-gallery) if you have
260
  ideas)!
261
 
262
+ = 2.0.1 =
263
+ * **Bug Fix:** Resolves issue with `2.0` where DG options were not properly
264
+ initialized when the plugin was updated. This caused the settings page to
265
+ behave oddly and many other things throughout to not work as expected when
266
+ you updated through the dashboard. Thanks to jawhite & rigbypa for
267
+ [reporting this](http://wordpress.org/support/topic/errors-after-updating-to-20)!
268
+
269
  = 2.0 =
270
  * **Enhancement:** This release is a **BIG** deal! We are introducing true
271
  document thumbnails (rather than the boring static images that were the same
admin/class-admin.php CHANGED
@@ -45,7 +45,7 @@ class DG_Admin {
45
  * Registers stylesheet for admin options page.
46
  */
47
  public static function registerAdminStyle() {
48
- wp_register_style('dg-admin', DG_URL . 'admin/css/style.css', null, DocumentGallery::version());
49
  }
50
 
51
  /**
45
  * Registers stylesheet for admin options page.
46
  */
47
  public static function registerAdminStyle() {
48
+ wp_register_style('dg-admin', DG_URL . 'admin/css/style.css', null, DG_VERSION);
49
  }
50
 
51
  /**
document-gallery.php CHANGED
@@ -4,7 +4,7 @@ defined('WPINC') OR exit;
4
  /*
5
  Plugin Name: Document Gallery
6
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
7
- Version: 2.0
8
  Author: Dan Rossiter
9
  Author URI: http://danrossiter.org/
10
  License: GPLv2
@@ -12,6 +12,7 @@ defined('WPINC') OR exit;
12
  */
13
 
14
  // define helper paths & URLs
 
15
  define('DG_URL', plugin_dir_url(__FILE__));
16
  define('DG_PATH', plugin_dir_path(__FILE__));
17
  if(!defined('WP_INCLUDE_DIR')) {
@@ -24,11 +25,11 @@ if(!defined('WP_ADMIN_DIR')) {
24
  // init DG options for use throughout plugin
25
  global $dg_options;
26
  define('DG_OPTION_NAME', 'document_gallery');
27
- $dg_options = get_option(DG_OPTION_NAME);
28
 
29
  // handle activation and uninstallation
30
  include_once DG_PATH . 'inc/class-setup.php';
31
- register_activation_hook(__FILE__, array('DG_Setup', 'activation'));
32
  register_uninstall_hook(__FILE__, array('DG_Setup', 'uninstall'));
33
 
34
  // I18n
@@ -91,7 +92,7 @@ class DocumentGallery {
91
  public static function enqueueGalleryStyle() {
92
  global $dg_options;
93
  wp_register_style('dg-main', DG_URL . 'assets/css/style.css', null,
94
- self::version() . ':' . $dg_options['css']['version']);
95
  wp_enqueue_style('dg-main');
96
  }
97
 
@@ -119,26 +120,6 @@ class DocumentGallery {
119
  * HELPER FUNCTIONS
120
  *=========================================================================*/
121
 
122
- /**
123
- * Gets the current version of the plugin.
124
- * @param bool recalculate Whether to re-read the file for version number.
125
- * @return str DG version installed.
126
- */
127
- public static function version($recalculate = false) {
128
- static $version = null;
129
-
130
- if ($recalculate) {
131
- include_once WP_ADMIN_DIR . '/includes/plugin.php';
132
- $data = get_plugin_data(__FILE__, false);
133
- $version = $data['Version'];
134
- } elseif(is_null($version)) {
135
- global $dg_options;
136
- $version = $dg_options['version'];
137
- }
138
-
139
- return $version;
140
- }
141
-
142
  /**
143
  * Blocks instantiation. All functions are static.
144
  */
4
  /*
5
  Plugin Name: Document Gallery
6
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
7
+ Version: 2.0.1
8
  Author: Dan Rossiter
9
  Author URI: http://danrossiter.org/
10
  License: GPLv2
12
  */
13
 
14
  // define helper paths & URLs
15
+ define('DG_VERSION', '2.0.1');
16
  define('DG_URL', plugin_dir_url(__FILE__));
17
  define('DG_PATH', plugin_dir_path(__FILE__));
18
  if(!defined('WP_INCLUDE_DIR')) {
25
  // init DG options for use throughout plugin
26
  global $dg_options;
27
  define('DG_OPTION_NAME', 'document_gallery');
28
+ $dg_options = get_option(DG_OPTION_NAME, null);
29
 
30
  // handle activation and uninstallation
31
  include_once DG_PATH . 'inc/class-setup.php';
32
+ DG_Setup::maybeUpdate();
33
  register_uninstall_hook(__FILE__, array('DG_Setup', 'uninstall'));
34
 
35
  // I18n
92
  public static function enqueueGalleryStyle() {
93
  global $dg_options;
94
  wp_register_style('dg-main', DG_URL . 'assets/css/style.css', null,
95
+ DG_VERSION . ':' . $dg_options['css']['version']);
96
  wp_enqueue_style('dg-main');
97
  }
98
 
120
  * HELPER FUNCTIONS
121
  *=========================================================================*/
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  /**
124
  * Blocks instantiation. All functions are static.
125
  */
inc/class-setup.php CHANGED
@@ -12,6 +12,7 @@ class DG_Setup {
12
  * @return array Contains default options for DG.
13
  */
14
  public static function getDefaultOptions() {
 
15
  return array(
16
  'thumber' => array(
17
  'thumbs' => array(),
@@ -39,24 +40,29 @@ class DG_Setup {
39
  )
40
  ),
41
  'css' => array('version' => 0, 'text' => ''),
42
- 'version' => DocumentGallery::version(true)
43
  );
44
  }
45
 
46
  /**
47
- * Runs when DG is activated.
48
  */
49
- public static function activation() {
50
- $options = get_option(DG_OPTION_NAME, null);
51
- if (is_null($options)) {
52
- // first installation
53
- add_option(DG_OPTION_NAME, self::getDefaultOptions());
54
- } else if (DocumentGallery::version(true) !== $options['version']) {
55
- // update version number
56
- $options['version'] = DocumentGallery::version(true);
57
- update_option(DG_OPTION_NAME, $options);
58
- if ('' !== $options['css']['text']) {
59
- DocumentGallery::updateUserGalleryStyle($options['css']['text']);
 
 
 
 
 
60
  }
61
  }
62
  }
12
  * @return array Contains default options for DG.
13
  */
14
  public static function getDefaultOptions() {
15
+ include_once DG_PATH . 'inc/class-thumber.php';
16
  return array(
17
  'thumber' => array(
18
  'thumbs' => array(),
40
  )
41
  ),
42
  'css' => array('version' => 0, 'text' => ''),
43
+ 'version' => DG_VERSION
44
  );
45
  }
46
 
47
  /**
48
+ * Runs every page load, updates when needed.
49
  */
50
+ public static function maybeUpdate() {
51
+ global $dg_options;
52
+
53
+ // first installation
54
+ if (is_null($dg_options)) {
55
+ $options = self::getDefaultOptions();
56
+ add_option(DG_OPTION_NAME, $options);
57
+ }
58
+
59
+ // do update
60
+ elseif (DG_VERSION !== $dg_options['version']) {
61
+ $dg_options['version'] = DG_VERSION;
62
+ update_option(DG_OPTION_NAME, $dg_options);
63
+
64
+ if ('' !== $dg_options['css']['text']) {
65
+ DocumentGallery::updateUserGalleryStyle($dg_options['css']['text']);
66
  }
67
  }
68
  }