PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.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/FrmApplicationTemplate.php +17 -78 6.256.2 View file →
@@ -8,28 +8,31 @@
8 8 */
9 9 class FrmApplicationTemplate {
10 10
11 11 /**
12 - * @var array<string>|null
12 + * @var array<string>|null $keys
13 13 */
14 14 private static $keys;
15 15
16 16 /**
17 - * @var array<string>|null
17 + * @var array<string>|null $keys_with_images
18 18 */
19 19 private static $keys_with_images;
20 20
21 21 /**
22 - * @var array<string>|null
22 + * @var array<string>|null $categories
23 23 */
24 24 private static $categories;
25 25
26 26 /**
27 - * @var array
27 + * @var array $api_data
28 28 */
29 29 private $api_data;
30 30
31 31 /**
32 + * @param array<string> $keys
33 + * @param array<string> $keys_with_images
34 + *
32 35 * @return void
33 36 */
34 37 public static function init() {
35 38 /**
@@ -38,44 +41,20 @@
38 41 * @param array $keys
39 42 */
40 43 self::$keys = apply_filters(
41 44 'frm_application_data_keys',
42 - array( 'key', 'name', 'description', 'link', 'categories', 'views', 'forms', 'used_addons' )
45 + array( 'key', 'name', 'description', 'link', 'categories', 'views', 'forms' )
43 46 );
44 - self::$keys_with_images = array_merge(
45 - self::get_template_keys_with_local_png_images(),
46 - self::get_template_keys_with_local_webp_images()
47 - );
47 + self::$keys_with_images = self::get_template_keys_with_local_images();
48 48 self::$categories = array();
49 49 }
50 50
51 51 /**
52 - * Newer templates now use .webp files instead of .png.
53 - *
54 - * @since 6.16
55 - *
56 - * @return array<string>
57 - */
58 - private static function get_template_keys_with_local_webp_images() {
59 - return array(
60 - 'member-directory',
61 - 'link-in-bio-instagram',
62 - 'letter-of-recommendation',
63 - 'invoice-pdf',
64 - 'freelance-invoice-generator',
65 - 'contract-agreement',
66 - 'charity-tracker',
67 - 'certificate',
68 - 'testimonials',
69 - );
70 - }
71 -
72 - /**
73 52 * Return the template keys that have embedded images. Otherwise, we want to avoid trying to load the URL and use the placeholder instead.
74 53 *
75 54 * @return array<string>
76 55 */
77 - private static function get_template_keys_with_local_png_images() {
56 + private static function get_template_keys_with_local_images() {
78 57 return array(
79 58 'business-hours',
80 59 'faq-template-wordpress',
81 60 'restaurant-menu',
@@ -81,30 +60,8 @@
81 60 'restaurant-menu',
82 61 'team-directory',
83 62 'product-review',
84 63 'real-estate-listings',
85 - 'business-directory',
86 - 'artist-gallery',
87 - 'classifieds',
88 - 'community-event-calendar',
89 - 'company-timeline',
90 - 'crowdfunding',
91 - 'job-board',
92 - 'logo-cloud',
93 - 'multi-property-booking-system',
94 - 'wedding-venue-booking',
95 - 'permission-slip',
96 - 'property-directory',
97 - 'radio-station',
98 - 'recipe',
99 - 'rsvp-invite',
100 - 'searchable-directory',
101 - 'shopping-cart',
102 - 'sports-league-calendar',
103 - 'staff-directory',
104 - 'tiered-pricing',
105 - 'trip-itinerary',
106 - 'twitterx',
107 64 );
108 65 }
109 66
110 67 /**
@@ -144,9 +101,9 @@
144 101 private static function category_matches_a_license_type( $category ) {
145 102 if ( false !== strpos( $category, '+Views' ) ) {
146 103 return true;
147 104 }
148 - return in_array( $category, FrmFormsHelper::get_license_types(), true );
105 + return in_array( $category, FrmFormsHelper::ignore_template_categories(), true );
149 106 }
150 107
151 108 /**
152 109 * @return array<string>
@@ -151,9 +108,9 @@
151 108 /**
152 109 * @return array<string>
153 110 */
154 111 public static function get_categories() {
155 - return self::$categories ?? array();
112 + return isset( self::$categories ) ? self::$categories : array();
156 113 }
157 114
158 115 /**
159 116 * @return array
@@ -158,12 +115,8 @@
158 115 /**
159 116 * @return array
160 117 */
161 118 public function as_js_object() {
162 - if ( ! is_array( self::$keys ) ) {
163 - return array();
164 - }
165 -
166 119 $application = array();
167 120 foreach ( self::$keys as $key ) {
168 121 if ( ! isset( $this->api_data[ $key ] ) ) {
169 122 continue;
@@ -177,9 +130,9 @@
177 130 } elseif ( 'categories' === $key ) {
178 131 $application[ $key ] = array_values(
179 132 array_filter(
180 133 $value,
181 - function ( $category ) {
134 + function( $category ) {
182 135 return false === strpos( $category, '+Views' );
183 136 }
184 137 )
185 138 );
@@ -194,39 +147,25 @@
194 147 // Strip off the " Template" text at the end of the name as it takes up space.
195 148 $value = substr( $value, 0, -9 );
196 149 }
197 150 $application[ $key ] = $value;
198 - }//end if
199 - }//end foreach
151 + }
152 + }
200 153
201 154 $application['hasLiteThumbnail'] = in_array( $application['key'], self::$keys_with_images, true );
202 - $application['isWebp'] = in_array( $application['key'], self::get_template_keys_with_local_webp_images(), true );
203 155
204 156 if ( ! array_key_exists( 'url', $application ) ) {
205 - $application['requires'] = FrmFormsHelper::get_plan_required( $application );
206 -
207 - if ( false === $application['requires'] ) {
208 - // Application is invalid if the URL is unavailable and there is no plan required.
209 - return array();
210 - }
211 -
212 157 $purchase_url = $this->is_available_for_purchase();
213 158 if ( false !== $purchase_url ) {
214 159 $application['forPurchase'] = true;
215 160 }
216 161 $application['upgradeUrl'] = $this->get_admin_upgrade_link();
162 + $application['requires'] = FrmFormsHelper::get_plan_required( $application );
217 163 $application['link'] = $application['upgradeUrl'];
218 164 }
219 165
220 166 $application['isNew'] = $this->is_new();
221 167
222 - $application['usedAddons'] = array();
223 - if ( isset( $application['used_addons'] ) ) {
224 - // Change key to camel case.
225 - $application['usedAddons'] = $application['used_addons'];
226 - unset( $application['used_addons'] );
227 - }
228 -
229 168 return $application;
230 169 }
231 170
232 171 /**
@@ -292,8 +231,8 @@
292 231 array(
293 232 'content' => 'upgrade',
294 233 'medium' => 'applications',
295 234 ),
296 - 'view-templates/' . $this->api_data['slug']
235 + '/view-templates/' . $this->api_data['slug']
297 236 );
298 237 }
299 238 }