PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / trunk
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz vtrunk
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
← All changes | inc/payments/stripe/stripe-helper.php +19 -5 2.9.1 → trunk View file →
@@ -390,12 +390,16 @@
390 390
391 391 /**
392 392 * Get the SureForms Pro License Key.
393 393 *
394 + * @param bool $allow_remote_check Whether a license-cache miss may block on the
395 + * SureCart API. Pass false from front-end request
396 + * paths - see is_pro_license_active().
394 397 * @since 2.0.0
398 + * @since 2.12.8 Added the $allow_remote_check parameter.
395 399 * @return string The SureForms Pro License Key.
396 400 */
397 - public static function get_license_key() {
401 + public static function get_license_key( $allow_remote_check = true ) {
398 402 $licensing = self::get_licensing_instance();
399 403 if ( ! $licensing ||
400 404 ! method_exists( $licensing, 'licensing_setup' ) || ! method_exists( $licensing->licensing_setup(), 'settings' ) ) {
401 405 return '';
@@ -400,9 +404,9 @@
400 404 ! method_exists( $licensing, 'licensing_setup' ) || ! method_exists( $licensing->licensing_setup(), 'settings' ) ) {
401 405 return '';
402 406 }
403 407 // Check if the SureForms Pro license is active.
404 - $is_license_active = self::is_pro_license_active();
408 + $is_license_active = self::is_pro_license_active( $allow_remote_check );
405 409 // If the license is active, get the license key.
406 410 $license_setup = $licensing->licensing_setup();
407 411 return ! empty( $is_license_active ) && is_object( $license_setup ) && method_exists( $license_setup, 'settings' ) ? $license_setup->settings()->license_key : '';
408 412 }
@@ -409,12 +413,22 @@
409 413
410 414 /**
411 415 * Check if the SureForms Pro license is active.
412 416 *
417 + * On a cache miss the Pro licensing check makes blocking wp_remote_request calls
418 + * with a 30 second timeout each. That is fine on an admin screen, but this helper
419 + * is also reached from wp_ajax_nopriv_ checkout handlers, where an unauthenticated
420 + * visitor would wait on SureCart before their payment intent is created - and a
421 + * single slow response would pin the cached verdict for the whole site.
422 + *
423 + * Pass false from those paths to read the last known status instead.
424 + *
425 + * @param bool $allow_remote_check Whether a cache miss may block on the SureCart API.
413 426 * @since 2.0.0
427 + * @since 2.12.8 Added the $allow_remote_check parameter.
414 428 * @return bool|string True if the SureForms Pro license is active, false otherwise.
415 429 */
416 - public static function is_pro_license_active() {
430 + public static function is_pro_license_active( $allow_remote_check = true ) {
417 431 $licensing = self::get_licensing_instance();
418 432 if ( ! $licensing || ! method_exists( $licensing, 'is_license_active' )
419 433 ) {
420 434 return '';
@@ -419,9 +433,9 @@
419 433 ) {
420 434 return '';
421 435 }
422 436 // Check if the SureForms Pro license is active.
423 - return $licensing->is_license_active();
437 + return $licensing->is_license_active( $allow_remote_check );
424 438 }
425 439
426 440 /**
427 441 * Get the webhook URL for Stripe.
@@ -524,9 +538,9 @@
524 538 return false;
525 539 }
526 540
527 541 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
528 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom table query to check transaction existence, table name is validated and cannot be parameterized with prepare().
542 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Custom table query to check transaction existence; table name from get_tablename() and validated (not user input); cannot be parameterized with prepare().
529 543 $count = $wpdb->get_var(
530 544 "SELECT COUNT(*) FROM {$payments_table} LIMIT 1"
531 545 );
532 546 // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared