Ditty News Ticker - Version 2.3.13

Version Description

  • Updated extension updater code.
Download this release

Release Info

Developer metaphorcreations
Plugin Icon 128x128 Ditty News Ticker
Version 2.3.13
Comparing to
See all releases

Code changes from version 2.3.12 to 2.3.13

ditty-news-ticker.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://dittynewsticker.com/
5
  Description: Ditty News Ticker is a multi-functional data display plugin
6
  Text Domain: ditty-news-ticker
7
  Domain Path: languages
8
- Version: 2.3.12
9
  Author: Metaphor Creations
10
  Author URI: http://www.metaphorcreations.com
11
  Contributors: metaphorcreations
@@ -62,7 +62,7 @@ final class Ditty_News_Ticker {
62
 
63
  // Plugin version
64
  if ( ! defined( 'MTPHR_DNT_VERSION' ) ) {
65
- define( 'MTPHR_DNT_VERSION', '2.3.12' );
66
  }
67
 
68
  // Plugin Folder Path
5
  Description: Ditty News Ticker is a multi-functional data display plugin
6
  Text Domain: ditty-news-ticker
7
  Domain Path: languages
8
+ Version: 2.3.13
9
  Author: Metaphor Creations
10
  Author URI: http://www.metaphorcreations.com
11
  Contributors: metaphorcreations
62
 
63
  // Plugin version
64
  if ( ! defined( 'MTPHR_DNT_VERSION' ) ) {
65
+ define( 'MTPHR_DNT_VERSION', '2.3.13' );
66
  }
67
 
68
  // Plugin Folder Path
eddsl/EDD_SL_Plugin_Updater.php CHANGED
@@ -1,25 +1,27 @@
1
  <?php
2
 
3
  // Exit if accessed directly
4
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
5
 
6
  /**
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
- * @version 1.8.0
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
14
- private $api_url = '';
15
- private $api_data = array();
16
- private $name = '';
17
- private $slug = '';
18
- private $version = '';
19
- private $wp_override = false;
20
- private $cache_key = '';
21
-
22
- private $health_check_timeout = 5;
23
 
24
  /**
25
  * Class constructor.
@@ -35,14 +37,15 @@ class EDD_SL_Plugin_Updater {
35
 
36
  global $edd_plugin_data;
37
 
38
- $this->api_url = trailingslashit( $_api_url );
39
- $this->api_data = $_api_data;
40
- $this->name = plugin_basename( $_plugin_file );
41
- $this->slug = basename( $_plugin_file, '.php' );
42
- $this->version = $_api_data['version'];
43
- $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
44
- $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
45
- $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
 
46
 
47
  $edd_plugin_data[ $this->slug ] = $this->api_data;
48
 
@@ -71,8 +74,7 @@ class EDD_SL_Plugin_Updater {
71
 
72
  add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
73
  add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
74
- remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
75
- add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
76
  add_action( 'admin_init', array( $this, 'show_changelog' ) );
77
 
78
  }
@@ -95,11 +97,7 @@ class EDD_SL_Plugin_Updater {
95
  global $pagenow;
96
 
97
  if ( ! is_object( $_transient_data ) ) {
98
- $_transient_data = new stdClass;
99
- }
100
-
101
- if ( 'plugins.php' == $pagenow && is_multisite() ) {
102
- return $_transient_data;
103
  }
104
 
105
  if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
@@ -153,122 +151,126 @@ class EDD_SL_Plugin_Updater {
153
  }
154
 
155
  /**
156
- * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
157
  *
158
  * @param string $file
159
  * @param array $plugin
160
  */
161
  public function show_update_notification( $file, $plugin ) {
162
 
163
- if ( is_network_admin() ) {
 
164
  return;
165
  }
166
 
167
- if( ! current_user_can( 'update_plugins' ) ) {
 
168
  return;
169
  }
170
 
171
- if( ! is_multisite() ) {
172
  return;
173
  }
174
 
175
- if ( $this->name != $file ) {
176
- return;
177
- }
178
-
179
- // Remove our filter on the site transient
180
- remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
181
-
182
  $update_cache = get_site_transient( 'update_plugins' );
183
 
184
- $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
185
-
186
- if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
187
-
188
- $version_info = $this->get_repo_api_data();
189
-
190
- if ( false === $version_info ) {
191
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
192
-
193
- // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
194
- if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
195
- $version_info->banners = $this->convert_object_to_array( $version_info->banners );
196
- }
197
-
198
- if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
199
- $version_info->sections = $this->convert_object_to_array( $version_info->sections );
200
- }
201
-
202
- if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
203
- $version_info->icons = $this->convert_object_to_array( $version_info->icons );
204
- }
205
-
206
- if ( isset( $version_info->contributors ) && ! is_array( $version_info->contributors ) ) {
207
- $version_info->contributors = $this->convert_object_to_array( $version_info->contributors );
208
- }
209
-
210
- $this->set_version_info_cache( $version_info );
211
- }
212
-
213
- if ( ! is_object( $version_info ) ) {
214
- return;
215
  }
 
 
