| @@ -140,9 +140,14 @@ | ||
| 140 | 140 | * @return array<array> |
| 141 | 141 | */ |
| 142 | 142 | private static function reduce_template( $total, $current ) { |
| 143 | 143 | $template = new FrmApplicationTemplate( $current ); |
| 144 | - $total[] = $template->as_js_object(); | |
| 144 | + | |
| 145 | + $js_object = $template->as_js_object(); | |
| 146 | + if ( $js_object ) { | |
| 147 | + $total[] = $js_object; | |
| 148 | + } | |
| 149 | + | |
| 145 | 150 | return $total; |
| 146 | 151 | } |
| 147 | 152 | |
| 148 | 153 | /** |
| @@ -153,9 +158,9 @@ | ||
| 153 | 158 | */ |
| 154 | 159 | private static function sort_templates( $applications ) { |
| 155 | 160 | usort( |
| 156 | 161 | $applications, |
| 157 | - function( $a, $b ) { | |
| 162 | + function ( $a, $b ) { | |
| 158 | 163 | return strcmp( $a['name'], $b['name'] ); |
| 159 | 164 | } |
| 160 | 165 | ); |
| 161 | 166 | return $applications; |
| @@ -161,10 +166,21 @@ | ||
| 161 | 166 | return $applications; |
| 162 | 167 | } |
| 163 | 168 | |
| 164 | 169 | /** |
| 170 | + * @usedby FrmAppController::admin_init(). | |
| 171 | + * | |
| 172 | + * @since 6.8 | |
| 173 | + * | |
| 165 | 174 | * @return void |
| 166 | 175 | */ |
| 176 | + public static function load_page() { | |
| 177 | + self::load_assets(); | |
| 178 | + } | |
| 179 | + | |
| 180 | + /** | |
| 181 | + * @return void | |
| 182 | + */ | |
| 167 | 183 | public static function load_assets() { |
| 168 | 184 | $plugin_url = FrmAppHelper::plugin_url(); |
| 169 | 185 | $version = FrmAppHelper::plugin_version(); |
| 170 | 186 | |
| @@ -172,9 +188,10 @@ | ||
| 172 | 188 | wp_enqueue_style( 'formidable-grids' ); |
| 173 | 189 | |
| 174 | 190 | $js_dependencies = array( |
| 175 | 191 | 'wp-i18n', |
| 176 | - 'wp-hooks', // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7. | |
| 192 | + // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7. | |
| 193 | + 'wp-hooks', | |
| 177 | 194 | 'formidable_dom', |
| 178 | 195 | ); |
| 179 | 196 | wp_register_script( 'formidable_applications', $plugin_url . '/js/admin/applications.js', $js_dependencies, $version, true ); |
| 180 | 197 | wp_register_style( 'formidable_applications', $plugin_url . '/css/admin/applications.css', array(), $version ); |
| @@ -184,8 +201,9 @@ | ||
| 184 | 201 | ); |
| 185 | 202 | wp_localize_script( 'formidable_applications', 'frmApplicationsVars', $js_vars ); |
| 186 | 203 | |
| 187 | 204 | wp_enqueue_script( 'formidable_applications' ); |
| 205 | + wp_set_script_translations( 'formidable_applications', 'formidable' ); | |
| 188 | 206 | wp_enqueue_style( 'formidable_applications' ); |
| 189 | 207 | |
| 190 | 208 | do_action( 'frm_applications_assets' ); |
| 191 | 209 | } |
| @@ -194,11 +212,9 @@ | ||
| 194 | 212 | * @return void |
| 195 | 213 | */ |
| 196 | 214 | public static function dequeue_scripts() { |
| 197 | 215 | if ( 'formidable-applications' === FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ) { |
| 198 | - // Avoid extra scripts loading on applications index that aren't needed. | |
| 199 | - wp_dequeue_script( 'frm-surveys-admin' ); | |
| 200 | - wp_dequeue_script( 'frm-quizzes-form-action' ); | |
| 216 | + FrmAppHelper::dequeue_extra_global_scripts(); | |
| 201 | 217 | } |
| 202 | 218 | } |
| 203 | 219 | |
| 204 | 220 | /** |