PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.7
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/controllers/FrmApplicationsController.php +8 -31 6.265.5.7 View file →
@@ -18,9 +18,8 @@
18 18 $cap = self::get_required_capability();
19 19
20 20 if ( ! current_user_can( $cap ) && is_callable( 'FrmProApplicationsHelper::get_custom_applications_capability' ) ) {
21 21 $custom_applications_cap = FrmProApplicationsHelper::get_custom_applications_capability();
22 -
23 22 if ( current_user_can( $custom_applications_cap ) ) {
24 23 $cap = $custom_applications_cap;
25 24 $slug = 'edit-tags.php?taxonomy=frm_application';
26 25 $callback = '';
@@ -28,9 +27,9 @@
28 27 }
29 28
30 29 if ( ! isset( $slug ) ) {
31 30 $slug = 'formidable-applications';
32 - $callback = array( self::class, 'landing_page' );
31 + $callback = array( __CLASS__, 'landing_page' );
33 32 }
34 33
35 34 add_submenu_page( 'formidable', 'Formidable | ' . $label, $label, $cap, $slug, $callback );
36 35 }
@@ -108,9 +107,8 @@
108 107 $applications = array_filter( $applications, 'is_array' );
109 108
110 109 $unlocked_templates = array();
111 110 $locked_templates = array();
112 -
113 111 foreach ( $applications as $key => $application ) {
114 112 if ( ! is_numeric( $key ) ) {
115 113 // Skip "error" or any other non-numeric key.
116 114 continue;
@@ -125,9 +123,8 @@
125 123
126 124 $unlocked_templates = self::sort_templates( $unlocked_templates );
127 125
128 126 $applications = $unlocked_templates;
129 -
130 127 if ( current_user_can( 'administrator' ) || current_user_can( 'frm_change_settings' ) ) {
131 128 $locked_templates = self::sort_templates( $locked_templates );
132 129 $applications = array_merge( $applications, $locked_templates );
133 130 }
@@ -133,26 +130,19 @@
133 130 }
134 131
135 132 FrmApplicationTemplate::init();
136 133
137 - return array_reduce( $applications, array( self::class, 'reduce_template' ), array() );
134 + return array_reduce( $applications, array( __CLASS__, 'reduce_template' ), array() );
138 135 }
139 136
140 137 /**
141 138 * @param array $total the accumulated array of reduced application data.
142 139 * @param array $current data for the current template from the API.
143 - *
144 140 * @return array<array>
145 141 */
146 142 private static function reduce_template( $total, $current ) {
147 143 $template = new FrmApplicationTemplate( $current );
148 -
149 - $js_object = $template->as_js_object();
150 -
151 - if ( $js_object ) {
152 - $total[] = $js_object;
153 - }
154 -
144 + $total[] = $template->as_js_object();
155 145 return $total;
156 146 }
157 147
158 148 /**
@@ -158,15 +148,14 @@
158 148 /**
159 149 * Sort applications alphabetically.
160 150 *
161 151 * @param array<array> $applications
162 - *
163 152 * @return array<array>
164 153 */
165 154 private static function sort_templates( $applications ) {
166 155 usort(
167 156 $applications,
168 - function ( $a, $b ) {
157 + function( $a, $b ) {
169 158 return strcmp( $a['name'], $b['name'] );
170 159 }
171 160 );
172 161 return $applications;
@@ -172,21 +161,10 @@
172 161 return $applications;
173 162 }
174 163
175 164 /**
176 - * @usedby FrmAppController::admin_init().
177 - *
178 - * @since 6.8
179 - *
180 165 * @return void
181 166 */
182 - public static function load_page() {
183 - self::load_assets();
184 - }
185 -
186 - /**
187 - * @return void
188 - */
189 167 public static function load_assets() {
190 168 $plugin_url = FrmAppHelper::plugin_url();
191 169 $version = FrmAppHelper::plugin_version();
192 170
@@ -194,10 +172,9 @@
194 172 wp_enqueue_style( 'formidable-grids' );
195 173
196 174 $js_dependencies = array(
197 175 'wp-i18n',
198 - // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7.
199 - 'wp-hooks',
176 + 'wp-hooks', // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7.
200 177 'formidable_dom',
201 178 );
202 179 wp_register_script( 'formidable_applications', $plugin_url . '/js/admin/applications.js', $js_dependencies, $version, true );
203 180 wp_register_style( 'formidable_applications', $plugin_url . '/css/admin/applications.css', array(), $version );
@@ -207,9 +184,8 @@
207 184 );
208 185 wp_localize_script( 'formidable_applications', 'frmApplicationsVars', $js_vars );
209 186
210 187 wp_enqueue_script( 'formidable_applications' );
211 - wp_set_script_translations( 'formidable_applications', 'formidable' );
212 188 wp_enqueue_style( 'formidable_applications' );
213 189
214 190 do_action( 'frm_applications_assets' );
215 191 }
@@ -218,9 +194,11 @@
218 194 * @return void
219 195 */
220 196 public static function dequeue_scripts() {
221 197 if ( 'formidable-applications' === FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ) {
222 - FrmAppHelper::dequeue_extra_global_scripts();
198 + // Avoid extra scripts loading on applications index that aren't needed.
199 + wp_dequeue_script( 'frm-surveys-admin' );
200 + wp_dequeue_script( 'frm-quizzes-form-action' );
223 201 }
224 202 }
225 203
226 204 /**
@@ -225,9 +203,8 @@
225 203
226 204 /**
227 205 * @param string $title
228 206 * @param string $context values include 'index', 'list', and 'edit'.
229 - *
230 207 * @return void
231 208 */
232 209 public static function render_applications_header( $title, $context ) {
233 210 FrmAppHelper::print_admin_banner( true );