PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.1.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.1.9
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / codeinwp / themeisle-sdk / class-themeisle-sdk-licenser.php

class-themeisle-sdk-licenser.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 2.1.9, at vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-licenser.php

711 lines 23.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The main loader class for license handling.
4 *
5 * @package ThemeIsleSDK
6 * @subpackage Licenser
7 * @copyright Copyright (c) 2017, Marius Cristea
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.0.0
10 */
11 if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
12 /**
13 * Class ThemeIsle_SDK_Licenser
14 *
15 * Used to update the themeisle products
16 */
17 class ThemeIsle_SDK_Licenser {
18
19 /**
20 * @var string $license_key The license key string
21 */
22 public $license_key;
23
24 /**
25 * @var bool $do_check This ensures that the custom API request only runs on the second time that WP fires the update check
26 */
27 private $do_check = false;
28
29 /**
30 * @var bool $failed_checks Number of failed checks to the api endpoint
31 */
32 private $failed_checks = 0;
33 /**
34 * @var ThemeIsle_SDK_Product $product The ThemeIsle Product.
35 */
36 private $product;
37 /**
38 * @var string $product_key The product update response key.
39 */
40 private $product_key;
41 /**
42 * @var int $max_failed Maximum failed checks allowed before show the notice
43 */
44 private static $max_failed = 5;
45
46 /**
47 * ThemeIsle_SDK_Licenser constructor.
48 *
49 * @param ThemeIsle_SDK_Product $product The product object.
50 */
51 public function __construct( $product ) {
52 $this->product = $product;
53 $this->product_key = $this->product->get_key() . '-update-response';
54 if ( ! $this->product->requires_license() ) {
55 $this->license_key = 'free';
56 } else {
57 $license_data = get_option( $this->product->get_key() . '_license_data', '' );
58 $this->failed_checks = intval( get_option( $this->product->get_key() . '_failed_checks', 0 ) );
59 if ( $license_data !== '' ) {
60 $this->license_key = isset( $license_data->key ) ? $license_data->key : get_option( $this->product->get_key() . '_license', '' );
61 } else {
62 $this->license_key = get_option( $this->product->get_key() . '_license', '' );
63 }
64 $this->register_license_hooks();
65 }
66 }
67
68 /**
69 * Register license hooks for the themeisle products
70 */
71 public function register_license_hooks() {
72 add_action( 'admin_init', array( $this, 'register_settings' ) );
73 add_action( 'admin_init', array( $this, 'activate_license' ) );
74 add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 );
75 add_action( 'admin_notices', array( $this, 'show_notice' ) );
76 }
77
78 /**
79 * @param string $r Update payload.
80 * @param string $url The api url.
81 *
82 * @return mixed List of themes to check for update.
83 */
84 function disable_wporg_update( $r, $url ) {
85
86 if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/' ) ) {
87 return $r;
88 }
89
90 // Decode the JSON response
91 $themes = json_decode( $r['body']['themes'] );
92
93 unset( $themes->themes->{$this->product->get_slug()} );
94
95 // Encode the updated JSON response
96 $r['body']['themes'] = json_encode( $themes );
97
98 return $r;
99 }
100
101 /**
102 * Register the setting for the license of the product
103 *
104 * @return bool
105 */
106 public function register_settings() {
107 if ( ! is_admin() ) {
108 return false;
109 }
110 add_settings_field(
111 $this->product->get_key() . '_license',
112 $this->product->get_name() . ' license',
113 array( $this, 'license_view' ),
114 'general'
115 );
116 }
117
118 /**
119 * The license view field
120 */
121 public function license_view() {
122 $status = $this->get_license_status();
123 $value = $this->license_key;
124
125 $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' );
126 $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' );
127 $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' );
128 $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' );
129 $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' );
130
131 echo '<p ><input ' . ( ( $status === 'valid' ) ? ( 'style="border:1px solid #7ad03a; "' ) : '' ) . ' type="text" id="' . $this->product->get_key() . '_license" name="' . $this->product->get_key() . '_license" value="' . $value . '" /><a ' . ( ( $status === 'valid' ) ? ( 'style="color:#fff;background: #7ad03a; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $valid_string ) : ( 'style="color:#fff;background: #dd3d36; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $invalid_string ) ) . ' </a>&nbsp;&nbsp;&nbsp;<button name="' . $this->product->get_key() . '_btn_trigger" ' . ( ( $status === 'valid' ) ? ( ' class="button button-primary">' . $deactivate_string ) : ( ' class="button button-primary" value="yes" type="submit" >' . $activate_string ) ) . ' </button></p><p class="description">' . sprintf( $license_message, '<a href="' . $this->product->get_store_url() . '">' . $this->product->get_store_name() . '</a> ', $this->product->get_type() ) . '</p>';
132
133 }
134
135 /**
136 * Return the license status.
137 *
138 * @return string The License status.
139 */
140 public function get_license_status() {
141 $license_data = get_option( $this->product->get_key() . '_license_data', '' );
142 if ( $license_data !== '' ) {
143 return isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' );
144 } else {
145 return get_option( $this->product->get_key() . '_license_status', 'not_active' );
146 }
147
148 }
149
150 /**
151 * Check if the license is active or not
152 *
153 * @return bool
154 */
155 public function check_activation() {
156 $license_data = get_option( $this->product->get_key() . '_license_data', '' );
157 if ( $license_data !== '' ) {
158 return isset( $license_data->error ) ? ( $license_data->error == 'no_activations_left' ) : false;
159 }
160
161 return false;
162 }
163
164 /**
165 * Check if the license is about to expire in the next month
166 *
167 * @return bool
168 */
169 function check_expiration() {
170 $license_data = get_option( $this->product->get_key() . '_license_data', '' );
171 if ( $license_data !== '' ) {
172 if ( isset( $license_data->expires ) ) {
173 if ( strtotime( $license_data->expires ) - time() < 30 * 24 * 3600 ) {
174 return true;
175 }
176 }
177 }
178
179 return false;
180 }
181
182 /**
183 * Return the renew url from the store used
184 *
185 * @return string The renew url.
186 */
187 function renew_url() {
188 $license_data = get_option( $this->product->get_key() . '_license_data', '' );
189 if ( $license_data !== '' ) {
190 if ( isset( $license_data->download_id ) && isset( $license_data->key ) ) {
191 return $this->product->get_store_url() . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id;
192 }
193 }
194
195 return $this->product->get_store_url();
196 }
197
198 /**
199 * Check if we hide the notificatin nag or not
200 *
201 * @param string $hide The notification to hide.
202 *
203 * @return bool Either hide them or not.
204 */
205 function check_hide( $hide ) {
206 if ( isset( $_GET[ $this->product->get_key() . '_hide_' . $hide ] ) ) {
207 if ( $_GET[ $this->product->get_key() . '_hide_' . $hide ] === 'yes' ) {
208 update_option( $this->product->get_key() . '_hide_' . $hide, 'yes' );
209
210 return false;
211 }
212 } else {
213 $license = get_option( $this->product->get_key() . '_hide_' . $hide, '' );
214 if ( $license === 'yes' ) {
215 return false;
216 }
217 }
218
219 return true;
220 }
221
222 /**
223 * Show the admin notice regarding the license status
224 *
225 * @return bool
226 */
227 function show_notice() {
228 if ( ! is_admin() ) {
229 return false;
230 }
231 $status = $this->get_license_status();
232 $no_activations_string = apply_filters(
233 $this->product->get_key() . '_lc_no_activations_string', 'No activations left for %s !!!. You need to
234 upgrade your plan in order to use %s on more
235 websites. Please ask the %s
236 Staff for more details.'
237 );
238 $no_valid_string = apply_filters(
239 $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s , please add
240 your license code from your <a href="%s" target="_blank">purchase history</a> and validate it <a
241 href="%s">here</a> '
242 );
243 $expiration_string = apply_filters(
244 $this->product->get_key() . '_lc_expiration_string', 'Your license is about to expire
245 for %s. You can go to %s and renew it '
246 );
247 $hide_notice_string = apply_filters( $this->product->get_key() . '_lc_hide_notice_string', 'Hide Notice' );
248 if ( $status != 'valid' ) {
249 if ( $this->check_activation() ) {
250 if ( $this->check_hide( 'activation' ) ) {
251 ?>
252 <div class="error">
253 <p><strong>
254 <?php
255 echo sprintf(
256 $no_activations_string, $this->product->get_name(), $this->product->get_name(), '<a href="' . $this->product->get_store_url() . '"
257 target="_blank">' . $this->product->get_store_name() . '</a>'
258 );
259 ?>
260 </strong> | <a
261 href="<?php echo add_query_arg( $this->product->get_key() . '_activation', 'yes' ); ?> "><?php echo $hide_notice_string; ?></a>
262 </p>
263 </div>
264 <?php
265 return false;
266 }
267 }
268 ?>
269 <?php if ( $this->check_hide( 'valid' ) ) : ?>
270 <div class="error">
271 <p>
272 <strong><?php echo sprintf( $no_valid_string, $this->product->get_name() . ' ' . $this->product->get_type(), $this->product->get_store_url(), admin_url( 'options-general.php' ) . '#' . $this->product->get_key() ); ?> </strong>|
273 <a
274 href="<?php echo add_query_arg( $this->product->get_key() . '_hide_valid', 'yes' ); ?> "><?php echo $hide_notice_string; ?></a>
275 </p>
276 </div>
277 <?php endif; ?>
278 <?php
279 } else {
280 if ( $this->check_expiration() ) {
281 if ( $this->check_hide( 'expiration' ) ) {
282 ?>
283 <div class="update-nag">
284 <p>
285 <strong>
286 <?php
287 echo sprintf(
288 $expiration_string, $this->product->get_name() . ' ' . $this->product->get_type(), '<a
289 href="' . $this->renew_url() . '"
290 target="_blank">' . $this->product->get_store_name() . '</a>'
291 );
292 ?>
293 </strong> |
294 <a
295 href="<?php echo add_query_arg( $this->product->get_key() . '_hide_expiration', 'yes' ); ?> "><?php echo $hide_notice_string; ?></a>
296 </p>
297 </div>
298 <?php
299 }
300 }
301 }
302 }
303
304 /**
305 * Run the license check call
306 */
307 public function product_valid() {
308 if ( false === ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) {
309 $license = $this->check_license();
310 set_transient( $this->product->get_key() . '_license_data', $license, 12 * HOUR_IN_SECONDS );
311 update_option( $this->product->get_key() . '_license_data', $license );
312 }
313
314 }
315
316 /**
317 * Increment the failed checks
318 */
319 private function increment_failed_checks() {
320 $this->failed_checks ++;
321 update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
322 }
323
324 /**
325 * Reset the failed checks
326 */
327 private function reset_failed_checks() {
328 $this->failed_checks = 1;
329 update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
330 }
331
332 /**
333 * Check the license status
334 *
335 * @return object The license data.
336 */
337 public function check_license() {
338 $status = $this->get_license_status();
339 if ( $status == 'not_active' ) {
340 $license_data = new stdClass();
341 $license_data->license = 'not_active';
342
343 return $license_data;
344 }
345 $license = trim( $this->license_key );
346 $api_params = array(
347 'edd_action' => 'check_license',
348 'license' => $license,
349 'item_name' => rawurlencode( $this->product->get_name() ),
350 'url' => rawurlencode( home_url() ),
351 );
352 // Call the custom API.
353 $response = wp_remote_get(
354 add_query_arg( $api_params, $this->product->get_store_url() ), array(
355 'timeout' => 15,
356 'sslverify' => false,
357 )
358 );
359 if ( is_wp_error( $response ) ) {
360 $license_data = new stdClass();
361 $license_data->license = 'valid';
362
363 } else {
364 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
365 if ( ! is_object( $license_data ) ) {
366 $license_data = new stdClass();
367 $license_data->license = 'valid';
368 }
369 }
370 $license_old = get_option( $this->product->get_key() . '_license_data', '' );
371 if ( $license_old->license == 'valid' && ( $license_data->license != $license_old->license ) ) {
372 $this->increment_failed_checks();
373 } else {
374 $this->reset_failed_checks();
375 }
376
377 if ( $this->failed_checks <= self::$max_failed ) {
378 return $license_old;
379 }
380
381 if ( isset( $license_old->hide_valid ) ) {
382 $license_data->hide_valid = true;
383 }
384
385 if ( ! isset( $license_data->key ) ) {
386 $license_data->key = isset( $license_old->key ) ? $license_old->key : '';
387 }
388
389 if ( isset( $license_old->hide_expiration ) ) {
390 $license_data->hide_expiration = true;
391 }
392
393 if ( isset( $license_old->hide_activation ) ) {
394 $license_data->hide_activation = true;
395 }
396
397 return $license_data;
398
399 }
400
401 /**
402 * Activate the license remotely
403 */
404 function activate_license() {
405 // listen for our activate button to be clicked
406 if ( isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
407 $status = $this->get_license_status();
408 // retrieve the license from the database
409 $license = $_POST[ $this->product->get_key() . '_license' ];
410 $api_params = array(
411 'license' => $license,
412 'item_name' => rawurlencode( $this->product->get_name() ),
413 'url' => rawurlencode( home_url() ),
414 );
415 if ( $status != 'valid' ) {
416 // data to send in our API request
417 $api_params['edd_action'] = 'activate_license';
418 } else {
419 $api_params['edd_action'] = 'deactivate_license';
420 }
421 // Call the custom API.
422 $response = wp_remote_get( add_query_arg( $api_params, $this->product->get_store_url() ) );
423 // make sure the response came back okay
424 if ( is_wp_error( $response ) ) {
425 $license_data = new stdClass();
426 $license_data->license = ( $status != 'valid' ) ? 'valid' : 'invalid';
427
428 } else {
429 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
430 if ( ! is_object( $license_data ) ) {
431 $license_data = new stdClass();
432 $license_data->license = ( $status != 'valid' ) ? 'valid' : 'invalid';
433 }
434 }
435 if ( ! isset( $license_data->key ) ) {
436 $license_data->key = $license;
437 }
438 if ( $license_data->license == 'valid' ) {
439 $this->reset_failed_checks();
440 }
441
442 if ( isset( $license_data->plan ) ) {
443 update_option( $this->product->get_key() . '_license_plan', $license_data->plan );
444 }
445
446 update_option( $this->product->get_key() . '_license_data', $license_data );
447 delete_transient( $this->product->get_key() . '_license_data' );
448 set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );
449
450 }
451 }
452
453 /**
454 * Enable the license system
455 */
456 public function enable() {
457 if ( $this->product->get_type() == 'plugin' ) {
458 add_filter(
459 'pre_set_site_transient_update_plugins', array(
460 $this,
461 'pre_set_site_transient_update_plugins_filter',
462 )
463 );
464 add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
465 add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
466 }
467 if ( $this->product->get_type() == 'theme' ) {
468 add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
469 add_filter( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
470 add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
471 add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
472 add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
473 add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 );
474
475 }
476
477 }
478
479 /**
480 * Load the Themes screen
481 */
482 function load_themes_screen() {
483 add_thickbox();
484 add_action( 'admin_notices', array( &$this, 'update_nag' ) );
485 }
486
487 /**
488 * Alter the nag for themes update
489 */
490 function update_nag() {
491 $theme = wp_get_theme( $this->product->get_slug() );
492 $api_response = get_transient( $this->product_key );
493 if ( false === $api_response ) {
494 return;
495 }
496 $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() );
497 $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' );
498 $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"';
499 if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
500 echo '<div id="update-nag">';
501 printf(
502 '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.',
503 $theme->get( 'Name' ),
504 $api_response->new_version,
505 '#TB_inline?width=640&amp;inlineId=' . $this->product->get_version() . '_changelog',
506 $theme->get( 'Name' ),
507 $update_url,
508 $update_onclick
509 );
510 echo '</div>';
511 echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">';
512 echo wpautop( $api_response->sections['changelog'] );
513 echo '</div>';
514 }
515 }
516
517 /**
518 * @param mixed $value The transient data.
519 *
520 * @return mixed
521 */
522 function theme_update_transient( $value ) {
523 $update_data = $this->check_for_update();
524 if ( $update_data ) {
525 $value->response[ $this->product->get_slug() ] = $update_data;
526 }
527
528 return $value;
529 }
530
531 /**
532 * Delete the update transient
533 */
534 function delete_theme_update_transient() {
535 delete_transient( $this->product_key );
536 }
537
538 /**
539 * Check for updates
540 *
541 * @return array|bool Either the update data or false in case of failure
542 */
543 function check_for_update() {
544 $theme = wp_get_theme( $this->product->get_slug() );
545 $update_data = get_transient( $this->product_key );
546 if ( false === $update_data ) {
547 $failed = false;
548 if ( empty( $this->license_key ) ) {
549 return false;
550 }
551 $api_params = array(
552 'edd_action' => 'get_version',
553 'version' => $this->product->get_version(),
554 'license' => $this->license_key,
555 'name' => $this->product->get_name(),
556 'slug' => $this->product->get_slug(),
557 'author' => $this->product->get_store_name(),
558 'url' => rawurlencode( home_url() ),
559 );
560 $response = wp_remote_post(
561 $this->product->get_store_url(), array(
562 'timeout' => 15,
563 'sslverify' => false,
564 'body' => $api_params,
565 )
566 );
567 // make sure the response was successful
568 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
569 $failed = true;
570 }
571 $update_data = json_decode( wp_remote_retrieve_body( $response ) );
572 if ( ! is_object( $update_data ) ) {
573 $failed = true;
574 }
575 // if the response failed, try again in 30 minutes
576 if ( $failed ) {
577 $data = new stdClass;
578 $data->new_version = $this->product->get_version();
579 set_transient( $this->product_key, $data, strtotime( '+30 minutes' ) );
580
581 return false;
582 }
583 // if the status is 'ok', return the update arguments
584 if ( ! $failed ) {
585 $update_data->sections = maybe_unserialize( $update_data->sections );
586 set_transient( $this->product_key, $update_data, strtotime( '+12 hours' ) );
587 }
588 }
589 if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) {
590 return false;
591 }
592
593 return (array) $update_data;
594 }
595
596 /**
597 * Check for Updates at the defined API endpoint and modify the update array.
598 *
599 * This function dives into the update API just when WordPress creates its update array,
600 * then adds a custom API call and injects the custom plugin data retrieved from the API.
601 * It is reassembled from parts of the native WordPress plugin update code.
602 * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
603 *
604 * @uses api_request()
605 *
606 * @param array $_transient_data Update array build by WordPress.
607 *
608 * @return array Modified update array with custom plugin data.
609 */
610 public function pre_set_site_transient_update_plugins_filter( $_transient_data ) {
611 if ( empty( $_transient_data ) || ! $this->do_check ) {
612 $this->do_check = true;
613
614 return $_transient_data;
615 }
616 $api_response = $this->api_request();
617 if ( false !== $api_response && is_object( $api_response ) && isset( $api_response->new_version ) ) {
618 if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
619 $_transient_data->response[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response;
620 }
621 }
622
623 return $_transient_data;
624 }
625
626 /**
627 * Calls the API and, if successfull, returns the object delivered by the API.
628 *
629 * @uses get_bloginfo()
630 * @uses wp_remote_post()
631 * @uses is_wp_error()
632 *
633 * @param string $_action The requested action.
634 * @param array $_data Parameters for the API action.
635 *
636 * @return false||object
637 */
638 private function api_request( $_action = '', $_data = '' ) {
639 if ( empty( $this->license_key ) ) {
640 return;
641 }
642 $api_params = array(
643 'edd_action' => 'get_version',
644 'license' => $this->license_key,
645 'name' => rawurlencode( $this->product->get_name() ),
646 'slug' => rawurlencode( $this->product->get_slug() ),
647 'author' => $this->product->get_store_name(),
648 'url' => rawurlencode( home_url() ),
649 );
650 $request = wp_remote_post(
651 $this->product->get_store_url(), array(
652 'timeout' => 15,
653 'sslverify' => false,
654 'body' => $api_params,
655 )
656 );
657 if ( ! is_wp_error( $request ) ) :
658 $request = json_decode( wp_remote_retrieve_body( $request ) );
659 if ( $request && isset( $request->sections ) ) {
660 $request->sections = maybe_unserialize( $request->sections );
661 }
662
663 return $request;
664 else :
665 return false;
666 endif;
667 }
668
669 /**
670 * Updates information on the "View version x.x details" page with custom data.
671 *
672 * @uses api_request()
673 *
674 * @param mixed $_data Plugin data.
675 * @param string $_action Action to send.
676 * @param object $_args Arguments to use.
677 *
678 * @return object $_data
679 */
680 public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
681 if ( ( $_action != 'plugin_information' ) || ! isset( $_args->slug ) || ( $_args->slug != $this->product->get_slug() ) ) {
682 return $_data;
683 }
684 $api_response = $this->api_request();
685 if ( false !== $api_response ) {
686 $_data = $api_response;
687 }
688
689 return $_data;
690 }
691
692 /**
693 * Disable SSL verification in order to prevent download update failures
694 *
695 * @param array $args Http args.
696 * @param string $url Url to check.
697 *
698 * @return object $array
699 */
700 function http_request_args( $args, $url ) {
701 // If it is an https request and we are performing a package download, disable ssl verification
702 if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
703 $args['sslverify'] = false;
704 }
705
706 return $args;
707 }
708
709 }
710 endif;
711