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