PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/traits/defender-bootstrap.php +40 -59 6.0.0 → 6.3.0 View file →
@@ -16,9 +16,8 @@
16 16 use WP_Defender\Controller\WAF;
17 17 use WP_Defender\Controller\Scan;
18 18 use WP_Defender\Component\Crypt;
19 19 use WP_Defender\Behavior\WPMUDEV;
20 -use WP_Defender\Controller\Onboard;
21 20 use WP_Defender\Controller\Webauthn;
22 21 use WP_Defender\Controller\Dashboard;
23 22 use WP_Defender\Controller\Captcha;
24 23 use WP_Defender\Controller\Recipients;
@@ -33,11 +32,9 @@
33 32 use WP_Defender\Controller\Login_Access;
34 33 use WP_Defender\Controller\Password_Reset;
35 34 use WP_Defender\Controller\Setup_Wizard;
36 35 use WP_Defender\Controller\Strong_Password;
37 -use WP_Defender\Controller\Expert_Services;
38 36 use WP_Defender\Controller\Security_Tweaks;
39 -use WP_Defender\Controller\Security_Headers;
40 37 use WP_Defender\Controller\Blocklist_Monitor;
41 38 use WP_Defender\Controller\Session_Protection;
42 39 use WP_Defender\Controller\Password_Protection;
43 40 use WP_Defender\Component\Network_Cron_Manager;
@@ -44,9 +41,8 @@
44 41 use WP_Defender\Component\Logger\Rotation_Logger;
45 42 use WP_Defender\Component\Firewall as Firewall_Component;
46 43 use WP_Defender\Controller\Firewall as Firewall_Controller;
47 44 use WP_Defender\Controller\Hub_Connector as Hub_Connector_Controller;
48 -use WP_Defender\Model\Onboard as Onboard_Model;
49 45 use WP_Defender\Controller\Rate as Rate_Controller;
50 46 use WP_Defender\Component\Rate as Rate_Component;
51 47 use WP_Defender\Upgrader;
52 48
@@ -169,8 +165,39 @@
169 165 $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
170 166 }
171 167
172 168 /**
169 + * Creates the audit log table used for caching audit events.
170 + */
171 + protected function create_table_audit_log(): void {
172 + global $wpdb;
173 +
174 + $charset_collate = $wpdb->get_charset_collate();
175 + // Audit log table. Though our data mainly store on API side, we will need a table for caching.
176 + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->base_prefix}defender_audit_log (
177 + `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
178 + `timestamp` int NOT NULL,
179 + `event_type` varchar(255) NOT NULL,
180 + `action_type` varchar(255) NOT NULL,
181 + `site_url` varchar(255) NOT NULL,
182 + `user_id` int NOT NULL,
183 + `context` varchar(255) NOT NULL,
184 + `ip` varchar(45) NOT NULL,
185 + `msg` varchar(255) NOT NULL,
186 + `blog_id` int NOT NULL,
187 + `synced` int NOT NULL,
188 + `ttl` int NOT NULL,
189 + PRIMARY KEY (`id`),
190 + KEY `event_type` (`event_type`),
191 + KEY `action_type` (`action_type`),
192 + KEY `user_id` (`user_id`),
193 + KEY `context` (`context`),
194 + KEY `ip` (`ip`)
195 +) $charset_collate;";
196 + $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
197 + }
198 +
199 + /**
173 200 * Creates Defender's tables.
174 201 *
175 202 * @since 2.7.1 No use dbDelta because PHP v8.1 triggers an error when calling query "DESCRIBE {$table};" if the
176 203 * table doesn't exist.
@@ -263,8 +290,10 @@
263 290 // Create Blocklist table.
264 291 $this->create_table_blocklist();
265 292 // Create Quarantine table.
266 293 $this->create_table_quarantine();
294 + // Create Audit Log table.
295 + $this->create_table_audit_log();
267 296 }
268 297
269 298 /**
270 299 * Check if all quarantine-dependent tables use the InnoDB storage engine.
@@ -353,34 +382,8 @@
353 382 $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
354 383 }
355 384
356 385 /**
357 - * Check if this is onboarding.
358 - *
359 - * @return bool
360 - */
361 - private function is_onboarding(): bool {
362 - // Temporary switch for setup-wizard showcase phase:
363 - // keep legacy onboarding disabled until new flow integration.
364 - $enable_legacy_onboarding = (bool) apply_filters( 'wpdef_enable_legacy_onboarding', false );
365 - if ( ! $enable_legacy_onboarding ) {
366 - return false;
367 - }
368 -
369 - /**
370 - * Display Onboarding if:
371 - * it's a fresh install and there were no requests from the Hub before,
372 - * after Reset Settings.
373 - *
374 - * @var HUB
375 - */
376 - $hub_class = wd_di()->get( HUB::class );
377 - $hub_class->set_onboarding_status( Onboard_Model::maybe_show_onboarding() );
378 -
379 - return $hub_class->get_onboarding_status() && ! defender_is_wp_cli();
380 - }
381 -
382 - /**
383 386 * Initialize the common modules of the application.
384 387 *
385 388 * @return void
386 389 */
@@ -388,16 +391,8 @@
388 391 // Init main ORM.
389 392 Array_Cache::set( 'orm', new Mapper() );
390 393
391 394 // New setup wizard is rendered directly inside Dashboard React UI.
392 - // Keep legacy onboarding initialization commented for rollback/reference.
393 - // if ( $this->is_onboarding() ) {
394 - // If it's cli we should start this normally.
395 - // Array_Cache::set( 'onboard', wd_di()->get( Onboard::class) );
396 - // } else {
397 - // Initialize the main controllers of every module.
398 - // wd_di()->get( Dashboard::class );
399 - // }
400 395 wd_di()->get( Setup_Wizard::class );
401 396 wd_di()->get( \WP_Defender\Controller\Activity_Log::class );
402 397 wd_di()->get( Dashboard::class );
403 398 wd_di()->get( Scan::class );
@@ -409,9 +404,8 @@
409 404 wd_di()->get( Mask_Login::class );
410 405 wd_di()->get( WAF::class );
411 406 wd_di()->get( Two_Factor::class );
412 407 wd_di()->get( Mask_Login::class );
413 - // wd_di()->get( Security_Headers::class );
414 408 wd_di()->get( Captcha::class );
415 409 wd_di()->get( Notification::class );
416 410 wd_di()->get( Recipients::class );
417 411 wd_di()->get( Main_Setting::class );
@@ -418,9 +412,8 @@
418 412 wd_di()->get( Blocklist_Monitor::class );
419 413 wd_di()->get( Password_Protection::class );
420 414 wd_di()->get( Password_Reset::class );
421 415 wd_di()->get( Webauthn::class );
422 - // wd_di()->get( Expert_Services::class );
423 416 wd_di()->get( Hub_Connector_Controller::class );
424 417 wd_di()->get( Strong_Password::class );
425 418 wd_di()->get( Session_Protection::class );
426 419 wd_di()->get( Quarantine::class );
@@ -480,12 +473,12 @@
480 473 }'
481 474 );
482 475
483 476 $css_files = array(
484 - 'defender' => WP_DEFENDER_BASE_URL . 'assets/css/styles.css',
485 - 'def-sui' => WP_DEFENDER_BASE_URL . 'assets/css/shared-ui.css',
486 - 'def-admin' => WP_DEFENDER_BASE_URL . 'assets/css/admin.css',
487 - 'def-showcase' => WP_DEFENDER_BASE_URL . 'assets/css/showcase.css',
477 + 'defender' => WP_DEFENDER_BASE_URL . 'assets/css/styles.css',
478 + 'def-sui' => WP_DEFENDER_BASE_URL . 'assets/css/shared-ui.css',
479 + 'def-admin' => WP_DEFENDER_BASE_URL . 'assets/css/admin.css',
480 + 'def-core-ui-style' => WP_DEFENDER_BASE_URL . 'assets/css/core-ui.css',
488 481 );
489 482
490 483 foreach ( $css_files as $slug => $file ) {
491 484 wp_register_style( $slug, $file, array(), DEFENDER_VERSION );
@@ -525,12 +518,8 @@
525 518 $base_url . 'assets/js/core-ui.js',
526 519 array( 'def-vue', 'def-manifest' ),
527 520 ),
528 521 // React files.
529 - 'def-showcase' => array(
530 - $base_url . 'assets/js/showcase.js',
531 - $dependencies,
532 - ),
533 522 'def-setup-wizard' => array(
534 523 $base_url . 'assets/js/setup-wizard.js',
535 524 $dependencies,
536 525 ),
@@ -559,14 +548,9 @@
559 548 private function localize_script(): void {
560 549 $wpmu_dev = new WPMUDEV();
561 550 global $wp_defender_central;
562 551
563 - $misc = array();
564 - $data_tracking = wd_di()->get( Data_Tracking::class );
565 - $is_tracking = $data_tracking->show_tracking_modal();
566 - if ( $is_tracking ) {
567 - $misc = $data_tracking->get_tracking_modal();
568 - }
552 + $misc = array();
569 553 $misc['high_contrast'] = defender_high_contrast();
570 554 $is_wp_org = defender_is_wp_org_version();
571 555 if ( $is_wp_org ) {
572 556 $misc['rating'] = array();
@@ -604,9 +588,8 @@
604 588 'wpmudev_url' => WP_DEFENDER_DOCS_LINK,
605 589 'wpmudev_support_ticket_text' => defender_support_ticket_text(),
606 590 'wpmudev_api_base_url' => $wpmu_dev->get_api_base_url(),
607 591 'upgrade_title' => esc_html__( 'UPGRADE TO PRO', 'defender-security' ),
608 - 'tracking_modal' => $is_tracking ? 'show' : 'hide',
609 592 'hosted' => $wpmu_dev->is_wpmu_hosting(),
610 593 'file_upload_nonce' => wp_create_nonce( 'defender_file_upload' ),
611 594 'wpmudev_hub_link' => 'https://wpmudev.com/hub2/',
612 595 )
@@ -679,9 +662,9 @@
679 662 if ( 'defender-security' !== $domain ) {
680 663 return $translations;
681 664 }
682 665
683 - static $served = false;
666 + static $served = false;
684 667 static $cached_json = null;
685 668
686 669 if ( $served ) {
687 670 return wp_json_encode(
@@ -719,9 +702,9 @@
719 702 'lang' => $locale,
720 703 ),
721 704 );
722 705
723 - if ( ! empty( $mo->headers['Plural-Forms'] ) ) {
706 + if ( isset( $mo->headers['Plural-Forms'] ) && '' !== $mo->headers['Plural-Forms'] ) {
724 707 $locale_data['']['plural-forms'] = $mo->headers['Plural-Forms'];
725 708 }
726 709
727 710 foreach ( $mo->entries as $msgid => $entry ) {
@@ -768,10 +751,8 @@
768 751 // Serve script translations from the single MO file our in-site translation tools produce.
769 752 add_filter( 'pre_load_script_translations', array( $this, 'provide_script_translations' ), 10, 4 );
770 753 // Register the Hub Connector early to handle the auth callback during the admin init hook.
771 754 add_action( 'plugins_loaded', array( wd_di()->get( Hub_Connector::class ), 'init' ) );
772 - // Register the Cross-Sell module.
773 - // add_action( 'init', array( wd_di()->get( \WP_Defender\Component\Cross_Sell::class ), 'init' ), 9 );
774 755 // Include admin class. Don't use is_admin().
775 756 add_action( 'admin_init', array( ( new Admin() ), 'init' ) );
776 757 // Initialize deactivation survey.
777 758 add_action( 'admin_enqueue_scripts', array( ( new Admin() ), 'init_deactivation_survey' ) );