PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/FrmApplicationTemplate.php +15 -12 6.25 → trunk View file →
@@ -108,8 +108,9 @@
108 108 }
109 109
110 110 /**
111 111 * @param array $api_data
112 + *
112 113 * @return void
113 114 */
114 115 public function __construct( $api_data ) {
115 116 $this->api_data = $api_data;
@@ -120,8 +121,9 @@
120 121 }
121 122
122 123 /**
123 124 * @param array<string> $categories
125 + *
124 126 * @return void
125 127 */
126 128 private static function populate_category_information( $categories ) {
127 129 foreach ( $categories as $category ) {
@@ -127,8 +129,9 @@
127 129 foreach ( $categories as $category ) {
128 130 if ( self::category_matches_a_license_type( $category ) ) {
129 131 continue;
130 132 }
133 +
131 134 if ( in_array( $category, self::$categories, true ) ) {
132 135 continue;
133 136 }
134 137 self::$categories[] = $category;
@@ -138,12 +141,13 @@
138 141 /**
139 142 * @since 5.5.2
140 143 *
141 144 * @param string $category
145 + *
142 146 * @return bool
143 147 */
144 148 private static function category_matches_a_license_type( $category ) {
145 - if ( false !== strpos( $category, '+Views' ) ) {
149 + if ( str_contains( $category, '+Views' ) ) {
146 150 return true;
147 151 }
148 152 return in_array( $category, FrmFormsHelper::get_license_types(), true );
149 153 }
@@ -163,8 +167,9 @@
163 167 return array();
164 168 }
165 169
166 170 $application = array();
171 +
167 172 foreach ( self::$keys as $key ) {
168 173 if ( ! isset( $this->api_data[ $key ] ) ) {
169 174 continue;
170 175 }
@@ -178,9 +183,9 @@
178 183 $application[ $key ] = array_values(
179 184 array_filter(
180 185 $value,
181 186 function ( $category ) {
182 - return false === strpos( $category, '+Views' );
187 + return ! str_contains( $category, '+Views' );
183 188 }
184 189 )
185 190 );
186 191 } else {
@@ -189,12 +194,13 @@
189 194 } elseif ( 'forms' === $key ) {
190 195 $key = 'formCount';
191 196 }
192 197
193 - if ( 'name' === $key && ' Template' === substr( $value, -9 ) ) {
198 + if ( 'name' === $key && str_ends_with( $value, ' Template' ) ) {
194 199 // Strip off the " Template" text at the end of the name as it takes up space.
195 200 $value = substr( $value, 0, -9 );
196 201 }
202 +
197 203 $application[ $key ] = $value;
198 204 }//end if
199 205 }//end foreach
200 206
@@ -209,11 +215,13 @@
209 215 return array();
210 216 }
211 217
212 218 $purchase_url = $this->is_available_for_purchase();
219 +
213 220 if ( false !== $purchase_url ) {
214 221 $application['forPurchase'] = true;
215 222 }
223 +
216 224 $application['upgradeUrl'] = $this->get_admin_upgrade_link();
217 225 $application['link'] = $application['upgradeUrl'];
218 226 }
219 227
@@ -219,8 +227,9 @@
219 227
220 228 $application['isNew'] = $this->is_new();
221 229
222 230 $application['usedAddons'] = array();
231 +
223 232 if ( isset( $application['used_addons'] ) ) {
224 233 // Change key to camel case.
225 234 $application['usedAddons'] = $application['used_addons'];
226 235 unset( $application['used_addons'] );
@@ -245,8 +254,9 @@
245 254 return false;
246 255 }
247 256
248 257 $pro = $addons[93790];
258 +
249 259 if ( ! array_key_exists( 'type', $pro ) ) {
250 260 return false;
251 261 }
252 262
@@ -254,13 +264,9 @@
254 264 $args = array(
255 265 'license_type' => $license_type,
256 266 'plan_required' => $this->get_required_license(),
257 267 );
258 - if ( ! FrmFormsHelper::plan_is_allowed( $args ) ) {
259 - return false;
260 - }
261 -
262 - return true;
268 + return FrmFormsHelper::plan_is_allowed( $args );
263 269 }
264 270
265 271 /**
266 272 * Check if an application template is new. If it is, we include a "NEW" pill beside the title.
@@ -277,12 +283,9 @@
277 283 * @return string
278 284 */
279 285 private function get_required_license() {
280 286 $required_license = strtolower( $this->api_data['min_plan'] );
281 - if ( 'plus' === $required_license ) {
282 - $required_license = 'personal';
283 - }
284 - return $required_license;
287 + return 'plus' === $required_license ? 'personal' : $required_license;
285 288 }
286 289
287 290 /**
288 291 * @return string