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 +39 -45 6.1.0 → 6.3.0 View file →
@@ -41,9 +41,8 @@
41 41 use WP_Defender\Component\Logger\Rotation_Logger;
42 42 use WP_Defender\Component\Firewall as Firewall_Component;
43 43 use WP_Defender\Controller\Firewall as Firewall_Controller;
44 44 use WP_Defender\Controller\Hub_Connector as Hub_Connector_Controller;
45 -use WP_Defender\Model\Onboard as Onboard_Model;
46 45 use WP_Defender\Controller\Rate as Rate_Controller;
47 46 use WP_Defender\Component\Rate as Rate_Component;
48 47 use WP_Defender\Upgrader;
49 48
@@ -166,8 +165,39 @@
166 165 $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
167 166 }
168 167
169 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 + /**
170 200 * Creates Defender's tables.
171 201 *
172 202 * @since 2.7.1 No use dbDelta because PHP v8.1 triggers an error when calling query "DESCRIBE {$table};" if the
173 203 * table doesn't exist.
@@ -260,8 +290,10 @@
260 290 // Create Blocklist table.
261 291 $this->create_table_blocklist();
262 292 // Create Quarantine table.
263 293 $this->create_table_quarantine();
294 + // Create Audit Log table.
295 + $this->create_table_audit_log();
264 296 }
265 297
266 298 /**
267 299 * Check if all quarantine-dependent tables use the InnoDB storage engine.
@@ -350,34 +382,8 @@
350 382 $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
351 383 }
352 384
353 385 /**
354 - * Check if this is onboarding.
355 - *
356 - * @return bool
357 - */
358 - private function is_onboarding(): bool {
359 - // Temporary switch for setup-wizard showcase phase:
360 - // keep legacy onboarding disabled until new flow integration.
361 - $enable_legacy_onboarding = (bool) apply_filters( 'wpdef_enable_legacy_onboarding', false );
362 - if ( ! $enable_legacy_onboarding ) {
363 - return false;
364 - }
365 -
366 - /**
367 - * Display Onboarding if:
368 - * it's a fresh install and there were no requests from the Hub before,
369 - * after Reset Settings.
370 - *
371 - * @var HUB
372 - */
373 - $hub_class = wd_di()->get( HUB::class );
374 - $hub_class->set_onboarding_status( Onboard_Model::maybe_show_onboarding() );
375 -
376 - return $hub_class->get_onboarding_status() && ! defender_is_wp_cli();
377 - }
378 -
379 - /**
380 386 * Initialize the common modules of the application.
381 387 *
382 388 * @return void
383 389 */
@@ -467,12 +473,12 @@
467 473 }'
468 474 );
469 475
470 476 $css_files = array(
471 - 'defender' => WP_DEFENDER_BASE_URL . 'assets/css/styles.css',
472 - 'def-sui' => WP_DEFENDER_BASE_URL . 'assets/css/shared-ui.css',
473 - 'def-admin' => WP_DEFENDER_BASE_URL . 'assets/css/admin.css',
474 - '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',
475 481 );
476 482
477 483 foreach ( $css_files as $slug => $file ) {
478 484 wp_register_style( $slug, $file, array(), DEFENDER_VERSION );
@@ -512,12 +518,8 @@
512 518 $base_url . 'assets/js/core-ui.js',
513 519 array( 'def-vue', 'def-manifest' ),
514 520 ),
515 521 // React files.
516 - 'def-showcase' => array(
517 - $base_url . 'assets/js/showcase.js',
518 - $dependencies,
519 - ),
520 522 'def-setup-wizard' => array(
521 523 $base_url . 'assets/js/setup-wizard.js',
522 524 $dependencies,
523 525 ),
@@ -546,14 +548,9 @@
546 548 private function localize_script(): void {
547 549 $wpmu_dev = new WPMUDEV();
548 550 global $wp_defender_central;
549 551
550 - $misc = array();
551 - $data_tracking = wd_di()->get( Data_Tracking::class );
552 - $is_tracking = $data_tracking->show_tracking_modal();
553 - if ( $is_tracking ) {
554 - $misc = $data_tracking->get_tracking_modal();
555 - }
552 + $misc = array();
556 553 $misc['high_contrast'] = defender_high_contrast();
557 554 $is_wp_org = defender_is_wp_org_version();
558 555 if ( $is_wp_org ) {
559 556 $misc['rating'] = array();
@@ -591,9 +588,8 @@
591 588 'wpmudev_url' => WP_DEFENDER_DOCS_LINK,
592 589 'wpmudev_support_ticket_text' => defender_support_ticket_text(),
593 590 'wpmudev_api_base_url' => $wpmu_dev->get_api_base_url(),
594 591 'upgrade_title' => esc_html__( 'UPGRADE TO PRO', 'defender-security' ),
595 - 'tracking_modal' => $is_tracking ? 'show' : 'hide',
596 592 'hosted' => $wpmu_dev->is_wpmu_hosting(),
597 593 'file_upload_nonce' => wp_create_nonce( 'defender_file_upload' ),
598 594 'wpmudev_hub_link' => 'https://wpmudev.com/hub2/',
599 595 )
@@ -706,9 +702,9 @@
706 702 'lang' => $locale,
707 703 ),
708 704 );
709 705
710 - if ( ! empty( $mo->headers['Plural-Forms'] ) ) {
706 + if ( isset( $mo->headers['Plural-Forms'] ) && '' !== $mo->headers['Plural-Forms'] ) {
711 707 $locale_data['']['plural-forms'] = $mo->headers['Plural-Forms'];
712 708 }
713 709
714 710 foreach ( $mo->entries as $msgid => $entry ) {
@@ -755,10 +751,8 @@
755 751 // Serve script translations from the single MO file our in-site translation tools produce.
756 752 add_filter( 'pre_load_script_translations', array( $this, 'provide_script_translations' ), 10, 4 );
757 753 // Register the Hub Connector early to handle the auth callback during the admin init hook.
758 754 add_action( 'plugins_loaded', array( wd_di()->get( Hub_Connector::class ), 'init' ) );
759 - // Register the Cross-Sell module.
760 - // add_action( 'init', array( wd_di()->get( \WP_Defender\Component\Cross_Sell::class ), 'init' ), 9 );
761 755 // Include admin class. Don't use is_admin().
762 756 add_action( 'admin_init', array( ( new Admin() ), 'init' ) );
763 757 // Initialize deactivation survey.
764 758 add_action( 'admin_enqueue_scripts', array( ( new Admin() ), 'init_deactivation_survey' ) );