From 5bae44b39d300a5ff8d4054ab686466560d2b890 Mon Sep 17 00:00:00 2001 From: Erik Golinelli Date: Fri, 26 Jan 2024 16:31:38 +0100 Subject: [PATCH] startup optimization close #104 --- cf7-antispam.php | 15 +++++---------- core/CF7_Antispam_Service.php | 2 ++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cf7-antispam.php b/cf7-antispam.php index da17cb4..739f671 100644 --- a/cf7-antispam.php +++ b/cf7-antispam.php @@ -133,16 +133,11 @@ function cf7_antispam_register_service() { } add_action( 'wpcf7_init', 'cf7_antispam_register_service', 1, 0 ); - +/** + * Executes CF7-AntiSpam + */ function run_cf7a() { - $options = get_option( 'cf7a_options' ); - - if ( ! empty( $options['cf7a_enable'] ) ) { - $cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam(); - $cf7a->run(); - } else { - /* Must call style enqueue to apply styles in integration page even if the plugin is deactivated */ - wp_enqueue_style( CF7ANTISPAM_NAME, CF7ANTISPAM_PLUGIN_URL . '/build/admin-scripts.css', array(), CF7ANTISPAM_VERSION ); - } + $cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam(); + $cf7a->run(); } add_action( 'init', 'run_cf7a', 11, 0 ); diff --git a/core/CF7_Antispam_Service.php b/core/CF7_Antispam_Service.php index c437ff2..1acf4f8 100644 --- a/core/CF7_Antispam_Service.php +++ b/core/CF7_Antispam_Service.php @@ -132,6 +132,8 @@ public function icon() { ), ); echo '
' . wp_kses( file_get_contents( CF7ANTISPAM_PLUGIN_DIR . '/assets/icon.svg' ), $allowed_html ) . '
'; + // inline css isn't the best idea generally speaking, but in this case will avoid to enqueue the css before to know if the plugin is enabled + echo ''; } /**