Google Doc Embedder - Version 2.5.11

Version Description

  • Fixed: Settings and profiles import
  • Changed: Removed beta delivery API (disabled in 2.5.9)
Download this release

Release Info

Developer k3davis
Plugin Icon wp plugin Google Doc Embedder
Version 2.5.11
Comparing to
See all releases

Code changes from version 2.5.10 to 2.5.11

functions-admin.php CHANGED
@@ -671,8 +671,6 @@ function gde_register_mce_button( $buttons ) {
671
  return $buttons;
672
  }
673
 
674
- /* BETA CHECKING ****/
675
-
676
  /**
677
  * Check current beta status
678
  *
@@ -733,130 +731,6 @@ function gde_warn_on_plugin_page( $plugin_file ) {
733
  }
734
  }
735
 
736
- /**
737
- * Run beta checking process
738
- *
739
- * @since 2.5.0.1
740
- * @return bool True or false, there is a (newer) beta available
741
- */
742
- function gde_check_for_beta( $plugin_file ) {
743
- return false; // disable beta api (bandwidth issues)
744
- global $gdeoptions, $pdata;
745
-
746
- // beta checking is enabled
747
- if ( $gdeoptions['beta_check'] == "yes" ) {
748
-
749
- if ( gde_beta_available() ) {
750
-
751
- require GDE_PLUGIN_DIR . 'libs/lib-betacheck.php';
752
- $betacheck = new PluginUpdateChecker(
753
- GDE_BETA_API . 'beta-info/gde',
754
- $plugin_file,
755
- $pdata['slug']
756
- );
757
-
758
- if ( ! $state = get_option('external_updates-' . $pdata['slug']) ) {
759
- // get beta info if not cached
760
- $betacheck->checkForUpdates();
761
- if ( ! $state = get_option('external_updates-' . $pdata['slug']) ) {
762
- // something's wrong with the process - skip
763
- gde_dx_log("Can't fetch beta info - skipping");
764
- return false;
765
- } else {
766
- if ( version_compare( $state->update->version, $pdata['Version'], '>' ) ) {
767
- return true;
768
- }
769
- }
770
- } elseif ( version_compare( $state->update->version, $pdata['Version'], '>' ) ) {
771
- return true;
772
- }
773
- }
774
- }
775
-
776
- // otherwise...
777
- return false;
778
- }
779
-
780
- /**
781
- * Check to see if a beta is available (generally or to this install's API key)
782
- *
783
- * @since 2.5.0.1
784
- * @return bool Whether or not a new beta is available
785
- */
786
- function gde_beta_available() {
787
- return false; // disable beta api (bandwidth issues)
788
- global $gdeoptions, $pdata;
789
-
790
- $key = 'gde_beta_version';
791
-
792
- if ( $avail_version = get_site_transient( $key ) ) {
793
- // transient already set - compare versions
794
- if ( version_compare( $pdata['Version'], $avail_version, '>=' ) ) {
795
- // installed version is same or newer, don't do anything
796
- return false;
797
- } else {
798
- // transient is newer, get beta info (no version check necessary)
799
- return true;
800
- }
801
- } else {
802
- // beta status unknown - attempt to fetch
803
- $api_url = GDE_BETA_API . "versions/gde";
804
-
805
- if ( ! empty ( $gdeoptions['api_key'] ) ) {
806
- $api_url .= '?api_key=' . $gdeoptions['api_key'];
807
- }
808
-
809
- gde_dx_log("Performing remote beta check");
810
- $response = wp_remote_get( $api_url );
811
-
812
- // set checking interval lower if currently running a beta
813
- if ( gde_is_beta() ) {
814
- $hours = 3;
815
- } else {
816
- $hours = 24;
817
- }
818
-
819
- if ( ! is_wp_error( $response ) ) {
820
- if ( $json = json_decode( wp_remote_retrieve_body( $response ) ) ) {
821
- if ( isset( $json->beta->version ) ) {
822
- $ver = $json->beta->version;
823
- gde_dx_log("Beta detected: ".$ver);
824
- }
825
- if ( ! empty( $ver ) ) {
826
- gde_dx_log("Beta detected, don't check again for $hours hours");
827
- set_site_transient( $key, $ver, 60*60*$hours );
828
-
829
- // there is a beta available, let the checker decide if it's relevant
830
- return true;
831
- } else {
832
- // no beta available - don't check again for x hours
833
- gde_dx_log("No beta detected, check again in $hours hours");
834
- set_site_transient( $key, $pdata['Version'], 60*60*24 );
835
- return false;
836
- }
837
- }
838
- }
839
-
840
- // otherwise (in case of retrieve failure)
841
- return false;
842
- }
843
- }
844
-
845
- /**
846
- * Include custom js for plugin page (beta notification)
847
- *
848
- * @since 2.5.0.1
849
- * @return void
850
- */
851
- function gde_admin_beta_js_update() {
852
- global $pagenow;
853
-
854
- if ( current_user_can('activate_plugins' && $pagenow == 'plugins.php' ) ) {
855
- $js = GDE_PLUGIN_URL . 'js/gde-betanotify.js';
856
- wp_enqueue_script( 'gde_betanotify', $js );
857
- }
858
- }
859
-
860
  /**
861
  * Check for existence and valid content of dx log
862
  *
671
  return $buttons;
672
  }
673
 
 
 
674
  /**
675
  * Check current beta status
676
  *
731
  }
732
  }
733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734
  /**
735
  * Check for existence and valid content of dx log
736
  *
functions.php CHANGED
@@ -17,14 +17,13 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
17
  @define( 'GDE_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
18
  @define( 'GDE_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
19
 
20
- // external urls (help, beta API, etc.)
21
  @define( 'GDE_STDOPT_URL', 'http://www.davistribe.org/gde/settings/viewer-options/' );
22
  @define( 'GDE_ENHOPT_URL', 'http://www.davistribe.org/gde/settings/enhanced-options/' );
23
  @define( 'GDE_PROOPT_URL', 'http://www.davistribe.org/gde/settings/viewer-profiles/' );
24
  @define( 'GDE_ADVOPT_URL', 'http://www.davistribe.org/gde/settings/advanced-options/' );
25
  @define( 'GDE_FORUM_URL', 'http://wordpress.org/support/plugin/google-document-embedder' );
26
  @define( 'GDE_WP_URL', 'http://wordpress.org/extend/plugins/google-document-embedder/' );
27
- //@define( 'GDE_BETA_API', 'http://dev.davismetro.com/api/1.0/' );
28
 
29
  /**
30
  * List supported extensions & MIME types
17
  @define( 'GDE_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
18
  @define( 'GDE_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
19
 
20
+ // help links
21
  @define( 'GDE_STDOPT_URL', 'http://www.davistribe.org/gde/settings/viewer-options/' );
22
  @define( 'GDE_ENHOPT_URL', 'http://www.davistribe.org/gde/settings/enhanced-options/' );
23
  @define( 'GDE_PROOPT_URL', 'http://www.davistribe.org/gde/settings/viewer-profiles/' );
24
  @define( 'GDE_ADVOPT_URL', 'http://www.davistribe.org/gde/settings/advanced-options/' );
25
  @define( 'GDE_FORUM_URL', 'http://wordpress.org/support/plugin/google-document-embedder' );
26
  @define( 'GDE_WP_URL', 'http://wordpress.org/extend/plugins/google-document-embedder/' );
 
27
 
28
  /**
29
  * List supported extensions & MIME types
gviewer.php CHANGED
@@ -8,7 +8,7 @@ Author: Kevin Davis
8
  Author URI: http://www.davistribe.org/
9
  Text Domain: gde
10
  Domain Path: /languages/
11
- Version: 2.5.10
12
  License: GPLv2
13
  */
