PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1.2
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/FrmFormApi.php +1 -32 6.266.16.1.2 View file →
@@ -28,12 +28,8 @@
28 28 protected $new_days = 90;
29 29
30 30 /**
31 31 * @since 3.06
32 - *
33 - * @param string|null $license The license key.
34 - *
35 - * @return void
36 32 */
37 33 public function __construct( $license = null ) {
38 34 $this->set_license( $license );
39 35 $this->set_cache_key();
@@ -41,16 +37,13 @@
41 37
42 38 /**
43 39 * @since 3.06
44 40 *
45 - * @param string|null $license The license key.
46 - *
47 41 * @return void
48 42 */
49 43 private function set_license( $license ) {
50 44 if ( $license === null ) {
51 45 $edd_update = $this->get_pro_updater();
52 -
53 46 if ( ! empty( $edd_update ) ) {
54 47 $license = $edd_update->license;
55 48 }
56 49 }
@@ -58,9 +51,8 @@
58 51 }
59 52
60 53 /**
61 54 * @since 3.06
62 - *
63 55 * @return string
64 56 */
65 57 public function get_license() {
66 58 return $this->license;
@@ -76,9 +68,8 @@
76 68 }
77 69
78 70 /**
79 71 * @since 3.06
80 - *
81 72 * @return string
82 73 */
83 74 public function get_cache_key() {
84 75 return $this->cache_key;
@@ -85,20 +76,17 @@
85 76 }
86 77
87 78 /**
88 79 * @since 3.06
89 - *
90 80 * @return array
91 81 */
92 82 public function get_api_info() {
93 83 $url = $this->api_url();
94 -
95 84 if ( ! empty( $this->license ) ) {
96 85 $url .= '?l=' . urlencode( base64_encode( $this->license ) );
97 86 }
98 87
99 88 $addons = $this->get_cached();
100 -
101 89 if ( is_array( $addons ) ) {
102 90 return $addons;
103 91 }
104 92
@@ -110,9 +98,8 @@
110 98 $this->set_running();
111 99
112 100 // We need to know the version number to allow different downloads.
113 101 $agent = 'formidable/' . FrmAppHelper::plugin_version();
114 -
115 102 if ( class_exists( 'FrmProDb' ) ) {
116 103 $agent = 'formidable-pro/' . FrmProDb::$plug_version;
117 104 }
118 105
@@ -140,9 +127,8 @@
140 127 }
141 128
142 129 if ( isset( $addon['categories'] ) ) {
143 130 $cats = array_intersect( $this->skip_categories(), $addon['categories'] );
144 -
145 131 if ( ! empty( $cats ) ) {
146 132 unset( $addons[ $k ] );
147 133 continue;
148 134 }
@@ -179,9 +165,8 @@
179 165 * @return void
180 166 */
181 167 protected function set_running() {
182 168 $expires = 2 * MINUTE_IN_SECONDS;
183 -
184 169 if ( $this->run_as_multisite() ) {
185 170 set_site_transient( $this->transient_key(), true, $expires );
186 171 return;
187 172 }
@@ -218,9 +203,9 @@
218 203 *
219 204 * @return string
220 205 */
221 206 protected function transient_key() {
222 - return strtolower( self::class ) . '_request_lock';
207 + return strtolower( __CLASS__ ) . '_request_lock';
223 208 }
224 209
225 210 /**
226 211 * @since 3.06
@@ -255,12 +240,10 @@
255 240 public function get_addon_for_license( $license_plugin, $addons = array() ) {
256 241 if ( empty( $addons ) ) {
257 242 $addons = $this->get_api_info();
258 243 }
259 -
260 244 $download_id = $license_plugin->download_id;
261 245 $plugin = array();
262 -
263 246 if ( empty( $download_id ) && ! empty( $addons ) ) {
264 247 foreach ( $addons as $addon ) {
265 248 if ( is_array( $addon ) && ! empty( $addon['title'] ) && strtolower( $license_plugin->plugin_name ) === strtolower( $addon['title'] ) ) {
266 249 return $addon;
@@ -274,10 +257,8 @@
274 257 }
275 258
276 259 /**
277 260 * @since 3.06
278 - *
279 - * @return false|object
280 261 */
281 262 public function get_pro_updater() {
282 263 if ( FrmAppHelper::pro_is_installed() && is_callable( 'FrmProAppHelper::get_updater' ) ) {
283 264 $updater = FrmProAppHelper::get_updater();
@@ -295,9 +276,8 @@
295 276 * @return array|bool
296 277 */
297 278 protected function get_cached() {
298 279 $cache = $this->get_cached_option();
299 -
300 280 if ( empty( $cache ) ) {
301 281 return false;
302 282 }
303 283
@@ -309,9 +289,8 @@
309 289 }
310 290
311 291 $version = FrmAppHelper::plugin_version();
312 292 $for_current = isset( $cache['version'] ) && $cache['version'] == $version;
313 -
314 293 if ( ! $for_current ) {
315 294 // Force a new check.
316 295 return false;
317 296 }
@@ -331,9 +310,8 @@
331 310 */
332 311 protected function get_cached_option() {
333 312 if ( is_multisite() ) {
334 313 $cached = get_site_option( $this->cache_key );
335 -
336 314 if ( $cached ) {
337 315 return $cached;
338 316 }
339 317 }
@@ -372,9 +350,8 @@
372 350 * @return string
373 351 */
374 352 protected function get_cache_timeout( $addons ) {
375 353 $timeout = $this->cache_timeout;
376 -
377 354 if ( isset( $addons['response_code'] ) && 429 === $addons['response_code'] ) {
378 355 $timeout = '+5 minutes';
379 356 }
380 357 return $timeout;
@@ -395,14 +372,12 @@
395 372 }
396 373
397 374 /**
398 375 * @since 3.06
399 - *
400 376 * @return array
401 377 */
402 378 public function error_for_license() {
403 379 $errors = array();
404 -
405 380 if ( ! empty( $this->license ) ) {
406 381 $errors = $this->get_error_from_response();
407 382 }
408 383
@@ -410,11 +385,8 @@
410 385 }
411 386
412 387 /**
413 388 * @since 3.06
414 - *
415 - * @param array $addons
416 - *
417 389 * @return array
418 390 */
419 391 public function get_error_from_response( $addons = array() ) {
420 392 if ( empty( $addons ) ) {
@@ -419,11 +391,9 @@
419 391 public function get_error_from_response( $addons = array() ) {
420 392 if ( empty( $addons ) ) {
421 393 $addons = $this->get_api_info();
422 394 }
423 -
424 395 $errors = array();
425 -
426 396 if ( isset( $addons['error'] ) ) {
427 397 if ( is_string( $addons['error'] ) ) {
428 398 $errors[] = $addons['error'];
429 399 } elseif ( ! empty( $addons['error']['message'] ) ) {
@@ -441,9 +411,8 @@
441 411 *
442 412 * @since 6.0
443 413 *
444 414 * @param array $addon
445 - *
446 415 * @return bool
447 416 */
448 417 protected function is_new( $addon ) {
449 418 return strtotime( $addon['released'] ) > strtotime( '-' . $this->new_days . ' days' );