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