14
 
@@ -331,14 +331,8 @@ if ( is_admin() ) {
331
  // add quick settings link to plugin list
332
  add_filter( "plugin_action_links_" . plugin_basename( __FILE__ ), 'gde_actlinks' );
333
 
334
- // beta notification (if enabled)
335
- if ( gde_check_for_beta( __FILE__ ) ) {
336
- // override plugin update text
337
- add_action( 'admin_enqueue_scripts', 'gde_admin_beta_js_update' );
338
- } else {
339
- // no update available, but notify if currently using a beta
340
- add_action( 'after_plugin_row', 'gde_warn_on_plugin_page' );
341
- }
342
 
343
  // editor integration
344
  if ( ! isset( $gdeoptions['ed_disable'] ) || $gdeoptions['ed_disable'] == "no" ) {
8
  Author URI: http://www.davistribe.org/
9
  Text Domain: gde
10
  Domain Path: /languages/
11
+ Version: 2.5.11
12
  License: GPLv2
13
  */
14
 
331
  // add quick settings link to plugin list
332
  add_filter( "plugin_action_links_" . plugin_basename( __FILE__ ), 'gde_actlinks' );
333
 
334
+ // notify if currently using a beta
335
+ add_action( 'after_plugin_row', 'gde_warn_on_plugin_page' );
 
 
 
 
 
 
336
 
337
  // editor integration
338
  if ( ! isset( $gdeoptions['ed_disable'] ) || $gdeoptions['ed_disable'] == "no" ) {
js/gde-betanotify.js DELETED
@@ -1,35 +0,0 @@
1
- jQuery(function ($) {
2
-
3
- /*
4
- * jQuery library for GDE (used for beta notification)
5
- */
6
-
7
- // change plugin row text - they don't make this one easy!
8
- var newtxt = 'There is a new pre-release version of Google Doc Embedder available.';
9
-
10
- var html = $('#google-doc-embedder').closest('tr').next('tr').children('.plugin-update').children('.update-message').html();
11
-
12
- var links = gde_extract_urls(html);
13
- var detailLink = links[0];
14
- var updateLink = links[1];
15
-
16
- newtxt += ' <a class="thickbox" title="Google Doc Embedder" href="' + detailLink + '">';
17
- newtxt += 'See what\'s new' + '</a>' + ' or ';
18
- newtxt += '<a href="' + updateLink + '">';
19
- newtxt += 'update now' + '</a>.';
20
-
21
- $('#google-doc-embedder').closest('tr').next('tr').children('.plugin-update').children('.update-message').html(newtxt);
22
-
23
- function gde_extract_urls(str) {
24
- var doc = document.createElement("html");
25
- doc.innerHTML = str;
26
- var links = doc.getElementsByTagName("a")
27
- var urls = [];
28
-
29
- for (var i=0; i<links.length; i++) {
30
- urls.push(links[i].getAttribute("href"));
31
- }
32
-
33
- return urls;
34
- }
35
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libs/lib-betacheck.php DELETED
@@ -1,525 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Update Checker Library 1.1
4
- * http://w-shadow.com/
5
- *
6
- * Copyright 2011 Janis Elsts
7
- * Licensed under the GNU GPL license.
8
- * http://www.gnu.org/licenses/gpl.html
9
- */
10
-
11
- if ( !class_exists('PluginUpdateChecker') ):
12
-
13
- /**
14
- * A custom plugin update checker.
15
- *
16
- * @author Janis Elsts
17
- * @copyright 2011
18
- * @version 1.1
19
- * @access public
20
- */
21
- class PluginUpdateChecker {
22
- public $metadataUrl = ''; //The URL of the plugin's metadata file.
23
- public $pluginFile = ''; //Plugin filename relative to the plugins directory.
24
- public $slug = ''; //Plugin slug.
25
- public $checkPeriod = 0; //How often to check for updates (in hours).
26
- public $optionName = ''; //Where to store the update info.
27
-
28
- private $cronHook = null;
29
-
30
- /**
31
- * Class constructor.
32
- *
33
- * @param string $metadataUrl The URL of the plugin's metadata file.
34
- * @param string $pluginFile Fully qualified path to the main plugin file.
35
- * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
36
- * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
37
- * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
38
- */
39
- function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = ''){
40
- $this->metadataUrl = $metadataUrl;
41
- $this->pluginFile = plugin_basename($pluginFile);
42
- $this->checkPeriod = $checkPeriod;
43
- $this->slug = $slug;
44
- $this->optionName = $optionName;
45
-
46
- //If no slug is specified, use the name of the main plugin file as the slug.
47
- //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
48
- if ( empty($this->slug) ){
49
- $this->slug = basename($this->pluginFile, '.php');
50
- }
51
-
52
- if ( empty($this->optionName) ){
53
- $this->optionName = 'external_updates-' . $this->slug;
54
- }
55
-
56
- $this->installHooks();
57
- }
58
-
59
- /**
60
- * Install the hooks required to run periodic update checks and inject update info
61
- * into WP data structures.
62
- *
63
- * @return void
64
- */
65
- function installHooks(){
66
- //Override requests for plugin information
67
- add_filter('plugins_api', array($this, 'injectInfo'), 10, 3);
68
-
69
- //Insert our update info into the update array maintained by WP
70
- add_filter('site_transient_update_plugins', array($this,'injectUpdate')); //WP 3.0+
71
- add_filter('transient_update_plugins', array($this,'injectUpdate')); //WP 2.8+
72
-
73
- //Set up the periodic update checks
74
- $this->cronHook = 'check_plugin_updates-' . $this->slug;
75
- if ( $this->checkPeriod > 0 ){
76
-
77
- //Trigger the check via Cron
78
- add_filter('cron_schedules', array($this, '_addCustomSchedule'));
79
- if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) {
80
- $scheduleName = 'every' . $this->checkPeriod . 'hours';
81
- wp_schedule_event(time(), $scheduleName, $this->cronHook);
82
- }
83
- add_action($this->cronHook, array($this, 'checkForUpdates'));
84
-
85
- register_deactivation_hook($this->pluginFile, array($this, '_removeUpdaterCron'));
86
-
87
- //In case Cron is disabled or unreliable, we also manually trigger
88
- //the periodic checks while the user is browsing the Dashboard.
89
- add_action( 'admin_init', array($this, 'maybeCheckForUpdates') );
90
-
91
- } else {
92
- //Periodic checks are disabled.
93
- wp_clear_scheduled_hook($this->cronHook);
94
- }
95
- }
96
-
97
- /**
98
- * Add our custom schedule to the array of Cron schedules used by WP.
99
- *
100
- * @param array $schedules
101
- * @return array
102
- */
103
- function _addCustomSchedule($schedules){
104
- if ( $this->checkPeriod && ($this->checkPeriod > 0) ){
105
- $scheduleName = 'every' . $this->checkPeriod . 'hours';
106
- $schedules[$scheduleName] = array(
107
- 'interval' => $this->checkPeriod * 3600,
108
- 'display' => sprintf('Every %d hours', $this->checkPeriod),
109
- );
110
- }
111
- return $schedules;
112
- }
113
-
114
- /**
115
- * Remove the scheduled cron event that the library uses to check for updates.
116
- *
117
- * @return void
118
- */
119
- function _removeUpdaterCron(){
120
- wp_clear_scheduled_hook($this->cronHook);
121
- }
122
-
123
- /**
124
- * Retrieve plugin info from the configured API endpoint.
125
- *
126
- * @uses wp_remote_get()
127
- *
128
- * @param array $queryArgs Additional query arguments to append to the request. Optional.
129
- * @return PluginInfo
130
- */
131
- function requestInfo($queryArgs = array()){
132
- //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
133
- $queryArgs['installed_version'] = $this->getInstalledVersion();
134
- $queryArgs = apply_filters('puc_request_info_query_args-'.$this->slug, $queryArgs);
135
-
136
- //Various options for the wp_remote_get() call. Plugins can filter these, too.
137
- $options = array(
138
- 'timeout' => 10, //seconds
139
- 'headers' => array(
140
- 'Accept' => 'application/json'
141
- ),
142
- );
143
- $options = apply_filters('puc_request_info_options-'.$this->slug, $options);
144
-
145
- //The plugin info should be at 'http://your-api.com/url/here/$slug/info.json'
146
- $url = $this->metadataUrl;
147
- if ( !empty($queryArgs) ){
148
- $url = add_query_arg($queryArgs, $url);
149
- }
150
-
151
- $result = wp_remote_get(
152
- $url,
153
- $options
154
- );
155
-
156
- //Try to parse the response
157
- $pluginInfo = null;
158
- if ( !is_wp_error($result) && isset($result['response']['code']) && ($result['response']['code'] == 200) && !empty($result['body']) ){
159
- $pluginInfo = PluginInfo::fromJson($result['body']);
160
- }
161
- $pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result);
162
- return $pluginInfo;
163
- }
164
-
165
- /**
166
- * Retrieve the latest update (if any) from the configured API endpoint.
167
- *
168
- * @uses PluginUpdateChecker::requestInfo()
169
- *
170
- * @return PluginUpdate An instance of PluginUpdate, or NULL when no updates are available.
171
- */
172
- function requestUpdate(){
173
- //For the sake of simplicity, this function just calls requestInfo()
174
- //and transforms the result accordingly.
175
- $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
176
- if ( $pluginInfo == null ){
177
- return null;
178
- }
179
- return PluginUpdate::fromPluginInfo($pluginInfo);
180
- }
181
-
182
- /**
183
- * Get the currently installed version of the plugin.
184
- *
185
- * @return string Version number.
186
- */
187
- function getInstalledVersion(){
188
- if ( !function_exists('get_plugins') ){
189
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
190
- }
191
- $allPlugins = get_plugins();
192
- if ( array_key_exists($this->pluginFile, $allPlugins) && array_key_exists('Version', $allPlugins[$this->pluginFile]) ){
193
- return $allPlugins[$this->pluginFile]['Version'];
194
- } else {
195
- return ''; //This should never happen.
196
- }
197
- }
198
-
199
- /**
200
- * Check for plugin updates.
201
- * The results are stored in the DB option specified in $optionName.
202
- *
203
- * @return void
204
- */
205
- function checkForUpdates(){
206
- $state = get_option($this->optionName);
207
- if ( empty($state) ){
208
- $state = new StdClass;
209
- $state->lastCheck = 0;
210
- $state->checkedVersion = '';
211
- $state->update = null;
212
- }
213
-
214
- $state->lastCheck = time();
215
- $state->checkedVersion = $this->getInstalledVersion();
216
- update_option($this->optionName, $state); //Save before checking in case something goes wrong
217
-
218
- $state->update = $this->requestUpdate();
219
- update_option($this->optionName, $state);
220
- }
221
-
222
- /**
223
- * Check for updates only if the configured check interval has already elapsed.
224
- *
225
- * @return void
226
- */
227
- function maybeCheckForUpdates(){
228
- if ( empty($this->checkPeriod) ){
229
- return;
230
- }
231
- /** @var $state StdClass */
232
- $state = get_option($this->optionName);
233
-
234
- $shouldCheck =
235
- empty($state) ||
236
- !isset($state->lastCheck) ||
237
- ( (time() - $state->lastCheck) >= $this->checkPeriod*3600 );
238
-
239
- if ( $shouldCheck ){
240
- $this->checkForUpdates();
241
- }
242
- }
243
-
244
- /**
245
- * Intercept plugins_api() calls that request information about our plugin and
246
- * use the configured API endpoint to satisfy them.
247
- *
248
- * @see plugins_api()
249
- *
250
- * @param mixed $result
251
- * @param string $action
252
- * @param array|object $args
253
- * @return mixed
254
- */
255
- function injectInfo($result, $action = null, $args = null){
256
- $relevant = ($action == 'plugin_information') && isset($args->slug) && ($args->slug == $this->slug);
257
- if ( !$relevant ){
258
- return $result;
259
- }
260
-
261
- $pluginInfo = $this->requestInfo();
262
- if ($pluginInfo){
263
- return $pluginInfo->toWpFormat();
264
- }
265
-
266
- return $result;
267
- }
268
-
269
- /**
270
- * Insert the latest update (if any) into the update list maintained by WP.
271
- *
272
- * @param StdClass $updates Update list.
273
- * @return StdClass Modified update list.
274
- */
275
- function injectUpdate($updates){
276
- /** @var StdClass $state */
277
- $state = get_option($this->optionName);
278
-
279
- //Is there an update to insert?
280
- if ( !empty($state) && isset($state->update) && !empty($state->update) ){
281
- //Only insert updates that are actually newer than the currently installed version.
282
- if ( version_compare($state->update->version, $this->getInstalledVersion(), '>') ){
283
- $updates->response[$this->pluginFile] = $state->update->toWpFormat();
284
- }
285
- }
286
-
287
- return $updates;
288
- }
289
-
290
- /**
291
- * Register a callback for filtering query arguments.
292
- *
293
- * The callback function should take one argument - an associative array of query arguments.
294
- * It should return a modified array of query arguments.
295
- *
296
- * @uses add_filter() This method is a convenience wrapper for add_filter().
297
- *
298
- * @param callback $callback
299
- * @return void
300
- */
301
- function addQueryArgFilter($callback){
302
- add_filter('puc_request_info_query_args-'.$this->slug, $callback);
303
- }
304
-
305
- /**
306
- * Register a callback for filtering arguments passed to wp_remote_get().
307
- *
308
- * The callback function should take one argument - an associative array of arguments -
309
- * and return a modified array or arguments. See the WP documentation on wp_remote_get()
310
- * for details on what arguments are available and how they work.
311
- *
312
- * @uses add_filter() This method is a convenience wrapper for add_filter().
313
- *
314
- * @param callback $callback
315
- * @return void
316
- */
317
- function addHttpRequestArgFilter($callback){
318
- add_filter('puc_request_info_options-'.$this->slug, $callback);
319
- }
320
-
321
- /**
322
- * Register a callback for filtering the plugin info retrieved from the external API.
323
- *
324
- * The callback function should take two arguments. If the plugin info was retrieved
325
- * successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
326
- * it will be NULL. The second argument will be the corresponding return value of
327
- * wp_remote_get (see WP docs for details).
328
- *
329
- * The callback function should return a new or modified instance of PluginInfo or NULL.
330
- *
331
- * @uses add_filter() This method is a convenience wrapper for add_filter().
332
- *
333
- * @param callback $callback
334
- * @return void
335
- */
336
- function addResultFilter($callback){
337
- add_filter('puc_request_info_result-'.$this->slug, $callback, 10, 2);
338
- }
339
- }
340
-
341
- endif;
342
-
343
- if ( !class_exists('PluginInfo') ):
344
-
345
- /**
346
- * A container class for holding and transforming various plugin metadata.
347
- *
348
- * @author Janis Elsts
349
- * @copyright 2010
350
- * @version 1.0
351
- * @access public
352
- */
353
- class PluginInfo {
354
- //Most fields map directly to the contents of the plugin's info.json file.
355
- //See the relevant docs for a description of their meaning.
356
- public $name;
357
- public $slug;
358
- public $version;
359
- public $homepage;
360
- public $sections;
361
- public $download_url;
362
-
363
- public $author;
364
- public $author_homepage;
365
-
366
- public $requires;
367
- public $tested;
368
- public $upgrade_notice;
369
-
370
- public $rating;
371
- public $num_ratings;
372
- public $downloaded;
373
- public $last_updated;
374
-
375
- public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.
376
-
377
- /**
378
- * Create a new instance of PluginInfo from JSON-encoded plugin info
379
- * returned by an external update API.
380
- *
381
- * @param string $json Valid JSON string representing plugin info.
382
- * @return PluginInfo New instance of PluginInfo, or NULL on error.
383
- */
384
- public static function fromJson($json){
385
- /** @var StdClass $apiResponse */
386
- $apiResponse = json_decode($json);
387
- if ( empty($apiResponse) || !is_object($apiResponse) ){
388
- return null;
389
- }
390
-
391
- //Very, very basic validation.
392
- $valid = isset($apiResponse->name) && !empty($apiResponse->name) && isset($apiResponse->version) && !empty($apiResponse->version);
393
- if ( !$valid ){
394
- return null;
395
- }
396
-
397
- $info = new PluginInfo();
398
- foreach(get_object_vars($apiResponse) as $key => $value){
399
- $info->$key = $value;
400
- }
401
-
402
- return $info;
403
- }
404
-
405
- /**
406
- * Transform plugin info into the format used by the native WordPress.org API
407
- *
408
- * @return object
409
- */
410
- public function toWpFormat(){
411
- $info = new StdClass;
412
-
413
- //The custom update API is built so that many fields have the same name and format
414
- //as those returned by the native WordPress.org API. These can be assigned directly.
415
- $sameFormat = array(
416
- 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
417
- 'num_ratings', 'downloaded', 'homepage', 'last_updated',
418
- );
419
- foreach($sameFormat as $field){
420
- if ( isset($this->$field) ) {
421
- $info->$field = $this->$field;
422
- } else {
423
- $info->$field = null;
424
- }
425
- }
426
-
427
- //Other fields need to be renamed and/or transformed.
428
- $info->download_link = $this->download_url;
429
-
430
- if ( !empty($this->author_homepage) ){
431
- $info->author = sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
432
- } else {
433
- $info->author = $this->author;
434
- }
435
-
436
- if ( is_object($this->sections) ){
437
- $info->sections = get_object_vars($this->sections);
438
- } elseif ( is_array($this->sections) ) {
439
- $info->sections = $this->sections;
440
- } else {
441
- $info->sections = array('description' => '');
442
- }
443
-
444
- return $info;
445
- }
446
- }
447
-
448
- endif;
449
-
450
- if ( !class_exists('PluginUpdate') ):
451
-
452
- /**
453
- * A simple container class for holding information about an available update.
454
- *
455
- * @author Janis Elsts
456
- * @copyright 2010
457
- * @version 1.0
458
- * @access public
459
- */
460
- class PluginUpdate {
461
- public $id = 0;
462
- public $slug;
463
- public $version;
464
- public $homepage;
465
- public $download_url;
466
- public $upgrade_notice;
467
-
468
- /**
469
- * Create a new instance of PluginUpdate from its JSON-encoded representation.
470
- *
471
- * @param string $json
472
- * @return PluginUpdate
473
- */
474
- public static function fromJson($json){
475
- //Since update-related information is simply a subset of the full plugin info,
476
- //we can parse the update JSON as if it was a plugin info string, then copy over
477
- //the parts that we care about.
478
- $pluginInfo = PluginInfo::fromJson($json);
479
- if ( $pluginInfo != null ) {
480
- return PluginUpdate::fromPluginInfo($pluginInfo);
481
- } else {
482
- return null;
483
- }
484
- }
485
-
486
- /**
487
- * Create a new instance of PluginUpdate based on an instance of PluginInfo.
488
- * Basically, this just copies a subset of fields from one object to another.
489
- *
490
- * @param PluginInfo $info
491
- * @return PluginUpdate
492
- */
493
- public static function fromPluginInfo($info){
494
- $update = new PluginUpdate();
495
- $copyFields = array('id', 'slug', 'version', 'homepage', 'download_url', 'upgrade_notice');
496
- foreach($copyFields as $field){
497
- $update->$field = $info->$field;
498
- }
499
- return $update;
500
- }
501
-
502
- /**
503
- * Transform the update into the format used by WordPress native plugin API.
504
- *
505
- * @return object
506
- */
507
- public function toWpFormat(){
508
- $update = new StdClass;
509
-
510
- $update->id = $this->id;
511
- $update->slug = $this->slug;
512
- $update->new_version = $this->version;
513
- $update->url = $this->homepage;
514
- $update->package = $this->download_url;
515
- if ( !empty($this->upgrade_notice) ){
516
- $update->upgrade_notice = $this->upgrade_notice;
517
- }
518
-
519
- return $update;
520
- }
521
- }
522
-
523
- endif;
524
-
525
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libs/lib-profile.php CHANGED
@@ -33,18 +33,6 @@ function gde_profile_form( $id = 1 ) {
33
  }
34
  ?>
35
 
36
- <!--
37
-
38
- <?php
39
-
40
- echo "id: $id\n\n";
41
- echo gettype($p)."\n\n";
42
- print_r($p);
43
-
44
- ?>
45
-
46
- -->
47
-
48
  <div id="profile-form">
49
 
50
  <form action="" method="post">
33
  }
34
  ?>
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  <div id="profile-form">
37
 
38
  <form action="" method="post">
libs/lib-setup.php CHANGED
@@ -14,7 +14,7 @@ function gde_defaults( $type ) {
14
  $pdata = gde_get_plugin_data();
15
  $baseurl = gde_base_url();
16
  $default_lang = gde_get_locale();
17
- $apikey = gde_get_api_key( $pdata['Version'] );
18
  $env = array(
19
  'pdata' => $pdata,
20
  'baseurl' => $baseurl,
@@ -26,7 +26,7 @@ function gde_defaults( $type ) {
26
  // define "global" options (multisite only)
27
  $globalopts = array(
28
  'file_maxsize' => '12',
29
- 'beta_check' => 'yes',
30
  'api_key' => $env['apikey']
31
  );
32
 
@@ -39,7 +39,7 @@ function gde_defaults( $type ) {
39
  'error_check' => 'yes',
40
  'error_display' => 'yes',
41
  'error_log' => 'no',
42
- 'beta_check' => 'yes',
43
  'ga_enable' => 'no',
44
  'ga_category' => $env['pdata']['Name'],
45
  'ga_label' => 'url',
@@ -287,72 +287,6 @@ function gde_get_options() {
287
  return $gdeoptions;
288
  }
289
 
290
- /**
291
- * Fetch Beta API Key
292
- *
293
- * @since 2.5.0.1
294
- * @return string Stored or newly generated API key, or blank value.
295
- * @note This should only run once on activation so no transient is necessary
296
- */
297
- function gde_get_api_key( $ver ) {
298
- return ''; // disable api keyfetch (bandwidth issues)
299
- global $current_user;
300
-
301
- if ( is_multisite() ) {
302
- $gdeglobals = get_site_option( 'gde_globals' );
303
- $api = $gdeglobals['api_key'];
304
- } else {
305
- $gdeoptions = get_option( 'gde_options' );
306
- if ( isset( $gdeoptions['api_key'] ) ) {
307
- $api = $gdeoptions['api_key'];
308
- } else {
309
- $api = "";
310
- }
311
- }
312
-
313
- if ( ! empty ( $api ) ) {
314
- gde_dx_log("API key already set: $api");
315
- return $api;
316
- } else {
317
- gde_dx_log("Requesting new API key");
318
- get_currentuserinfo();
319
- $keystring = $current_user->user_login . $current_user->user_email;
320
- if ( empty($keystring) ) {
321
- $keystring = "John146JesussaidtohimIamthewaythetruthandthelifenoonecomestotheFatherexceptthroughMe";
322
- }
323
- $keystring = str_shuffle( preg_replace("/[^A-Za-z0-9]/", "", $keystring ) );
324
-
325
- // attempt get new key
326
- $api_url = GDE_BETA_API . "keygen/$keystring?p=gde&v=" . $ver;
327
- $response = wp_remote_get( $api_url );
328
-
329
- if ( is_wp_error( $response ) ) {
330
- $error = $response->get_error_message();
331
- gde_dx_log("API Error: " . $error);
332
- // can't get response
333
- return '';
334
- } else {
335
- if ( $json = json_decode( wp_remote_retrieve_body( $response ) ) ) {
336
- if ( isset( $json->api_key ) ) {
337
- $key = $json->api_key;
338
- }
339
- if ( ! empty( $key ) ) {
340
- gde_dx_log("API Key: $key");
341
- return $key;
342
- } else {
343
- gde_dx_log("API returned empty response");
344
- // empty value response
345
- return '';
346
- }
347
- } else {
348
- // invalid response
349
- gde_dx_log("API returned invalid response");
350
- return '';
351
- }
352
- }
353
- }
354
- }
355
-
356
  /**
357
  * Create/update database table to store profile data
358
  *
14
  $pdata = gde_get_plugin_data();
15
  $baseurl = gde_base_url();
16
  $default_lang = gde_get_locale();
17
+ $apikey = '';
18
  $env = array(
19
  'pdata' => $pdata,
20
  'baseurl' => $baseurl,
26
  // define "global" options (multisite only)
27
  $globalopts = array(
28
  'file_maxsize' => '12',
29
+ 'beta_check' => 'no',
30
  'api_key' => $env['apikey']
31
  );
32
 
39
  'error_check' => 'yes',
40
  'error_display' => 'yes',
41
  'error_log' => 'no',
42
+ 'beta_check' => 'no',
43
  'ga_enable' => 'no',
44
  'ga_category' => $env['pdata']['Name'],
45
  'ga_label' => 'url',
287
  return $gdeoptions;
288
  }
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  /**
291
  * Create/update database table to store profile data
292
  *
libs/tab-advanced.php CHANGED
@@ -61,15 +61,10 @@
61
  ?>
62
  </td>
63
  </tr>
64
- <tr valign="top">
65
  <th scope="row"><?php _e('Version Notifications', 'gde'); ?></th>
66
  <td>
67
- <select name="beta_check" id="beta_check">
68
- <?php
69
- gde_profile_option( $g['beta_check'], 'yes', __('All Versions', 'gde'), __('You will receive release and beta notifications', 'gde') );
70
- gde_profile_option( $g['beta_check'], 'no', __('Release Versions Only', 'gde'), __('You will not receive beta notifications', 'gde') );
71
- ?>
72
- </select><br/>
73
  <span class="gde-fnote" id="beta-h"></span>
74
  </td>
75
  </tr>
61
  ?>
62
  </td>
63
  </tr>
64
+ <tr valign="top" style="display:none;">
65
  <th scope="row"><?php _e('Version Notifications', 'gde'); ?></th>
66
  <td>
67
+ <input type="hidden" name="beta_check" value="no">
 
 
 
 
 
68
  <span class="gde-fnote" id="beta-h"></span>
69
  </td>
70
  </tr>
options.php CHANGED
@@ -124,7 +124,7 @@ if ( isset( $_POST['_general_default'] ) ) {
124
 
125
  // check import file validity
126
  if ( isset( $_FILES['import'] ) && ! empty( $_FILES['import'] ) ) {
127
- if ( $_FILES['import']['size'] > 0 && is_uploaded_file( $_FILES['import']['tmp_name'] ) && preg_match( '/json$/i', $_FILES['import']['type'] ) ) {
128
  // file OK, check for json content
129
  $json = json_decode( file_get_contents( $_FILES['import']['tmp_name'] ), true );
130
  if ( $json !== null && is_array( $json ) ) {
124
 
125
  // check import file validity
126
  if ( isset( $_FILES['import'] ) && ! empty( $_FILES['import'] ) ) {
127
+ if ( $_FILES['import']['size'] > 0 && is_uploaded_file( $_FILES['import']['tmp_name'] ) && preg_match( '/json$/i', $_FILES['import']['name'] ) ) {
128
  // file OK, check for json content
129
  $json = json_decode( file_get_contents( $_FILES['import']['tmp_name'] ), true );
130
  if ( $json !== null && is_array( $json ) ) {
readme.txt CHANGED
@@ -135,6 +135,10 @@ More common questions are answered on the GDE web site [here](http://www.davistr
135
 
136
  (E) Enhanced Viewer
137
 
 
 
 
 
138
  = 2.5.10 =
139
  * Fixed: PHP warning on multisite during uninstall (thanks TigranTovmasyan)
140
  * Changed: (E) Viewer settings use native color picker
135
 
136
  (E) Enhanced Viewer
137
 
138
+ = 2.5.11 =
139
+ * Fixed: Settings and profiles import
140
+ * Changed: Removed beta delivery API (disabled in 2.5.9)
141
+
142
  = 2.5.10 =
143
  * Fixed: PHP warning on multisite during uninstall (thanks TigranTovmasyan)
144
  * Changed: (E) Viewer settings use native color picker