PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.01
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmAddon.php +86 -277 6.255.0.01 View file →
@@ -2,9 +2,8 @@
2 2 if ( ! defined( 'ABSPATH' ) ) {
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 -/** @phpstan-consistent-constructor */
7 6 class FrmAddon {
8 7 public $store_url = 'https://formidableforms.com';
9 8 public $download_id;
10 9 public $plugin_file;
@@ -12,43 +11,15 @@
12 11 public $plugin_name;
13 12 public $plugin_slug;
14 13 public $option_name;
15 14 public $version;
16 - public $author = 'Strategy11';
15 + public $author = 'Strategy11';
17 16 public $is_parent_licence = false;
18 - public $needs_license = true;
17 + public $needs_license = true;
19 18 private $is_expired_addon = false;
20 19 public $license;
21 20 protected $get_beta = false;
22 - protected $save_status;
23 21
24 - /**
25 - * This is used to decide whether the license checks should continue.
26 - * The point is to avoid license issues when a site url changes.
27 - *
28 - * @since 6.8.3
29 - *
30 - * @var array
31 - */
32 - private $save_response = array();
33 -
34 - /**
35 - * This is used to flag other add ons not to send a request.
36 - * We only want to send a single API request per page load.
37 - *
38 - * @since 6.8.3
39 - *
40 - * @var string
41 - */
42 - private $transient_lock_key = 'frm_activate_request_lock';
43 -
44 - /**
45 - * @since 6.8.3
46 - *
47 - * @var bool
48 - */
49 - protected $should_clear_cache = true;
50 -
51 22 public function __construct() {
52 23
53 24 if ( empty( $this->plugin_slug ) ) {
54 25 $this->plugin_slug = preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->plugin_name ) ) );
@@ -65,9 +36,9 @@
65 36 }
66 37
67 38 public static function load_hooks() {
68 39 add_filter( 'frm_include_addon_page', '__return_true' );
69 - new static();
40 + //new static();
70 41 }
71 42
72 43 public function insert_installed_addon( $plugins ) {
73 44 $plugins[ $this->plugin_slug ] = $this;
@@ -102,13 +73,13 @@
102 73 }
103 74 }
104 75
105 76 /**
106 - * Updates information on the "View version 6.15 details" page with custom data.
77 + * Updates information on the "View version x.x details" page with custom data.
107 78 *
108 79 * @uses api_request()
109 80 *
110 - * @param mixed $_data
81 + * @param mixed $_data
111 82 * @param string $_action
112 83 * @param object $_args
113 84 *
114 85 * @return object $_data
@@ -118,11 +89,10 @@
118 89 if ( $_action != 'plugin_information' ) {
119 90 return $_data;
120 91 }
121 92
122 - $slug = basename( $this->plugin_file, '.php' );
123 - $slug2 = str_replace( '/' . $slug . '.php', '', $this->plugin_folder );
124 - if ( empty( $_args->slug ) || ( $_args->slug != $slug && $_args->slug !== $slug2 ) ) {
93 + $slug = basename( $this->plugin_file, '.php' );
94 + if ( ! isset( $_args->slug ) || $_args->slug != $slug ) {
125 95 return $_data;
126 96 }
127 97
128 98 $item_id = $this->download_id;
@@ -198,10 +168,11 @@
198 168 * @since 2.04
199 169 */
200 170 public function activate_defined_license() {
201 171 $license = $this->get_defined_license();
202 - if ( ! empty( $license ) && ! $this->is_active() && ! $this->checked_recently( '1 day' ) ) {
172 + if ( ! empty( $license ) && ! $this->is_active() && $this->is_time_to_auto_activate() ) {
203 173 $response = $this->activate_license( $license );
174 + $this->set_auto_activate_time();
204 175 if ( ! $response['success'] ) {
205 176 $license = '';
206 177 }
207 178 }
@@ -214,11 +185,11 @@
214 185 *
215 186 * @since 2.04
216 187 */
217 188 public function get_defined_license() {
218 - $constant_name = 'FRM_' . strtoupper( $this->plugin_slug ) . '_LICENSE';
189 + $consant_name = 'FRM_' . strtoupper( $this->plugin_slug ) . '_LICENSE';
219 190
220 - return defined( $constant_name ) ? constant( $constant_name ) : false;
191 + return defined( $consant_name ) ? constant( $consant_name ) : false;
221 192 }
222 193
223 194 public function set_license( $license ) {
224 195 update_option( $this->option_name . 'key', $license );
@@ -223,8 +194,24 @@
223 194 public function set_license( $license ) {
224 195 update_option( $this->option_name . 'key', $license );
225 196 }
226 197
198 + /**
199 + * If the license is in the config, limit the frequency of checks.
200 + * The license may be entered incorrectly, so we don't want to check on every page load.
201 + *
202 + * @since 2.04
203 + */
204 + private function is_time_to_auto_activate() {
205 + $last_try = get_option( $this->option_name . 'last_activate' );
206 +
207 + return ( ! $last_try || $last_try < strtotime( '-1 day' ) );
208 + }
209 +
210 + private function set_auto_activate_time() {
211 + update_option( $this->option_name . 'last_activate', time() );
212 + }
213 +
227 214 public function is_active() {
228 215 return get_option( $this->option_name . 'active' );
229 216 }
230 217
@@ -230,12 +217,12 @@
230 217
231 218 /**
232 219 * @since 3.04.03
233 220 *
234 - * @param array|string $error
221 + * @param array error
235 222 */
236 223 public function maybe_clear_license( $error ) {
237 - if ( is_array( $error ) && $error['code'] === 'disabled' && $error['license'] === $this->license ) {
224 + if ( $error['code'] === 'disabled' && $error['license'] === $this->license ) {
238 225 $this->clear_license();
239 226 }
240 227 }
241 228
@@ -241,41 +228,15 @@
241 228
242 229 public function clear_license() {
243 230 delete_option( $this->option_name . 'active' );
244 231 delete_option( $this->option_name . 'key' );
245 -
246 - if ( $this->should_clear_cache ) {
247 - delete_site_option( $this->transient_key() );
248 - delete_option( $this->transient_key() );
249 - $this->delete_cache();
250 - $this->should_clear_cache = true;
251 - }
232 + delete_site_option( $this->transient_key() );
233 + delete_option( $this->transient_key() );
234 + $this->delete_cache();
252 235 }
253 236
254 - /**
255 - * Don't save an invalid license.
256 - *
257 - * @since 6.8.3
258 - *
259 - * @param bool $is_valid If license activation was successful.
260 - *
261 - * @return void
262 - */
263 - protected function maybe_set_active( $is_valid ) {
264 - update_option( $this->option_name . 'active', $is_valid );
265 - if ( $is_valid ) {
266 - $this->set_active( $is_valid );
267 - return;
268 - }
269 -
270 - // Don't save the license if it's invalid.
271 - $this->should_clear_cache = false;
272 - $this->clear_license();
273 - delete_option( $this->option_name . 'key' );
274 - $this->license = '';
275 - }
276 -
277 237 public function set_active( $is_active ) {
238 + update_option( $this->option_name . 'active', $is_active );
278 239 $this->delete_cache();
279 240 FrmAppHelper::save_combined_js();
280 241 $this->update_pro_capabilities();
281 242 }
@@ -287,20 +248,16 @@
287 248 */
288 249 protected function update_pro_capabilities() {
289 250 global $wp_roles;
290 251
291 - if ( ! function_exists( 'get_editable_roles' ) ) {
292 - require_once ABSPATH . 'wp-admin/includes/user.php';
293 - }
294 -
295 252 $caps = FrmAppHelper::frm_capabilities( 'pro_only' );
296 253 $roles = get_editable_roles();
297 254 $settings = new FrmSettings();
298 255 foreach ( $caps as $cap => $cap_desc ) {
299 - $cap_roles = (array) ( $settings->$cap ?? 'administrator' );
256 + $cap_roles = (array) ( isset( $settings->$cap ) ? $settings->$cap : 'administrator' );
300 257
301 258 // Make sure administrators always have permissions.
302 - if ( ! in_array( 'administrator', $cap_roles, true ) ) {
259 + if ( ! in_array( 'administrator', $cap_roles ) ) {
303 260 array_push( $cap_roles, 'administrator' );
304 261 }
305 262
306 263 foreach ( $roles as $role => $details ) {
@@ -318,22 +275,13 @@
318 275 */
319 276 protected function delete_cache() {
320 277 delete_transient( 'frm_api_licence' );
321 278
322 - // Cleanup option that has been removed.
323 - delete_option( $this->option_name . 'last_activate' );
324 -
325 279 $api = new FrmFormApi( $this->license );
326 280 $api->reset_cached();
327 281
328 282 $api = new FrmFormTemplateApi( $this->license );
329 283 $api->reset_cached();
330 -
331 - $api = new FrmApplicationApi( $this->license );
332 - $api->reset_cached();
333 -
334 - $api = new FrmSalesApi();
335 - $api->reset_cached();
336 284 }
337 285
338 286 /**
339 287 * The Pro version includes the show_license_message function.
@@ -370,9 +318,9 @@
370 318 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
371 319 $id = sanitize_title( $plugin['Name'] ) . '-next';
372 320
373 321 echo '<tr class="plugin-update-tr active" id="' . esc_attr( $id ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice error inline notice-error notice-alt"><p>';
374 - FrmAppHelper::kses_echo( $message, 'a' );
322 + echo FrmAppHelper::kses( $message, 'a' ); // WPCS: XSS ok.
375 323 echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '").previousSibling;if ( d !== null ){ d.className = d.className + " update"; }</script>';
376 324 echo '</p></div></td></tr>';
377 325 }
378 326
@@ -381,9 +329,9 @@
381 329 return $transient;
382 330 }
383 331
384 332 if ( $this->is_current_version( $transient ) ) {
385 - // Make sure it doesn't show there is an update if plugin is up-to-date.
333 + //make sure it doesn't show there is an update if plugin is up-to-date
386 334 if ( isset( $transient->response[ $this->plugin_folder ] ) ) {
387 335 unset( $transient->response[ $this->plugin_folder ] );
388 336 }
389 337 } elseif ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) {
@@ -406,21 +354,20 @@
406 354 * Check if the plugin information is correct to allow an update
407 355 *
408 356 * @since 3.04.03
409 357 *
410 - * @param object $transient The current plugin info saved for update.
358 + * @param object $transient - the current plugin info saved for update
411 359 */
412 360 private function prepare_update_details( &$transient ) {
413 361 $version_info = $transient;
414 - $has_beta_url = ! empty( $version_info->beta );
362 + $has_beta_url = isset( $version_info->beta ) && ! empty( $version_info->beta );
415 363 if ( $this->get_beta && ! $has_beta_url ) {
416 364 $version_info = (object) $this->get_api_info( $this->license );
417 365 }
418 366
419 - if ( ! empty( $version_info->new_version ) ) {
367 + if ( isset( $version_info->new_version ) && ! empty( $version_info->new_version ) ) {
420 368 $this->clear_old_plugin_version( $version_info );
421 - if ( $version_info === false ) {
422 - // Was cleared with timeout.
369 + if ( $version_info === false ) { // was cleared with timeout
423 370 $transient = false;
424 371 } else {
425 372 $this->maybe_use_beta_url( $version_info );
426 373
@@ -458,12 +405,11 @@
458 405 *
459 406 * @since 2.05.05
460 407 */
461 408 private function clear_old_plugin_version( &$version_info ) {
462 - $timeout = ! empty( $version_info->timeout ) ? $version_info->timeout : 0;
409 + $timeout = ( isset( $version_info->timeout ) && ! empty( $version_info->timeout ) ) ? $version_info->timeout : 0;
463 410 if ( ! empty( $timeout ) && time() > $timeout ) {
464 - // Cache is expired.
465 - $version_info = false;
411 + $version_info = false; // Cache is expired
466 412 $api = new FrmFormApi( $this->license );
467 413 $api->reset_cached();
468 414 }
469 415 }
@@ -474,12 +420,12 @@
474 420 *
475 421 * @since 3.04.03
476 422 */
477 423 private function maybe_use_beta_url( &$version_info ) {
478 - if ( $this->get_beta && ! empty( $version_info->beta ) ) {
424 + if ( $this->get_beta && isset( $version_info->beta ) && ! empty( $version_info->beta ) ) {
479 425 $version_info->new_version = $version_info->beta['version'];
480 426 $version_info->package = $version_info->beta['package'];
481 - if ( ! empty( $version_info->plugin ) ) {
427 + if ( isset( $version_info->plugin ) && ! empty( $version_info->plugin ) ) {
482 428 $version_info->plugin = $version_info->beta['plugin'];
483 429 }
484 430 }
485 431 }
@@ -488,9 +434,9 @@
488 434 if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) {
489 435 return false;
490 436 }
491 437
492 - $response = empty( $transient->response );
438 + $response = ! isset( $transient->response ) || empty( $transient->response );
493 439 if ( $response ) {
494 440 return true;
495 441 }
496 442
@@ -496,14 +442,12 @@
496 442
497 443 return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] === $transient->response[ $this->plugin_folder ]->new_version;
498 444 }
499 445
500 - /**
501 - * @return bool
502 - */
503 446 private function has_been_cleared() {
504 447 $last_cleared = get_option( 'frm_last_cleared' );
505 - return $last_cleared && $last_cleared > gmdate( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) );
448 +
449 + return ( $last_cleared && $last_cleared > gmdate( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) );
506 450 }
507 451
508 452 private function cleared_plugins() {
509 453 update_option( 'frm_last_cleared', gmdate( 'Y-m-d H:i:s' ) );
@@ -509,82 +453,32 @@
509 453 update_option( 'frm_last_cleared', gmdate( 'Y-m-d H:i:s' ) );
510 454 }
511 455
512 456 private function is_license_revoked() {
513 - if ( empty( $this->license ) || empty( $this->plugin_slug ) || isset( $_POST['license'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
457 + if ( empty( $this->license ) || empty( $this->plugin_slug ) || isset( $_POST['license'] ) ) { // WPCS: CSRF ok.
514 458 return;
515 459 }
516 460
517 - if ( $this->get_defined_license() ) {
518 - // Don't check if the license is defined in wp-config.php since we can't remove it.
519 - return;
520 - }
521 -
522 - // Only check weekly.
523 - if ( $this->checked_recently( '7 days', 'valid' ) || $this->is_running() ) {
524 - return;
525 - }
526 -
527 - $response = $this->get_license_status();
528 - if ( 'revoked' === $response['status'] || 'blocked' === $response['status'] || 'disabled' === $response['status'] || 'missing' === $response['status'] ) {
529 - $this->clear_license();
530 - }
531 - }
532 -
533 - /**
534 - * Has this been checked too recently?
535 - *
536 - * @param string $time ie. '1 day'.
537 - * @param string $required_status Return false if the last check does not match. ie 'valid'.
538 - *
539 - * @return bool
540 - */
541 - private function checked_recently( $time, $required_status = '' ) {
542 - $last_checked = $this->last_checked();
543 - $is_429 = isset( $last_checked['response_code'] ) && 429 === $last_checked['response_code'];
544 - if ( $is_429 ) {
545 - // If the last check was a a rate limit, we'll need to check again sooner.
546 - $time = '5 minutes';
547 - $required_status = '';
548 - }
549 -
550 - if ( $required_status && ( ! isset( $last_checked['status'] ) || $last_checked['status'] !== $required_status ) ) {
551 - // If the last check was invalid, we don't need to check again.
552 - return true;
553 - }
554 -
555 - $checked_time = $last_checked['time'] ?? false;
556 - $time_ago = gmdate( 'Y-m-d H:i:s', strtotime( '-' . $time ) );
557 - return $checked_time && $checked_time > $time_ago;
558 - }
559 -
560 - /**
561 - * @since 6.8.3 Switched to an array to store extra response info.
562 - *
563 - * @return array
564 - */
565 - private function last_checked() {
566 461 if ( is_multisite() ) {
567 462 $last_checked = get_site_option( $this->transient_key() );
568 463 } else {
569 464 $last_checked = get_option( $this->transient_key() );
570 465 }
571 - if ( $last_checked && ! is_array( $last_checked ) ) {
572 - // Get string into array for existing values.
573 - $last_checked = array( 'time' => $last_checked );
574 - }
575 - return $last_checked ? (array) $last_checked : array();
576 - }
577 466
578 - /**
579 - * @return void
580 - */
581 - private function update_last_checked() {
582 - $this->save_response['time'] = gmdate( 'Y-m-d H:i:s' );
583 - if ( is_multisite() ) {
584 - update_site_option( $this->transient_key(), $this->save_response );
585 - } else {
586 - update_option( $this->transient_key(), $this->save_response );
467 + $seven_days_ago = gmdate( 'Y-m-d H:i:s', strtotime( '-7 days' ) );
468 +
469 + if ( ! $last_checked || $last_checked < $seven_days_ago ) {
470 + // check weekly
471 + if ( is_multisite() ) {
472 + update_site_option( $this->transient_key(), gmdate( 'Y-m-d H:i:s' ) );
473 + } else {
474 + update_option( $this->transient_key(), gmdate( 'Y-m-d H:i:s' ) );
475 + }
476 +
477 + $response = $this->get_license_status();
478 + if ( 'revoked' === $response['status'] || 'blocked' === $response['status'] || 'disabled' === $response['status'] ) {
479 + $this->clear_license();
480 + }
587 481 }
588 482 }
589 483
590 484 /**
@@ -599,12 +493,14 @@
599 493 check_ajax_referer( 'frm_ajax', 'nonce' );
600 494
601 495 $license = stripslashes( FrmAppHelper::get_param( 'license', '', 'post', 'sanitize_text_field' ) );
602 496 if ( empty( $license ) ) {
603 - wp_send_json(
604 - array(
605 - 'message' => __( 'Oops! You forgot to enter your license number.', 'formidable' ),
606 - 'success' => false,
497 + wp_die(
498 + json_encode(
499 + array(
500 + 'message' => __( 'Oops! You forgot to enter your license number.', 'formidable' ),
501 + 'success' => false,
502 + )
607 503 )
608 504 );
609 505 }
610 506
@@ -610,11 +506,10 @@
610 506
611 507 $plugin_slug = FrmAppHelper::get_param( 'plugin', '', 'post', 'sanitize_text_field' );
612 508 $response = self::activate_license_for_plugin( $license, $plugin_slug );
613 509
614 - FrmInbox::clear_cache();
615 -
616 - wp_send_json( $response );
510 + echo json_encode( $response );
511 + wp_die();
617 512 }
618 513
619 514 /**
620 515 * @since 4.08
@@ -627,10 +522,8 @@
627 522 private function activate_license( $license ) {
628 523 $this->set_license( $license );
629 524 $this->license = $license;
630 525
631 - $this->die_if_not_allowed();
632 -
633 526 $response = $this->get_license_status();
634 527 $response['message'] = '';
635 528 $response['success'] = false;
636 529
@@ -648,38 +541,15 @@
648 541 if ( 'valid' === $response['status'] ) {
649 542 $is_valid = 'valid';
650 543 $response['success'] = true;
651 544 }
652 - $this->maybe_set_active( $is_valid );
545 + $this->set_active( $is_valid );
653 546 }
654 547
655 - $this->update_last_checked();
656 -
657 548 return $response;
658 549 }
659 550
660 - /**
661 - * Prevent this check from happening more than once per minute with the same license.
662 - *
663 - * @return void
664 - */
665 - private function die_if_not_allowed() {
666 - if ( ! $this->checked_recently( '2 minutes' ) ) {
667 - return;
668 - }
669 -
670 - // Don't check more than once per minute.
671 - wp_send_json(
672 - array(
673 - 'message' => __( 'Please wait two minutes before trying again.', 'formidable' ),
674 - 'success' => false,
675 - )
676 - );
677 - }
678 -
679 551 private function get_license_status() {
680 - $this->set_running();
681 -
682 552 $response = array(
683 553 'status' => 'missing',
684 554 'error' => true,
685 555 );
@@ -694,11 +564,10 @@
694 564 $license_data = $this->send_mothership_request( 'activate_license' );
695 565
696 566 // $license_data->license will be either "valid" or "invalid"
697 567 if ( is_array( $license_data ) ) {
698 - if ( ! empty( $license_data['license'] ) && in_array( $license_data['license'], array( 'valid', 'invalid' ), true ) ) {
699 - $response['status'] = $license_data['license'];
700 - $this->save_status['status'] = $license_data['license'];
568 + if ( in_array( $license_data['license'], array( 'valid', 'invalid' ), true ) ) {
569 + $response['status'] = $license_data['license'];
701 570 }
702 571 } else {
703 572 $response['status'] = $license_data;
704 573 }
@@ -705,10 +574,8 @@
705 574 } catch ( Exception $e ) {
706 575 $response['status'] = $e->getMessage();
707 576 }
708 577
709 - $this->update_last_checked();
710 - $this->done_running();
711 578 return $response;
712 579 }
713 580
714 581 private function get_messages() {
@@ -737,9 +604,10 @@
737 604 'success' => true,
738 605 'message' => __( 'Cache cleared', 'formidable' ),
739 606 );
740 607
741 - wp_send_json( $response );
608 + echo json_encode( $response );
609 + wp_die();
742 610 }
743 611
744 612 public static function deactivate() {
745 613 FrmAppHelper::permission_check( 'frm_change_settings' );
@@ -764,11 +632,11 @@
764 632 $response['message'] = $e->getMessage();
765 633 }
766 634
767 635 $this_plugin->clear_license();
768 - FrmInbox::clear_cache();
769 636
770 - wp_send_json( $response );
637 + echo json_encode( $response );
638 + wp_die();
771 639 }
772 640
773 641 /**
774 642 * @since 4.03
@@ -780,11 +648,8 @@
780 648 $this_plugin->license = $license;
781 649 return $this_plugin;
782 650 }
783 651
784 - /**
785 - * @return string
786 - */
787 652 public function send_mothership_request( $action ) {
788 653 $api_params = array(
789 654 'edd_action' => $action,
790 655 'license' => $this->license,
@@ -801,20 +666,16 @@
801 666 'timeout' => 25,
802 667 'user-agent' => $this->plugin_slug . '/' . $this->version . '; ' . get_bloginfo( 'url' ),
803 668 );
804 669
805 - $resp = wp_remote_post(
806 - $this->store_url . '?l=' . urlencode( base64_encode( $this->license ) ),
807 - $arg_array
808 - );
809 - $body = wp_remote_retrieve_body( $resp );
810 - $this->save_status = array( 'response_code' => wp_remote_retrieve_response_code( $resp ) );
670 + $resp = wp_remote_post( $this->store_url, $arg_array );
671 + $body = wp_remote_retrieve_body( $resp );
811 672
812 673 $message = __( 'Your License Key was invalid', 'formidable' );
813 674 if ( is_wp_error( $resp ) ) {
814 675 $link = FrmAppHelper::admin_upgrade_link( 'api', 'knowledgebase/why-cant-i-activate-formidable-pro/' );
815 676 /* translators: %1$s: Start link HTML, %2$s: End link HTML */
816 - $message = sprintf( __( 'You had an error communicating with the Formidable API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="' . esc_url( $link ) . '" target="_blank">', '</a>' );
677 + $message = sprintf( __( 'You had an error communicating with the Formidable API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="' . esc_url( $link ) . '" target="_blank">', '</a>' );
817 678 $message .= ' ' . $resp->get_error_message();
818 679 } elseif ( 'error' === $body || is_wp_error( $body ) ) {
819 680 $message = __( 'You had an HTTP error connecting to the Formidable API', 'formidable' );
820 681 } else {
@@ -824,69 +685,17 @@
824 685 $message = $json_res['error'];
825 686 } else {
826 687 $message = $json_res;
827 688 }
828 - } elseif ( ! empty( $resp['response'] ) && ! empty( $resp['response']['code'] ) ) {
829 - $resp['body'] = wp_strip_all_tags( $resp['body'] );
830 -
831 - $message = sprintf(
832 - /* translators: %1$s: Error code, %2$s: Error message */
833 - esc_html__( 'There was a %1$s error: %2$s', 'formidable' ),
834 - esc_html( $resp['response']['code'] ),
835 - $resp['response']['message'] . ' ' . $resp['body']
836 - );
689 + } elseif ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) {
690 + /* translators: %1$s: Error code, %2$s: Error message */
691 + $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] );
837 692 }
838 - }//end if
693 + }
839 694
840 695 return $message;
841 696 }
842 697
843 698 public function manually_queue_update() {
844 - $updates = new stdClass();
845 - $updates->last_checked = 0;
846 - $updates->response = array();
847 - $updates->translations = array();
848 - $updates->no_update = array();
849 - $updates->checked = array();
850 - set_site_transient( 'update_plugins', $updates );
851 - }
852 -
853 - /**
854 - * Set the transient key for the lock. It should be unique to the license.
855 - *
856 - * @since 6.8.3
857 - *
858 - * @return bool
859 - */
860 - protected function lock_key() {
861 - return $this->transient_lock_key . '_' . $this->license;
862 - }
863 -
864 - /**
865 - * Prevent multiple requests from running at the same time.
866 - *
867 - * @since 6.8.3
868 - *
869 - * @return bool
870 - */
871 - protected function is_running() {
872 - return get_transient( $this->lock_key() );
873 - }
874 -
875 - /**
876 - * @since 6.8.3
877 - *
878 - * @return void
879 - */
880 - protected function set_running() {
881 - set_transient( $this->lock_key(), true, 2 * MINUTE_IN_SECONDS );
882 - }
883 -
884 - /**
885 - * @since 6.8.3
886 - *
887 - * @return void
888 - */
889 - protected function done_running() {
890 - delete_transient( $this->lock_key() );
699 + set_site_transient( 'update_plugins', null );
891 700 }
892 701 }