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