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