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