| @@ -112,8 +112,9 @@ | ||
| 112 | 112 | // are registered on AJAX requests originating from the Tools tab. |
| 113 | 113 | // Guarded to AJAX only to prevent a duplicate admin menu entry on normal page loads. |
| 114 | 114 | if ( wp_doing_ajax() ) { |
| 115 | 115 | wd_di()->get( Firewall::class ); |
| 116 | + wd_di()->get( Audit_Logging::class ); | |
| 116 | 117 | } |
| 117 | 118 | } |
| 118 | 119 | |
| 119 | 120 | /** |
| @@ -182,8 +183,9 @@ | ||
| 182 | 183 | |
| 183 | 184 | // Include Module data for the Tools tab. |
| 184 | 185 | $scan_controller = wd_di()->get( Scan::class ); |
| 185 | 186 | $firewall_controller = wd_di()->get( Firewall::class ); |
| 187 | + $audit_logging_controller = wd_di()->get( Audit_Logging::class ); | |
| 186 | 188 | $blocklist_monitor_controller = wd_di()->get( Blocklist_Monitor::class ); |
| 187 | 189 | $notification_controller = wd_di()->get( Notification::class ); |
| 188 | 190 | $recipients_controller = wd_di()->get( Recipients::class ); |
| 189 | 191 | wp_localize_script( |
| @@ -195,8 +197,9 @@ | ||
| 195 | 197 | array( |
| 196 | 198 | 'settings' => array_merge( $data, array( 'security_headers' => $sh_data ) ), |
| 197 | 199 | 'scan' => $scan_controller->data_frontend(), |
| 198 | 200 | 'firewall' => $firewall_controller->data_frontend(), |
| 201 | + 'audit_logging' => $audit_logging_controller->settings_data_frontend(), | |
| 199 | 202 | 'blocklist_monitor' => $blocklist_monitor_controller->data_frontend(), |
| 200 | 203 | 'notification' => $notification_controller->data_frontend(), |
| 201 | 204 | 'recipients' => $recipients_controller->data_frontend(), |
| 202 | 205 | 'routes' => $routes, |
| @@ -206,9 +209,9 @@ | ||
| 206 | 209 | ); |
| 207 | 210 | |
| 208 | 211 | wp_enqueue_style( |
| 209 | 212 | $handle, |
| 210 | - WP_DEFENDER_BASE_URL . 'assets/css/showcase.css', | |
| 213 | + WP_DEFENDER_BASE_URL . 'assets/css/core-ui.css', | |
| 211 | 214 | array(), |
| 212 | 215 | DEFENDER_VERSION |
| 213 | 216 | ); |
| 214 | 217 | |
| @@ -414,9 +417,29 @@ | ||
| 414 | 417 | * |
| 415 | 418 | * @return bool Returns true if the importer data is valid, false otherwise. |
| 416 | 419 | */ |
| 417 | 420 | private function validate_importer( $importer ): bool { |
| 418 | - return $this->service->verify_config_data( $importer ); | |
| 421 | + if ( ! $this->service->verify_config_data( $importer ) || ! is_array( $importer['configs'] ) ) { | |
| 422 | + return false; | |
| 423 | + } | |
| 424 | + | |
| 425 | + $sample = $this->service->gather_data(); | |
| 426 | + foreach ( $importer['configs'] as $slug => $module ) { | |
| 427 | + // Ignore whole modules unavailable on this site, such as Pro-only modules in Free builds. | |
| 428 | + if ( ! isset( $sample[ $slug ] ) ) { | |
| 429 | + continue; | |
| 430 | + } | |
| 431 | + | |
| 432 | + if ( | |
| 433 | + ! is_array( $module ) | |
| 434 | + || ! is_array( $sample[ $slug ] ) | |
| 435 | + || array() !== array_diff_key( $module, $sample[ $slug ] ) | |
| 436 | + ) { | |
| 437 | + return false; | |
| 438 | + } | |
| 439 | + } | |
| 440 | + | |
| 441 | + return true; | |
| 419 | 442 | } |
| 420 | 443 | |
| 421 | 444 | /** |
| 422 | 445 | * Import config. |
| @@ -484,9 +507,9 @@ | ||
| 484 | 507 | $pro_modules[] = $slug; |
| 485 | 508 | } |
| 486 | 509 | } |
| 487 | 510 | |
| 488 | - if ( ! empty( $pro_modules ) ) { | |
| 511 | + if ( array() !== $pro_modules ) { | |
| 489 | 512 | $module_names = array_map( |
| 490 | 513 | function ( $slug ) { |
| 491 | 514 | $names = array( |
| 492 | 515 | 'audit' => esc_html__( 'Audit Logs', 'defender-security' ), |