From cd9156bbd13d7db00ee8b92be5990e3ad7e55707 Mon Sep 17 00:00:00 2001 From: Erik Golinelli Date: Sun, 15 Oct 2023 15:16:27 +0200 Subject: [PATCH] psr autoload --- admin/CF7_AntiSpam_Admin_Tools.php | 2 +- cf7-antispam.php | 19 +++------ composer.json | 1 + core/CF7_AntiSpam.php | 41 +------------------ core/CF7_AntiSpam_Filters.php | 1 - ...7_Service.php => CF7_Antispam_Service.php} | 4 +- {core => engine}/CF7_AntiSpam_Activator.php | 4 +- {core => engine}/CF7_AntiSpam_Deactivator.php | 2 +- {core => engine}/CF7_AntiSpam_Uninstaller.php | 4 +- 9 files changed, 18 insertions(+), 60 deletions(-) rename core/{WPCF7_Service.php => CF7_Antispam_Service.php} (98%) rename {core => engine}/CF7_AntiSpam_Activator.php (99%) rename {core => engine}/CF7_AntiSpam_Deactivator.php (95%) rename {core => engine}/CF7_AntiSpam_Uninstaller.php (98%) diff --git a/admin/CF7_AntiSpam_Admin_Tools.php b/admin/CF7_AntiSpam_Admin_Tools.php index 050b89f..09e102d 100644 --- a/admin/CF7_AntiSpam_Admin_Tools.php +++ b/admin/CF7_AntiSpam_Admin_Tools.php @@ -5,7 +5,7 @@ use CF7_AntiSpam\Core\CF7_AntiSpam; use CF7_AntiSpam\Core\CF7_AntiSpam_Filters; use CF7_AntiSpam\Core\CF7_AntiSpam_Flamingo; -use CF7_AntiSpam\Core\CF7_AntiSpam_Uninstaller; +use CF7_AntiSpam\Engine\CF7_AntiSpam_Uninstaller; /** * The plugin admin tools diff --git a/cf7-antispam.php b/cf7-antispam.php index e31c56c..cf6b63e 100644 --- a/cf7-antispam.php +++ b/cf7-antispam.php @@ -11,12 +11,6 @@ */ /* If this file is called directly, abort. */ - -use CF7_AntiSpam\Core\CF7_AntiSpam; -use CF7_AntiSpam\Core\CF7_AntiSpam_Activator; -use CF7_AntiSpam\Core\CF7_AntiSpam_Deactivator; -use CF7_AntiSpam\Core\CF7_AntiSpam_Uninstaller; - if ( ! defined( 'WPINC' ) ) { die; } @@ -74,7 +68,7 @@ * The code that runs during plugin activation. */ function activate_cf7_antispam( $network_wide ) { - CF7_AntiSpam_Activator::on_activate( $network_wide ); + \CF7_AntiSpam\Engine\CF7_AntiSpam_Activator::on_activate( $network_wide ); } register_activation_hook( CF7ANTISPAM_PLUGIN, 'activate_cf7_antispam' ); @@ -88,7 +82,7 @@ function activate_cf7_antispam( $network_wide ) { function on_create_blog( $blog_id ) { if ( is_plugin_active_for_network( 'cf7-antispam/cf7-antispam.php' ) ) { switch_to_blog( $blog_id ); - CF7_AntiSpam_Activator::activate(); + \CF7_AntiSpam\Engine\CF7_AntiSpam_Activator::activate(); restore_current_blog(); } } @@ -113,7 +107,7 @@ function on_delete_blog( $tables ) { * The code that runs during plugin deactivation. */ function deactivate_cf7_antispam() { - CF7_AntiSpam_Deactivator::deactivate(); + \CF7_AntiSpam\Engine\CF7_AntiSpam_Deactivator::deactivate(); } register_deactivation_hook( CF7ANTISPAM_PLUGIN, 'deactivate_cf7_antispam' ); @@ -121,7 +115,7 @@ function deactivate_cf7_antispam() { * The code that runs during plugin un-installation. */ function uninstall_cf7_antispam() { - CF7_AntiSpam_Uninstaller::uninstall(); + \CF7_AntiSpam\Engine\CF7_AntiSpam_Uninstaller::uninstall(); } register_uninstall_hook( CF7ANTISPAM_PLUGIN, 'uninstall_cf7_antispam' ); @@ -132,11 +126,10 @@ function uninstall_cf7_antispam() { */ function cf7_antispam_register_service() { - require_once CF7ANTISPAM_PLUGIN_DIR . '/core/WPCF7_Service.php'; $integration = WPCF7_Integration::get_instance(); $integration->add_service( 'cf7-antispam', - \CF7_AntiSpam\Core\WPCF7_Antispam::get_instance() + \CF7_AntiSpam\Core\CF7_Antispam_Service::get_instance() ); } @@ -146,7 +139,7 @@ function cf7_antispam_register_service() { function run_cf7a() { $enabled = get_option( 'cf7a_options' ); if ( $enabled && ! empty( $enabled['cf7a_enable'] ) ) { - $cf7a = new CF7_AntiSpam(); + $cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam(); $cf7a->run(); } } diff --git a/composer.json b/composer.json index 26c93d8..023104a 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,7 @@ "autoload": { "psr-4": { "CF7_AntiSpam\\Core\\": "core/", + "CF7_AntiSpam\\Engine\\": "engine/", "CF7_AntiSpam\\Admin\\": "admin/" } }, diff --git a/core/CF7_AntiSpam.php b/core/CF7_AntiSpam.php index ac590ed..c152dc4 100644 --- a/core/CF7_AntiSpam.php +++ b/core/CF7_AntiSpam.php @@ -19,11 +19,8 @@ use CF7_AntiSpam\Admin\CF7_AntiSpam_Admin_Core; use CF7_AntiSpam\Admin\CF7_AntiSpam_Admin_Tools; +use CF7_AntiSpam\Engine\CF7_AntiSpam_Activator; -use CF7_AntiSpam\Core\CF7_AntiSpam_i18n; -use CF7_AntiSpam\Core\CF7_AntiSpam_Loader; -use CF7_AntiSpam\Core\CF7_AntiSpam_Flamingo; -use CF7_AntiSpam\Core\CF7_AntiSpam_Frontend; /** * It sets the version, plugin name, and options. It loads * the dependencies, sets the locale, updates the plugin, and loads the admin and frontend areas @@ -136,42 +133,6 @@ protected function update() { * It loads the plugin's dependencies */ private function load_dependencies() { - - // ** - // * The class responsible for orchestrating the actions and filters of the - // * core plugin. - // */ - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-loader.php'; - // - // ** - // * The class responsible for defining internationalization functionality - // * of the plugin. - // */ - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-i18n.php'; - // - // ** - // * The class responsible for defining frontend functionality - // * of the plugin. - // */ - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-frontend.php'; - // - // ** - // * The classes responsible for defining antispam functionality and the related filters - // * of the plugin. - // */ - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-antispam-filters.php'; - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-antispam-geoip.php'; - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-antispam-flamingo.php'; - // require_once CF7ANTISPAM_PLUGIN_DIR . '/includes/cf7a-antispam-b8.php'; - // - // ** - // * The classes responsible for defining admin backend functionality - // */ - // require_once CF7ANTISPAM_PLUGIN_DIR . '/admin/admin-customizations.php'; - // require_once CF7ANTISPAM_PLUGIN_DIR . '/admin/admin-display.php'; - // require_once CF7ANTISPAM_PLUGIN_DIR . '/admin/admin-tools.php'; - // require_once CF7ANTISPAM_PLUGIN_DIR . '/admin/admin.php'; - $this->loader = new CF7_AntiSpam_Loader(); } diff --git a/core/CF7_AntiSpam_Filters.php b/core/CF7_AntiSpam_Filters.php index df29f60..33bcc0b 100644 --- a/core/CF7_AntiSpam_Filters.php +++ b/core/CF7_AntiSpam_Filters.php @@ -13,7 +13,6 @@ use Exception; use WPCF7_Submission; -use CF7_AntiSpam\Core\CF7_Antispam_Geoip; /** * A class that is used to filter out spam. diff --git a/core/WPCF7_Service.php b/core/CF7_Antispam_Service.php similarity index 98% rename from core/WPCF7_Service.php rename to core/CF7_Antispam_Service.php index c6e1326..6504341 100644 --- a/core/WPCF7_Service.php +++ b/core/CF7_Antispam_Service.php @@ -28,7 +28,7 @@ functionality. */ * This Extension represents the skeleton of the integration API */ -class WPCF7_Antispam extends GlobalWPCF7_Service { +class CF7_Antispam_Service extends GlobalWPCF7_Service { private static $instance; @@ -114,6 +114,7 @@ public function icon() { 'overflow' => true, ), 'path' => array( + 'stroke-width' => true, 'fill' => true, 'd' => true, ), @@ -123,6 +124,7 @@ public function icon() { 'rx' => true, 'ry' => true, 'fill' => true, + 'stroke-width' => true, ), 'g' => array( 'stroke' => true, diff --git a/core/CF7_AntiSpam_Activator.php b/engine/CF7_AntiSpam_Activator.php similarity index 99% rename from core/CF7_AntiSpam_Activator.php rename to engine/CF7_AntiSpam_Activator.php index 2a7b134..eea9129 100644 --- a/core/CF7_AntiSpam_Activator.php +++ b/engine/CF7_AntiSpam_Activator.php @@ -1,6 +1,6 @@ */ + use CF7_AntiSpam\Admin\CF7_AntiSpam_Admin_Tools; + /** * It's a class that activates the plugin. */ diff --git a/core/CF7_AntiSpam_Deactivator.php b/engine/CF7_AntiSpam_Deactivator.php similarity index 95% rename from core/CF7_AntiSpam_Deactivator.php rename to engine/CF7_AntiSpam_Deactivator.php index fbcb784..cb91cb8 100644 --- a/core/CF7_AntiSpam_Deactivator.php +++ b/engine/CF7_AntiSpam_Deactivator.php @@ -1,6 +1,6 @@