PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +12 -76 6.256.8 View file →
@@ -8,24 +8,24 @@
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 /**
@@ -38,44 +38,20 @@
38 38 * @param array $keys
39 39 */
40 40 self::$keys = apply_filters(
41 41 'frm_application_data_keys',
42 - array( 'key', 'name', 'description', 'link', 'categories', 'views', 'forms', 'used_addons' )
42 + array( 'key', 'name', 'description', 'link', 'categories', 'views', 'forms' )
43 43 );
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 - );
44 + self::$keys_with_images = self::get_template_keys_with_local_images();
48 45 self::$categories = array();
49 46 }
50 47
51 48 /**
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 49 * Return the template keys that have embedded images. Otherwise, we want to avoid trying to load the URL and use the placeholder instead.
74 50 *
75 51 * @return array<string>
76 52 */
77 - private static function get_template_keys_with_local_png_images() {
53 + private static function get_template_keys_with_local_images() {
78 54 return array(
79 55 'business-hours',
80 56 'faq-template-wordpress',
81 57 'restaurant-menu',
@@ -81,30 +57,8 @@
81 57 'restaurant-menu',
82 58 'team-directory',
83 59 'product-review',
84 60 '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 61 );
108 62 }
109 63
110 64 /**
@@ -144,9 +98,9 @@
144 98 private static function category_matches_a_license_type( $category ) {
145 99 if ( false !== strpos( $category, '+Views' ) ) {
146 100 return true;
147 101 }
148 - return in_array( $category, FrmFormsHelper::get_license_types(), true );
102 + return in_array( $category, FrmFormsHelper::ignore_template_categories(), true );
149 103 }
150 104
151 105 /**
152 106 * @return array<string>
@@ -151,9 +105,9 @@
151 105 /**
152 106 * @return array<string>
153 107 */
154 108 public static function get_categories() {
155 - return self::$categories ?? array();
109 + return isset( self::$categories ) ? self::$categories : array();
156 110 }
157 111
158 112 /**
159 113 * @return array
@@ -158,12 +112,8 @@
158 112 /**
159 113 * @return array
160 114 */
161 115 public function as_js_object() {
162 - if ( ! is_array( self::$keys ) ) {
163 - return array();
164 - }
165 -
166 116 $application = array();
167 117 foreach ( self::$keys as $key ) {
168 118 if ( ! isset( $this->api_data[ $key ] ) ) {
169 119 continue;
@@ -177,9 +127,9 @@
177 127 } elseif ( 'categories' === $key ) {
178 128 $application[ $key ] = array_values(
179 129 array_filter(
180 130 $value,
181 - function ( $category ) {
131 + function( $category ) {
182 132 return false === strpos( $category, '+Views' );
183 133 }
184 134 )
185 135 );
@@ -198,35 +148,21 @@
198 148 }//end if
199 149 }//end foreach
200 150
201 151 $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 152
204 153 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 154 $purchase_url = $this->is_available_for_purchase();
213 155 if ( false !== $purchase_url ) {
214 156 $application['forPurchase'] = true;
215 157 }
216 158 $application['upgradeUrl'] = $this->get_admin_upgrade_link();
159 + $application['requires'] = FrmFormsHelper::get_plan_required( $application );
217 160 $application['link'] = $application['upgradeUrl'];
218 161 }
219 162
220 163 $application['isNew'] = $this->is_new();
221 164
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 165 return $application;
230 166 }
231 167
232 168 /**
@@ -292,8 +228,8 @@
292 228 array(
293 229 'content' => 'upgrade',
294 230 'medium' => 'applications',
295 231 ),
296 - 'view-templates/' . $this->api_data['slug']
232 + '/view-templates/' . $this->api_data['slug']
297 233 );
298 234 }
299 235 }