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