PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +16 -60 6.4.25.0 View file →
@@ -9,15 +9,8 @@
9 9 protected $cache_key = '';
10 10 protected $cache_timeout = '+6 hours';
11 11
12 12 /**
13 - * The number of days an add-on is new.
14 - *
15 - * @var int $new_days
16 - */
17 - protected $new_days = 90;
18 -
19 - /**
20 13 * @since 3.06
21 14 */
22 15 public function __construct( $license = null ) {
23 16 $this->set_license( $license );
@@ -25,10 +18,8 @@
25 18 }
26 19
27 20 /**
28 21 * @since 3.06
29 - *
30 - * @return void
31 22 */
32 23 private function set_license( $license ) {
33 24 if ( $license === null ) {
34 25 $edd_update = $this->get_pro_updater();
@@ -48,10 +39,8 @@
48 39 }
49 40
50 41 /**
51 42 * @since 3.06
52 - *
53 - * @return void
54 43 */
55 44 protected function set_cache_key() {
56 45 $this->cache_key = 'frm_addons_l' . ( empty( $this->license ) ? '' : md5( $this->license ) );
57 46 }
@@ -74,9 +63,9 @@
74 63 $url .= '?l=' . urlencode( base64_encode( $this->license ) );
75 64 }
76 65
77 66 $addons = $this->get_cached();
78 - if ( is_array( $addons ) ) {
67 + if ( ! empty( $addons ) ) {
79 68 return $addons;
80 69 }
81 70
82 71 // We need to know the version number to allow different downloads.
@@ -91,36 +80,30 @@
91 80 'timeout' => 25,
92 81 'user-agent' => $agent . '; ' . get_bloginfo( 'url' ),
93 82 )
94 83 );
95 -
96 84 if ( is_array( $response ) && ! is_wp_error( $response ) ) {
97 - $addons = $response['body'] ? json_decode( $response['body'], true ) : array();
98 - }
85 + $addons = $response['body'];
86 + if ( ! empty( $addons ) ) {
87 + $addons = json_decode( $addons, true );
99 88
100 - if ( ! is_array( $addons ) ) {
101 - $addons = array();
102 - }
103 -
104 - foreach ( $addons as $k => $addon ) {
105 - if ( ! is_array( $addon ) ) {
106 - continue;
107 - }
108 -
109 - if ( isset( $addon['categories'] ) ) {
110 - $cats = array_intersect( $this->skip_categories(), $addon['categories'] );
111 - if ( ! empty( $cats ) ) {
112 - unset( $addons[ $k ] );
113 - continue;
89 + foreach ( $addons as $k => $addon ) {
90 + if ( ! isset( $addon['categories'] ) ) {
91 + continue;
92 + }
93 + $cats = array_intersect( $this->skip_categories(), $addon['categories'] );
94 + if ( ! empty( $cats ) ) {
95 + unset( $addons[ $k ] );
96 + }
114 97 }
115 - }
116 98
117 - if ( ! array_key_exists( 'is_new', $addon ) && array_key_exists( 'released', $addon ) ) {
118 - $addons[ $k ]['is_new'] = $this->is_new( $addon );
99 + $this->set_cached( $addons );
119 100 }
120 101 }
121 102
122 - $this->set_cached( $addons );
103 + if ( empty( $addons ) ) {
104 + return array();
105 + }
123 106
124 107 return $addons;
125 108 }
126 109
@@ -125,10 +108,8 @@
125 108 }
126 109
127 110 /**
128 111 * @since 3.06
129 - *
130 - * @return string
131 112 */
132 113 protected function api_url() {
133 114 return 'https://formidableforms.com/wp-json/s11edd/v1/updates/';
134 115 }
@@ -134,10 +115,8 @@
134 115 }
135 116
136 117 /**
137 118 * @since 3.06
138 - *
139 - * @return string[]
140 119 */
141 120 protected function skip_categories() {
142 121 return array( 'WordPress Form Templates', 'WordPress Form Style Templates' );
143 122 }
@@ -145,9 +124,8 @@
145 124 /**
146 125 * @since 3.06
147 126 *
148 127 * @param object $license_plugin The FrmAddon object
149 - * @param array $addons
150 128 *
151 129 * @return array
152 130 */
153 131 public function get_addon_for_license( $license_plugin, $addons = array() ) {
@@ -189,10 +167,8 @@
189 167 */
190 168 protected function get_cached() {
191 169 $cache = get_option( $this->cache_key );
192 170
193 - FrmAppHelper::filter_gmt_offset();
194 -
195 171 if ( empty( $cache ) || empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
196 172 return false; // Cache is expired
197 173 }
198 174
@@ -207,16 +183,10 @@
207 183 }
208 184
209 185 /**
210 186 * @since 3.06
211 - *
212 - * @param array $addons
213 - *
214 - * @return void
215 187 */
216 188 protected function set_cached( $addons ) {
217 - FrmAppHelper::filter_gmt_offset();
218 -
219 189 $data = array(
220 190 'timeout' => strtotime( $this->cache_timeout, current_time( 'timestamp' ) ),
221 191 'value' => json_encode( $addons ),
222 192 'version' => FrmAppHelper::plugin_version(),
@@ -226,10 +196,8 @@
226 196 }
227 197
228 198 /**
229 199 * @since 3.06
230 - *
231 - * @return void
232 200 */
233 201 public function reset_cached() {
234 202 delete_option( $this->cache_key );
235 203 }
@@ -261,18 +229,6 @@
261 229 do_action( 'frm_license_error', $addons['error'] );
262 230 }
263 231
264 232 return $errors;
265 - }
266 -
267 - /**
268 - * Check if a template is new.
269 - *
270 - * @since 6.0
271 - *
272 - * @param array $addon
273 - * @return bool
274 - */
275 - protected function is_new( $addon ) {
276 - return strtotime( $addon['released'] ) > strtotime( '-' . $this->new_days . ' days' );
277 233 }
278 234 }