| @@ -13,10 +13,11 @@ | ||
| 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 | if ( current_user_can( $custom_applications_cap ) ) { |
| @@ -27,12 +28,12 @@ | ||
| 27 | 28 | } |
| 28 | 29 | |
| 29 | 30 | if ( ! isset( $slug ) ) { |
| 30 | 31 | $slug = 'formidable-applications'; |
| 31 | - $callback = array( self::class, 'landing_page' ); | |
| 32 | + $callback = array( __CLASS__, 'landing_page' ); | |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | - add_submenu_page( 'formidable', 'Formidable | ' . $label, $label, $cap, $slug, $callback ); | |
| 35 | + add_submenu_page( 'formidable', 'Formidable | ' . $label, $label . $new_pill, $cap, $slug, $callback ); | |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | /** |
| 38 | 39 | * Get the required capability for accessing the Applications dashboard. |
| @@ -71,11 +72,8 @@ | ||
| 71 | 72 | * |
| 72 | 73 | * @return void |
| 73 | 74 | */ |
| 74 | 75 | public static function get_applications_data() { |
| 75 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 76 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 77 | - | |
| 78 | 76 | $view = FrmAppHelper::get_param( 'view', '', 'get', 'sanitize_text_field' ); |
| 79 | 77 | $data = array(); |
| 80 | 78 | |
| 81 | 79 | if ( 'applications' !== $view ) { |
| @@ -107,14 +105,9 @@ | ||
| 107 | 105 | $applications = array_filter( $applications, 'is_array' ); |
| 108 | 106 | |
| 109 | 107 | $unlocked_templates = array(); |
| 110 | 108 | $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 | - | |
| 109 | + foreach ( $applications as $application ) { | |
| 117 | 110 | if ( ! empty( $application['url'] ) ) { |
| 118 | 111 | $unlocked_templates[] = $application; |
| 119 | 112 | } else { |
| 120 | 113 | $locked_templates[] = $application; |
| @@ -130,9 +123,9 @@ | ||
| 130 | 123 | } |
| 131 | 124 | |
| 132 | 125 | FrmApplicationTemplate::init(); |
| 133 | 126 | |
| 134 | - return array_reduce( $applications, array( self::class, 'reduce_template' ), array() ); | |
| 127 | + return array_reduce( $applications, array( __CLASS__, 'reduce_template' ), array() ); | |
| 135 | 128 | } |
| 136 | 129 | |
| 137 | 130 | /** |
| 138 | 131 | * @param array $total the accumulated array of reduced application data. |
| @@ -140,14 +133,9 @@ | ||
| 140 | 133 | * @return array<array> |
| 141 | 134 | */ |
| 142 | 135 | private static function reduce_template( $total, $current ) { |
| 143 | 136 | $template = new FrmApplicationTemplate( $current ); |
| 144 | - | |
| 145 | - $js_object = $template->as_js_object(); | |
| 146 | - if ( $js_object ) { | |
| 147 | - $total[] = $js_object; | |
| 148 | - } | |
| 149 | - | |
| 137 | + $total[] = $template->as_js_object(); | |
| 150 | 138 | return $total; |
| 151 | 139 | } |
| 152 | 140 | |
| 153 | 141 | /** |
| @@ -158,9 +146,9 @@ | ||
| 158 | 146 | */ |
| 159 | 147 | private static function sort_templates( $applications ) { |
| 160 | 148 | usort( |
| 161 | 149 | $applications, |
| 162 | - function ( $a, $b ) { | |
| 150 | + function( $a, $b ) { | |
| 163 | 151 | return strcmp( $a['name'], $b['name'] ); |
| 164 | 152 | } |
| 165 | 153 | ); |
| 166 | 154 | return $applications; |
| @@ -166,21 +154,10 @@ | ||
| 166 | 154 | return $applications; |
| 167 | 155 | } |
| 168 | 156 | |
| 169 | 157 | /** |
| 170 | - * @usedby FrmAppController::admin_init(). | |
| 171 | - * | |
| 172 | - * @since 6.8 | |
| 173 | - * | |
| 174 | 158 | * @return void |
| 175 | 159 | */ |
| 176 | - public static function load_page() { | |
| 177 | - self::load_assets(); | |
| 178 | - } | |
| 179 | - | |
| 180 | - /** | |
| 181 | - * @return void | |
| 182 | - */ | |
| 183 | 160 | public static function load_assets() { |
| 184 | 161 | $plugin_url = FrmAppHelper::plugin_url(); |
| 185 | 162 | $version = FrmAppHelper::plugin_version(); |
| 186 | 163 | |
| @@ -188,10 +165,8 @@ | ||
| 188 | 165 | wp_enqueue_style( 'formidable-grids' ); |
| 189 | 166 | |
| 190 | 167 | $js_dependencies = array( |
| 191 | 168 | 'wp-i18n', |
| 192 | - // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7. | |
| 193 | - 'wp-hooks', | |
| 194 | 169 | 'formidable_dom', |
| 195 | 170 | ); |
| 196 | 171 | wp_register_script( 'formidable_applications', $plugin_url . '/js/admin/applications.js', $js_dependencies, $version, true ); |
| 197 | 172 | wp_register_style( 'formidable_applications', $plugin_url . '/css/admin/applications.css', array(), $version ); |
| @@ -201,9 +176,8 @@ | ||
| 201 | 176 | ); |
| 202 | 177 | wp_localize_script( 'formidable_applications', 'frmApplicationsVars', $js_vars ); |
| 203 | 178 | |
| 204 | 179 | wp_enqueue_script( 'formidable_applications' ); |
| 205 | - wp_set_script_translations( 'formidable_applications', 'formidable' ); | |
| 206 | 180 | wp_enqueue_style( 'formidable_applications' ); |
| 207 | 181 | |
| 208 | 182 | do_action( 'frm_applications_assets' ); |
| 209 | 183 | } |
| @@ -212,9 +186,11 @@ | ||
| 212 | 186 | * @return void |
| 213 | 187 | */ |
| 214 | 188 | public static function dequeue_scripts() { |
| 215 | 189 | if ( 'formidable-applications' === FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ) { |
| 216 | - 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' ); | |
| 217 | 193 | } |
| 218 | 194 | } |
| 219 | 195 | |
| 220 | 196 | /** |
| @@ -222,8 +198,7 @@ | ||
| 222 | 198 | * @param string $context values include 'index', 'list', and 'edit'. |
| 223 | 199 | * @return void |
| 224 | 200 | */ |
| 225 | 201 | public static function render_applications_header( $title, $context ) { |
| 226 | - FrmAppHelper::print_admin_banner( true ); | |
| 227 | 202 | require self::get_view_path() . 'header.php'; |
| 228 | 203 | } |
| 229 | 204 | } |