216
 
217
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
218
- $update_cache->response[ $this->name ] = $version_info;
219
- } else {
220
- $update_cache->no_update[ $this->name ] = $version_info;
221
- }
222
 
223
- $update_cache->last_checked = time();
224
- $update_cache->checked[ $this->name ] = $this->version;
 
 
 
 
225
 
226
- set_site_transient( 'update_plugins', $update_cache );
 
227
 
228
- } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
- $version_info = $update_cache->response[ $this->name ];
 
 
 
 
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  }
233
 
234
- // Restore our filter
235
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
236
 
237
- if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
238
-
239
- // build a plugin list row, with update notification
240
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
241
- # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
242
- echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
243
- echo '<td colspan="3" class="plugin-update colspanchange">';
244
- echo '<div class="update-message notice inline notice-warning notice-alt">';
245
-
246
- $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
247
-
248
- if ( empty( $version_info->download_link ) ) {
249
- printf(
250
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
251
- esc_html( $version_info->name ),
252
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
253
- esc_html( $version_info->new_version ),
254
- '</a>'
255
- );
256
- } else {
257
- printf(
258
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
259
- esc_html( $version_info->name ),
260
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
261
- esc_html( $version_info->new_version ),
262
- '</a>',
263
- '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
264
- '</a>'
265
- );
266
- }
267
 
268
- do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
 
 
 
 
 
 
 
269
 
270
- echo '</div></td></tr>';
271
- }
272
  }
273
 
274
  /**
@@ -283,13 +285,13 @@ class EDD_SL_Plugin_Updater {
283
  */
284
  public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
285
 
286
- if ( $_action != 'plugin_information' ) {
287
 
288
  return $_data;
289
 
290
  }
291
 
292
- if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
293
 
294
  return $_data;
295
 
@@ -302,7 +304,7 @@ class EDD_SL_Plugin_Updater {
302
  'banners' => array(),
303
  'reviews' => false,
304
  'icons' => array(),
305
- )
306
  );
307
 
308
  // Get the transient where we store the api request for this plugin for 24 hours
@@ -319,7 +321,6 @@ class EDD_SL_Plugin_Updater {
319
  if ( false !== $api_response ) {
320
  $_data = $api_response;
321
  }
322
-
323
  } else {
324
  $_data = $edd_api_request_transient;
325
  }
@@ -344,7 +345,7 @@ class EDD_SL_Plugin_Updater {
344
  $_data->contributors = $this->convert_object_to_array( $_data->contributors );
345
  }
346
 
347
- if( ! isset( $_data->plugin ) ) {
348
  $_data->plugin = $this->name;
349
  }
350
 
