PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 +19 -82 6.336.13 View file →
@@ -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,36 +57,13 @@
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 /**
111 65 * @param array $api_data
112 - *
113 66 * @return void
114 67 */
115 68 public function __construct( $api_data ) {
116 69 $this->api_data = $api_data;
@@ -121,9 +74,8 @@
121 74 }
122 75
123 76 /**
124 77 * @param array<string> $categories
125 - *
126 78 * @return void
127 79 */
128 80 private static function populate_category_information( $categories ) {
129 81 foreach ( $categories as $category ) {
@@ -129,9 +81,8 @@
129 81 foreach ( $categories as $category ) {
130 82 if ( self::category_matches_a_license_type( $category ) ) {
131 83 continue;
132 84 }
133 -
134 85 if ( in_array( $category, self::$categories, true ) ) {
135 86 continue;
136 87 }
137 88 self::$categories[] = $category;
@@ -141,16 +92,15 @@
141 92 /**
142 93 * @since 5.5.2
143 94 *
144 95 * @param string $category
145 - *
146 96 * @return bool
147 97 */
148 98 private static function category_matches_a_license_type( $category ) {
149 - if ( str_contains( $category, '+Views' ) ) {
99 + if ( false !== strpos( $category, '+Views' ) ) {
150 100 return true;
151 101 }
152 - return in_array( $category, FrmFormsHelper::get_license_types(), true );
102 + return in_array( $category, FrmFormsHelper::ignore_template_categories(), true );
153 103 }
154 104
155 105 /**
156 106 * @return array<string>
@@ -155,9 +105,9 @@
155 105 /**
156 106 * @return array<string>
157 107 */
158 108 public static function get_categories() {
159 - return self::$categories ?? array();
109 + return isset( self::$categories ) ? self::$categories : array();
160 110 }
161 111
162 112 /**
163 113 * @return array
@@ -167,9 +117,8 @@
167 117 return array();
168 118 }
169 119
170 120 $application = array();
171 -
172 121 foreach ( self::$keys as $key ) {
173 122 if ( ! isset( $this->api_data[ $key ] ) ) {
174 123 continue;
175 124 }
@@ -183,9 +132,9 @@
183 132 $application[ $key ] = array_values(
184 133 array_filter(
185 134 $value,
186 135 function ( $category ) {
187 - return ! str_contains( $category, '+Views' );
136 + return false === strpos( $category, '+Views' );
188 137 }
189 138 )
190 139 );
191 140 } else {
@@ -194,48 +143,30 @@
194 143 } elseif ( 'forms' === $key ) {
195 144 $key = 'formCount';
196 145 }
197 146
198 - if ( 'name' === $key && str_ends_with( $value, ' Template' ) ) {
147 + if ( 'name' === $key && ' Template' === substr( $value, -9 ) ) {
199 148 // Strip off the " Template" text at the end of the name as it takes up space.
200 149 $value = substr( $value, 0, -9 );
201 150 }
202 -
203 151 $application[ $key ] = $value;
204 152 }//end if
205 153 }//end foreach
206 154
207 155 $application['hasLiteThumbnail'] = in_array( $application['key'], self::$keys_with_images, true );
208 - $application['isWebp'] = in_array( $application['key'], self::get_template_keys_with_local_webp_images(), true );
209 156
210 157 if ( ! array_key_exists( 'url', $application ) ) {
211 - $application['requires'] = FrmFormsHelper::get_plan_required( $application );
212 -
213 - if ( false === $application['requires'] ) {
214 - // Application is invalid if the URL is unavailable and there is no plan required.
215 - return array();
216 - }
217 -
218 158 $purchase_url = $this->is_available_for_purchase();
219 -
220 159 if ( false !== $purchase_url ) {
221 160 $application['forPurchase'] = true;
222 161 }
223 -
224 162 $application['upgradeUrl'] = $this->get_admin_upgrade_link();
163 + $application['requires'] = FrmFormsHelper::get_plan_required( $application );
225 164 $application['link'] = $application['upgradeUrl'];
226 165 }
227 166
228 167 $application['isNew'] = $this->is_new();
229 168
230 - $application['usedAddons'] = array();
231 -
232 - if ( isset( $application['used_addons'] ) ) {
233 - // Change key to camel case.
234 - $application['usedAddons'] = $application['used_addons'];
235 - unset( $application['used_addons'] );
236 - }
237 -
238 169 return $application;
239 170 }
240 171
241 172 /**
@@ -254,9 +185,8 @@
254 185 return false;
255 186 }
256 187
257 188 $pro = $addons[93790];
258 -
259 189 if ( ! array_key_exists( 'type', $pro ) ) {
260 190 return false;
261 191 }
262 192
@@ -264,9 +194,13 @@
264 194 $args = array(
265 195 'license_type' => $license_type,
266 196 'plan_required' => $this->get_required_license(),
267 197 );
268 - return FrmFormsHelper::plan_is_allowed( $args );
198 + if ( ! FrmFormsHelper::plan_is_allowed( $args ) ) {
199 + return false;
200 + }
201 +
202 + return true;
269 203 }
270 204
271 205 /**
272 206 * Check if an application template is new. If it is, we include a "NEW" pill beside the title.
@@ -283,9 +217,12 @@
283 217 * @return string
284 218 */
285 219 private function get_required_license() {
286 220 $required_license = strtolower( $this->api_data['min_plan'] );
287 - return 'plus' === $required_license ? 'personal' : $required_license;
221 + if ( 'plus' === $required_license ) {
222 + $required_license = 'personal';
223 + }
224 + return $required_license;
288 225 }
289 226
290 227 /**
291 228 * @return string
@@ -295,8 +232,8 @@
295 232 array(
296 233 'content' => 'upgrade',
297 234 'medium' => 'applications',
298 235 ),
299 - 'view-templates/' . $this->api_data['slug']
236 + '/view-templates/' . $this->api_data['slug']
300 237 );
301 238 }
302 239 }