@@ -364,6 +365,9 @@ class EDD_SL_Plugin_Updater {
364
  * @return array
365
  */
366
  private function convert_object_to_array( $data ) {
 
 
 
367
  $new_data = array();
368
  foreach ( $data as $key => $value ) {
369
  $new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
@@ -381,9 +385,8 @@ class EDD_SL_Plugin_Updater {
381
  */
382
  public function http_request_args( $args, $url ) {
383
 
384
- $verify_ssl = $this->verify_ssl();
385
  if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
386
- $args['sslverify'] = $verify_ssl;
387
  }
388
  return $args;
389
 
@@ -398,85 +401,68 @@ class EDD_SL_Plugin_Updater {
398
  *
399
  * @param string $_action The requested action.
400
  * @param array $_data Parameters for the API action.
401
- * @return false|object
402
  */
403
  private function api_request( $_action, $_data ) {
 
404
 
405
- global $wp_version, $edd_plugin_url_available;
406
-
407
- $verify_ssl = $this->verify_ssl();
408
-
409
- // Do a quick status check on this domain if we haven't already checked it.
410
- $store_hash = md5( $this->api_url );
411
- if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
412
- $test_url_parts = parse_url( $this->api_url );
413
-
414
- $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
415
- $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
416
- $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
417
-
418
- if ( empty( $host ) ) {
419
- $edd_plugin_url_available[ $store_hash ] = false;
420
- } else {
421
- $test_url = $scheme . '://' . $host . $port;
422
- $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
423
- $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
424
- }
425
  }
426
 
427
- if ( false === $edd_plugin_url_available[ $store_hash ] ) {
 
428
  return false;
429
  }
430
 
431
- $data = array_merge( $this->api_data, $_data );
432
-
433
- if ( $data['slug'] != $this->slug ) {
434
  return false;
435
  }
436
 
437
- if ( $this->api_url == trailingslashit ( home_url() ) ) {
438
- return false; // Don't allow a plugin to ping itself
439
- }
440
-
441
- $api_params = array(
442
- 'edd_action' => 'get_version',
443
- 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
444
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
445
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
446
- 'version' => isset( $data['version'] ) ? $data['version'] : false,
447
- 'slug' => $data['slug'],
448
- 'author' => $data['author'],
449
- 'url' => home_url(),
450
- 'beta' => ! empty( $data['beta'] ),
451
- );
452
-
453
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
454
 
455
- if ( ! is_wp_error( $request ) ) {
456
- $request = json_decode( wp_remote_retrieve_body( $request ) );
457
- }
 
 
 
 
 
 
458
 
459
- if ( $request && isset( $request->sections ) ) {
460
- $request->sections = maybe_unserialize( $request->sections );
461
- } else {
462
- $request = false;
463
  }
464
 
465
- if ( $request && isset( $request->banners ) ) {
466
- $request->banners = maybe_unserialize( $request->banners );
467
- }
 
 
 
468
 
469
- if ( $request && isset( $request->icons ) ) {
470
- $request->icons = maybe_unserialize( $request->icons );
471
  }
472
 
473
- if ( ! empty( $request->sections ) ) {
474
- foreach( $request->sections as $key => $section ) {
475
- $request->$key = (array) $section;
476
- }
477
- }
478
 
479
- return $request;
 
 
 
 
 
 
 
 
 
 
 
 
480
  }
481
 
482
  /**
@@ -484,90 +470,119 @@ class EDD_SL_Plugin_Updater {
484
  */
485
  public function show_changelog() {
486
 
487
- global $edd_plugin_data;
488
-
489
- if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
490
  return;
491
  }
492
 
493
- if( empty( $_REQUEST['plugin'] ) ) {
494
  return;
495
  }
496
 
497
- if( empty( $_REQUEST['slug'] ) ) {
498
  return;
499
  }
500
 
501
- if( ! current_user_can( 'update_plugins' ) ) {
502
- wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
503
  }
504
 
505
- $data = $edd_plugin_data[ $_REQUEST['slug'] ];
506
- $version_info = $this->get_cached_version_info();
 
 
 
 
 
507
 
508
- if( false === $version_info ) {
 
509
 
510
- $api_params = array(
511
- 'edd_action' => 'get_version',
512
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
513
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
514
- 'slug' => $_REQUEST['slug'],
515
- 'author' => $data['author'],
516
- 'url' => home_url(),
517
- 'beta' => ! empty( $data['beta'] )
518
- );
 
 
 
 
 
 
 
 
 
 
519
 
520
- $verify_ssl = $this->verify_ssl();
521
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
 
523
- if ( ! is_wp_error( $request ) ) {
524
- $version_info = json_decode( wp_remote_retrieve_body( $request ) );
525
- }
526
 
527
- if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
528
- $version_info->sections = maybe_unserialize( $version_info->sections );
529
- } else {
530
- $version_info = false;
531
- }
532
 
533
- if( ! empty( $version_info ) ) {
534
- foreach( $version_info->sections as $key => $section ) {
535
- $version_info->$key = (array) $section;
536
- }
537
- }
538
 
539
- $this->set_version_info_cache( $version_info );
 
 
 
 
540
 
541
- // Delete the unneeded option
542
- delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
543
  }
544
 
545
- if ( isset( $version_info->sections ) ) {
546
- $sections = $this->convert_object_to_array( $version_info->sections );
547
- if ( ! empty( $sections['changelog'] ) ) {
548
- echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
 
 
 
549
  }
550
  }
551
 
552
- exit;
553
  }
554
 
555
  /**
556
- * Gets the plugin's cached version information from the database.
557
  *
558
  * @param string $cache_key
559
- * @return boolean|string
560
  */
561
  public function get_cached_version_info( $cache_key = '' ) {
562
 
563
- if( empty( $cache_key ) ) {
564
- $cache_key = $this->cache_key;
565
  }
566
 
567
  $cache = get_option( $cache_key );
568
 
569
- if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
570
- return false; // Cache is expired
 
571
  }
572
 
573
  // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
@@ -588,13 +603,13 @@ class EDD_SL_Plugin_Updater {
588
  */
589
  public function set_version_info_cache( $value = '', $cache_key = '' ) {
590
 
591
- if( empty( $cache_key ) ) {
592
- $cache_key = $this->cache_key;
593
  }
594
 
595
  $data = array(
596
  'timeout' => strtotime( '+3 hours', time() ),
597
- 'value' => json_encode( $value )
598
  );
599
 
600
  update_option( $cache_key, $data, 'no' );
@@ -613,4 +628,16 @@ class EDD_SL_Plugin_Updater {
613
  return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
614
  }
615
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  }
1
  <?php
2
 
3
  // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit;
6
+ }
7
 
8
  /**
9
  * Allows plugins to use their own update API.
10
  *
11
  * @author Easy Digital Downloads
12
+ * @version 1.9.1
13
  */
14
  class EDD_SL_Plugin_Updater {
15
 
16
+ private $api_url = '';
17
+ private $api_data = array();
18
+ private $plugin_file = '';
19
+ private $name = '';
20
+ private $slug = '';
21
+ private $version = '';
22
+ private $wp_override = false;
23
+ private $beta = false;
24
+ private $failed_request_cache_key;
25
 
26
  /**
27
  * Class constructor.
37
 
38
  global $edd_plugin_data;
39
 
40
+ $this->api_url = trailingslashit( $_api_url );
41
+ $this->api_data = $_api_data;
42
+ $this->plugin_file = $_plugin_file;
43
+ $this->name = plugin_basename( $_plugin_file );
44
+ $this->slug = basename( $_plugin_file, '.php' );
45
+ $this->version = $_api_data['version'];
46
+ $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
47
+ $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
48
+ $this->failed_request_cache_key = 'edd_sl_failed_http_' . md5( $this->api_url );
49
 
50
  $edd_plugin_data[ $this->slug ] = $this->api_data;
51
 
74
 
75
  add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
76
  add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
77
+ add_action( 'after_plugin_row', array( $this, 'show_update_notification' ), 10, 2 );
 
78
  add_action( 'admin_init', array( $this, 'show_changelog' ) );
79
 
80
  }
97
  global $pagenow;
98
 
99
  if ( ! is_object( $_transient_data ) ) {
100
+ $_transient_data = new stdClass();
 
 
 
 
101
  }
102
 
103
  if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
151
  }
152
 
153
  /**
154
+ * Show the update notification on multisite subsites.
155
  *
156
  * @param string $file
157
  * @param array $plugin
158
  */
159
  public function show_update_notification( $file, $plugin ) {
160
 
161
+ // Return early if in the network admin, or if this is not a multisite install.
162
+ if ( is_network_admin() || ! is_multisite() ) {
163
  return;
164
  }
165
 
166
+ // Allow single site admins to see that an update is available.
167
+ if ( ! current_user_can( 'activate_plugins' ) ) {
168
  return;
169
  }
170
 
171
+ if ( $this->name !== $file ) {
172
  return;
173
  }
174
 
175
+ // Do not print any message if update does not exist.
 
 
 
 
 
 
176
  $update_cache = get_site_transient( 'update_plugins' );
177
 
178
+ if ( ! isset( $update_cache->response[ $this->name ] ) ) {
179
+ if ( ! is_object( $update_cache ) ) {
180
+ $update_cache = new stdClass();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
+ $update_cache->response[ $this->name ] = $this->get_repo_api_data();
183
+ }
184
 
185
+ // Return early if this plugin isn't in the transient->response or if the site is running the current or newer version of the plugin.
186
+ if ( empty( $update_cache->response[ $this->name ] ) || version_compare( $this->version, $update_cache->response[ $this->name ]->new_version, '>=' ) ) {
187
+ return;
188
+ }
 
189
 
190
+ printf(
191
+ '<tr class="plugin-update-tr %3$s" id="%1$s-update" data-slug="%1$s" data-plugin="%2$s">',
192
+ $this->slug,
193
+ $file,
194
+ in_array( $this->name, $this->get_active_plugins(), true ) ? 'active' : 'inactive'
195
+ );
196
 
197
+ echo '<td colspan="3" class="plugin-update colspanchange">';
198
+ echo '<div class="update-message notice inline notice-warning notice-alt"><p>';
199
 
200
+ $changelog_link = '';
201
+ if ( ! empty( $update_cache->response[ $this->name ]->sections->changelog ) ) {
202
+ $changelog_link = add_query_arg(
203
+ array(
204
+ 'edd_sl_action' => 'view_plugin_changelog',
205
+ 'plugin' => urlencode( $this->name ),
206
+ 'slug' => urlencode( $this->slug ),
207
+ 'TB_iframe' => 'true',
208
+ 'width' => 77,
209
+ 'height' => 911,
210
+ ),
211
+ self_admin_url( 'index.php' )
212
+ );
213
+ }
214
+ $update_link = add_query_arg(
215
+ array(
216
+ 'action' => 'upgrade-plugin',
217
+ 'plugin' => urlencode( $this->name ),
218
+ ),
219
+ self_admin_url( 'update.php' )
220
+ );
221
 
222
+ printf(
223
+ /* translators: the plugin name. */
224
+ esc_html__( 'There is a new version of %1$s available.', 'easy-digital-downloads' ),
225
+ esc_html( $plugin['Name'] )
226
+ );
227
 
228
+ if ( ! current_user_can( 'update_plugins' ) ) {
229
+ echo ' ';
230
+ esc_html_e( 'Contact your network administrator to install the update.', 'easy-digital-downloads' );
231
+ } elseif ( empty( $update_cache->response[ $this->name ]->package ) && ! empty( $changelog_link ) ) {
232
+ echo ' ';
233
+ printf(
234
+ /* translators: 1. opening anchor tag, do not translate 2. the new plugin version 3. closing anchor tag, do not translate. */
235
+ __( '%1$sView version %2$s details%3$s.', 'easy-digital-downloads' ),
236
+ '<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
237
+ esc_html( $update_cache->response[ $this->name ]->new_version ),
238
+ '</a>'
239
+ );
240
+ } elseif ( ! empty( $changelog_link ) ) {
241
+ echo ' ';
242
+ printf(
243
+ __( '%1$sView version %2$s details%3$s or %4$supdate now%5$s.', 'easy-digital-downloads' ),
244
+ '<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
245
+ esc_html( $update_cache->response[ $this->name ]->new_version ),
246
+ '</a>',
247
+ '<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
248
+ '</a>'
249
+ );
250
+ } else {
251
+ printf(
252
+ ' %1$s%2$s%3$s',
253
+ '<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
254
+ esc_html__( 'Update now.', 'easy-digital-downloads' ),
255
+ '</a>'
256
+ );
257
  }
258
 
259
+ do_action( "in_plugin_update_message-{$file}", $plugin, $plugin );
 
260
 
261
+ echo '</p></div></td></tr>';
262
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
264
+ /**
265
+ * Gets the plugins active in a multisite network.
266
+ *
267
+ * @return array
268
+ */
269
+ private function get_active_plugins() {
270
+ $active_plugins = (array) get_option( 'active_plugins' );
271
+ $active_network_plugins = (array) get_site_option( 'active_sitewide_plugins' );
272
 
273
+ return array_merge( $active_plugins, array_keys( $active_network_plugins ) );
 
274
  }
275
 
276
  /**
285
  */
286
  public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
287
 
288
+ if ( 'plugin_information' !== $_action ) {
289
 
290
  return $_data;
291
 
292
  }
293
 
294
+ if ( ! isset( $_args->slug ) || ( $_args->slug !== $this->slug ) ) {
295
 
296
  return $_data;
297
 
304
  'banners' => array(),
305
  'reviews' => false,
306
  'icons' => array(),
307
+ ),
308
  );
309
 
310
  // Get the transient where we store the api request for this plugin for 24 hours
321
  if ( false !== $api_response ) {
322
  $_data = $api_response;
323
  }
 
324
  } else {
325
  $_data = $edd_api_request_transient;
326
  }
345
  $_data->contributors = $this->convert_object_to_array( $_data->contributors );
346
  }
347
 
348
+ if ( ! isset( $_data->plugin ) ) {
349
  $_data->plugin = $this->name;
350
  }
351
 
365
  * @return array
366
  */
367
  private function convert_object_to_array( $data ) {
368
+ if ( ! is_array( $data ) && ! is_object( $data ) ) {
369
+ return array();
370
+ }
371
  $new_data = array();
372
  foreach ( $data as $key => $value ) {
373
  $new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
385
  */
386
  public function http_request_args( $args, $url ) {
387
 
 
388
  if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
389
+ $args['sslverify'] = $this->verify_ssl();
390
  }
391
  return $args;
392
 
401
  *
402
  * @param string $_action The requested action.
403
  * @param array $_data Parameters for the API action.
404
+ * @return false|object|void
405
  */
406
  private function api_request( $_action, $_data ) {
407
+ $data = array_merge( $this->api_data, $_data );
408
 
409
+ if ( $data['slug'] !== $this->slug ) {
410
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
412
 
413
+ // Don't allow a plugin to ping itself
414
+ if ( trailingslashit( home_url() ) === $this->api_url ) {
415
  return false;
416
  }
417
 
418
+ if ( $this->request_recently_failed() ) {
 
 
419
  return false;
420
  }
421
 
422
+ return $this->get_version_from_remote();
423
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
 
425
+ /**
426
+ * Determines if a request has recently failed.
427
+ *
428
+ * @since 1.9.1
429
+ *
430
+ * @return bool
431
+ */
432
+ private function request_recently_failed() {
433
+ $failed_request_details = get_option( $this->failed_request_cache_key );
434
 
435
+ // Request has never failed.
436
+ if ( empty( $failed_request_details ) || ! is_numeric( $failed_request_details ) ) {
437
+ return false;
 
438
  }
439
 
440
+ /*
441
+ * Request previously failed, but the timeout has expired.
442
+ * This means we're allowed to try again.
443
+ */
444
+ if ( time() > $failed_request_details ) {
445
+ delete_option( $this->failed_request_cache_key );
446
 
447
+ return false;
 
448
  }
449
 
450
+ return true;
451
+ }
 
 
 
452
 
453
+ /**
454
+ * Logs a failed HTTP request for this API URL.
455
+ * We set a timestamp for 1 hour from now. This prevents future API requests from being
456
+ * made to this domain for 1 hour. Once the timestamp is in the past, API requests
457
+ * will be allowed again. This way if the site is down for some reason we don't bombard
458
+ * it with failed API requests.
459
+ *
460
+ * @see EDD_SL_Plugin_Updater::request_recently_failed
461
+ *
462
+ * @since 1.9.1
463
+ */
464
+ private function log_failed_request() {
465
+ update_option( $this->failed_request_cache_key, strtotime( '+1 hour' ) );
466
  }
467
 
468
  /**
470
  */
471
  public function show_changelog() {
472
 
473
+ if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) {
 
 
474
  return;
475
  }
476
 
477
+ if ( empty( $_REQUEST['plugin'] ) ) {
478
  return;
479
  }
480
 
481
+ if ( empty( $_REQUEST['slug'] ) || $this->slug !== $_REQUEST['slug'] ) {
482
  return;
483
  }
484
 
485
+ if ( ! current_user_can( 'update_plugins' ) ) {
486
+ wp_die( esc_html__( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
487
  }
488
 
489
+ $version_info = $this->get_repo_api_data();
490
+ if ( isset( $version_info->sections ) ) {
491
+ $sections = $this->convert_object_to_array( $version_info->sections );
492
+ if ( ! empty( $sections['changelog'] ) ) {
493
+ echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
494
+ }
495
+ }
496
 
497
+ exit;
498
+ }
499
 
500
+ /**
501
+ * Gets the current version information from the remote site.
502
+ *
503
+ * @return array|false
504
+ */
505
+ private function get_version_from_remote() {
506
+ $api_params = array(
507
+ 'edd_action' => 'get_version',
508
+ 'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '',
509
+ 'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false,
510
+ 'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false,
511
+ 'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false,
512
+ 'slug' => $this->slug,
513
+ 'author' => $this->api_data['author'],
514
+ 'url' => home_url(),
515
+ 'beta' => $this->beta,
516
+ 'php_version' => phpversion(),
517
+ 'wp_version' => get_bloginfo( 'version' ),
518
+ );
519
 
520
+ /**
521
+ * Filters the parameters sent in the API request.
522
+ *
523
+ * @param array $api_params The array of data sent in the request.
524
+ * @param array $this->api_data The array of data set up in the class constructor.
525
+ * @param string $this->plugin_file The full path and filename of the file.
526
+ */
527
+ $api_params = apply_filters( 'edd_sl_plugin_updater_api_params', $api_params, $this->api_data, $this->plugin_file );
528
+
529
+ $request = wp_remote_post(
530
+ $this->api_url,
531
+ array(
532
+ 'timeout' => 15,
533
+ 'sslverify' => $this->verify_ssl(),
534
+ 'body' => $api_params,
535
+ )
536
+ );
537
 
538
+ if ( is_wp_error( $request ) || ( 200 !== wp_remote_retrieve_response_code( $request ) ) ) {
539
+ $this->log_failed_request();
 
540
 
541
+ return false;
542
+ }
 
 
 
543
 
544
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
 
 
 
 
545
 
546
+ if ( $request && isset( $request->sections ) ) {
547
+ $request->sections = maybe_unserialize( $request->sections );
548
+ } else {
549
+ $request = false;
550
+ }
551
 
552
+ if ( $request && isset( $request->banners ) ) {
553
+ $request->banners = maybe_unserialize( $request->banners );
554
  }
555
 
556
+ if ( $request && isset( $request->icons ) ) {
557
+ $request->icons = maybe_unserialize( $request->icons );
558
+ }
559
+
560
+ if ( ! empty( $request->sections ) ) {
561
+ foreach ( $request->sections as $key => $section ) {
562
+ $request->$key = (array) $section;
563
  }
564
  }
565
 
566
+ return $request;
567
  }
568
 
569
  /**
570
+ * Get the version info from the cache, if it exists.
571
  *
572
  * @param string $cache_key
573
+ * @return object
574
  */
575
  public function get_cached_version_info( $cache_key = '' ) {
576
 
577
+ if ( empty( $cache_key ) ) {
578
+ $cache_key = $this->get_cache_key();
579
  }
580
 
581
  $cache = get_option( $cache_key );
582
 
583
+ // Cache is expired
584
+ if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
585
+ return false;
586
  }
587
 
588
  // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
603
  */
604
  public function set_version_info_cache( $value = '', $cache_key = '' ) {
605
 
606
+ if ( empty( $cache_key ) ) {
607
+ $cache_key = $this->get_cache_key();
608
  }
609
 
610
  $data = array(
611
  'timeout' => strtotime( '+3 hours', time() ),
612
+ 'value' => wp_json_encode( $value ),
613
  );
614
 
615
  update_option( $cache_key, $data, 'no' );
628
  return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
629
  }
630
 
631
+ /**
632
+ * Gets the unique key (option name) for a plugin.
633
+ *
634
+ * @since 1.9.0
635
+ * @return string
636
+ */
637
+ private function get_cache_key() {
638
+ $string = $this->slug . $this->api_data['license'] . $this->beta;
639
+
640
+ return 'edd_sl_' . md5( serialize( $string ) );
641
+ }
642
+
643
  }
eddsl/eddsl.php CHANGED
@@ -109,14 +109,18 @@ function mtphr_dnt_plugin_updater() {
109
  $license_key = isset($mtphr_edd_licenses[$slug]) ? trim($mtphr_edd_licenses[$slug]) : '';
110
 
111
  // setup the updater
112
- $edd_updater = new EDD_SL_Plugin_Updater( MTPHR_DNT_STORE_URL, $data['path'], array(
113
- 'version' => $data['version'], // current version number
114
- 'license' => $license_key, // license key (used get_option above to retrieve from DB)
115
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : null, // name of this plugin
116
- 'item_name' => $data['item_name'], // name of this plugin
117
- 'author' => isset($data['author']) ? $data['author'] : 'Metaphor Creations' // author of this plugin
118
- )
119
  );
 
 
 
 
 
 
120
 
121
  }
122
  }
@@ -369,9 +373,13 @@ function mtphr_dnt_license_check() {
369
  $api_params = array(
370
  'edd_action' => 'check_license',
371
  'license' => $license_key,
372
- 'item_name' => urlencode( $data['item_name'] ),
373
  'url' => home_url()
374
  );
 
 
 
 
 
375
 
376
  // Call the custom API.
377
  $response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
@@ -544,9 +552,13 @@ function mtphr_dnt_license_deactivate_ajax() {
544
  $api_params = array(
545
  'edd_action'=> 'deactivate_license',
546
  'license' => $license,
547
- 'item_name' => urlencode( $all_license_data[$slug]['item_name'] ), // the name of our product in EDD
548
  'url' => home_url()
549
  );
 
 
 
 
 
550
 
551
  // Call the custom API.
552
  $response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
@@ -637,9 +649,13 @@ function mtphr_dnt_license_activate_ajax() {
637
  $api_params = array(
638
  'edd_action'=> 'activate_license',
639
  'license' => $license,
640
- 'item_name' => urlencode( $all_license_data[$slug]['item_name'] ), // the name of our product in EDD
641
  'url' => home_url()
642
  );
 
 
 
 
 
643
 
644
  // Call the custom API.
645
  $response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
109
  $license_key = isset($mtphr_edd_licenses[$slug]) ? trim($mtphr_edd_licenses[$slug]) : '';
110
 
111
  // setup the updater
112
+ $api_params = array(
113
+ 'version' => $data['version'], // current version number
114
+ 'license' => $license_key, // license key (used get_option above to retrieve from DB)
115
+ 'author' => isset($data['author']) ? $data['author'] : 'Metaphor Creations', // author of this plugin
116
+ 'beta' => false,
 
 
117
  );
118
+ if ( isset( $data['item_id'] ) ) {
119
+ $api_params['item_id'] = $data['item_id']; // the name of our product in EDD
120
+ } elseif( isset( $data['item_name'] ) ) {
121
+ $api_params['item_name'] = $data['item_name']; // the name of our product in EDD
122
+ }
123
+ $edd_updater = new EDD_SL_Plugin_Updater( MTPHR_DNT_STORE_URL, $data['path'], $data );
124
 
125
  }
126
  }
373
  $api_params = array(
374
  'edd_action' => 'check_license',
375
  'license' => $license_key,
 
376
  'url' => home_url()
377
  );
378
+ if ( isset( $data['item_id'] ) ) {
379
+ $api_params['item_id'] = intval( $data['item_id'] ); // the name of our product in EDD
380
+ } elseif ( isset( $data['item_name'] ) ) {
381
+ $api_params['item_name'] = urlencode( $data['item_name'] ); // the name of our product in EDD
382
+ }
383
 
384
  // Call the custom API.
385
  $response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
552
  $api_params = array(
553
  'edd_action'=> 'deactivate_license',
554
  'license' => $license,
 
555
  'url' => home_url()
556
  );
557
+ if ( isset( $all_license_data[$slug]['item_id'] ) ) {
558
+ $api_params['item_id'] = intval( $all_license_data[$slug]['item_id'] ); // the name of our product in EDD
559
+ } elseif ( isset( $all_license_data[$slug]['item_name'] ) ) {
560
+ $api_params['item_name'] = urlencode( $all_license_data[$slug]['item_name'] ); // the name of our product in EDD
561
+ }
562
 
563
  // Call the custom API.
564
  $response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
649
  $api_params = array(
650
  'edd_action'=> 'activate_license',
651
  'license' => $license,
 
652
  'url' => home_url()
653
  );
654
+ if ( isset( $all_license_data[$slug]['item_id'] ) ) {
655
+ $api_params['item_id'] = intval( $all_license_data[$slug]['item_id'] ); // the name of our product in EDD
656
+ } elseif ( isset( $all_license_data[$slug]['item_name'] ) ) {
657
+ $api_params['item_name'] = urlencode( $all_license_data[$slug]['item_name'] ); // the name of our product in EDD
658
+ }
659
 
660
  // Call the custom API.
661
  $response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: metaphorcreations
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
4
  Tags: ticker, news, news ticker, rotator, data rotator, lists, data
5
  Requires at least: 4.5
6
- Tested up to: 5.8.1
7
  Stable tag: /trunk/
8
  License: GPL2
9
 
@@ -72,6 +72,9 @@ The most common cause for an unresponsive ticker (when using scroll or rotate mo
72
 
73
  == Changelog ==
74
 
 
 
 
75
  = 2.3.12 =
76
  * Bug fix in wpml-config.xml file.
77
 
@@ -586,4 +589,4 @@ The most common cause for an unresponsive ticker (when using scroll or rotate mo
586
 
587
  == Upgrade Notice ==
588
 
589
- Bug fix in wpml-config.xml file
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
4
  Tags: ticker, news, news ticker, rotator, data rotator, lists, data
5
  Requires at least: 4.5
6
+ Tested up to: 5.8.2
7
  Stable tag: /trunk/
8
  License: GPL2
9
 
72
 
73
  == Changelog ==
74
 
75
+ = 2.3.13 =
76
+ * Updated extension updater code.
77
+
78
  = 2.3.12 =
79
  * Bug fix in wpml-config.xml file.
80
 
589
 
590
  == Upgrade Notice ==
591
 
592
+ Updated extension updater code.