From cea90415c68f0f9e25bc885617c1ec6ed3af1b79 Mon Sep 17 00:00:00 2001 From: Torben Lundsgaard Date: Fri, 30 Aug 2024 15:05:42 +0200 Subject: [PATCH] Add standardised conditionals --- inc/main.php | 9 +++++--- src/Common/Conditionals/Conditional.php | 21 +++++++++++++++++ .../Conditionals/ContactForm7Conditional.php | 23 +++++++++++++++++++ .../EasyDigitalDownloadsConditional.php | 23 +++++++++++++++++++ .../Conditionals/WoocommerceConditional.php | 23 +++++++++++++++++++ vendor/composer/autoload_classmap.php | 5 +++- vendor/composer/autoload_static.php | 5 +++- vendor/composer/installed.php | 4 ++-- 8 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 src/Common/Conditionals/Conditional.php create mode 100644 src/Common/Conditionals/ContactForm7Conditional.php create mode 100644 src/Common/Conditionals/EasyDigitalDownloadsConditional.php create mode 100644 src/Common/Conditionals/WoocommerceConditional.php diff --git a/inc/main.php b/inc/main.php index 6ff1287..47e49c9 100644 --- a/inc/main.php +++ b/inc/main.php @@ -17,6 +17,9 @@ use TLA_Media\GTM_Kit\Admin\NotificationsHandler; use TLA_Media\GTM_Kit\Admin\SetupWizard; use TLA_Media\GTM_Kit\Admin\TemplatesOptionsPage; +use TLA_Media\GTM_Kit\Common\Conditionals\ContactForm7Conditional; +use TLA_Media\GTM_Kit\Common\Conditionals\EasyDigitalDownloadsConditional; +use TLA_Media\GTM_Kit\Common\Conditionals\WoocommerceConditional; use TLA_Media\GTM_Kit\Common\RestAPIServer; use TLA_Media\GTM_Kit\Common\Util; use TLA_Media\GTM_Kit\Frontend\BasicDatalayerData; @@ -129,13 +132,13 @@ function gtmkit_frontend_init(): void { BasicDatalayerData::register( $options ); UserData::register( $options ); - if ( $options->get( 'integrations', 'woocommerce_integration' ) && function_exists( 'WC' ) ) { + if ( $options->get( 'integrations', 'woocommerce_integration' ) && ( new WoocommerceConditional() )->is_met() ) { WooCommerce::register( $options, $util ); } - if ( $options->get( 'integrations', 'cf7_integration' ) && class_exists( 'WPCF7' ) ) { + if ( $options->get( 'integrations', 'cf7_integration' ) && ( new ContactForm7Conditional() )->is_met() ) { ContactForm7::register( $options, $util ); } - if ( $options->get( 'integrations', 'edd_integration' ) && class_exists( 'EDD_Requirements_Check' ) ) { + if ( $options->get( 'integrations', 'edd_integration' ) && ( new EasyDigitalDownloadsConditional() )->is_met() ) { EasyDigitalDownloads::register( $options, $util ); } } diff --git a/src/Common/Conditionals/Conditional.php b/src/Common/Conditionals/Conditional.php new file mode 100644 index 0000000..3199630 --- /dev/null +++ b/src/Common/Conditionals/Conditional.php @@ -0,0 +1,21 @@ + $baseDir . '/src/Admin/AdminAPI.php', 'TLA_Media\\GTM_Kit\\Admin\\Analytics' => $baseDir . '/src/Admin/Analytics.php', 'TLA_Media\\GTM_Kit\\Admin\\AssetsTrait' => $baseDir . '/src/Admin/AssetsTrait.php', - 'TLA_Media\\GTM_Kit\\Admin\\Check' => $baseDir . '/src/Admin/Check.php', 'TLA_Media\\GTM_Kit\\Admin\\GeneralOptionsPage' => $baseDir . '/src/Admin/GeneralOptionsPage.php', 'TLA_Media\\GTM_Kit\\Admin\\HelpOptionsPage' => $baseDir . '/src/Admin/HelpOptionsPage.php', 'TLA_Media\\GTM_Kit\\Admin\\Integrations' => $baseDir . '/src/Admin/Integrations.php', @@ -21,6 +20,10 @@ 'TLA_Media\\GTM_Kit\\Admin\\NotificationsHandler' => $baseDir . '/src/Admin/NotificationsHandler.php', 'TLA_Media\\GTM_Kit\\Admin\\SetupWizard' => $baseDir . '/src/Admin/SetupWizard.php', 'TLA_Media\\GTM_Kit\\Admin\\TemplatesOptionsPage' => $baseDir . '/src/Admin/TemplatesOptionsPage.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\Conditional' => $baseDir . '/src/Common/Conditionals/Conditional.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\ContactForm7Conditional' => $baseDir . '/src/Common/Conditionals/ContactForm7Conditional.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\EasyDigitalDownloadsConditional' => $baseDir . '/src/Common/Conditionals/EasyDigitalDownloadsConditional.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\WoocommerceConditional' => $baseDir . '/src/Common/Conditionals/WoocommerceConditional.php', 'TLA_Media\\GTM_Kit\\Common\\RestAPIServer' => $baseDir . '/src/Common/RestAPIServer.php', 'TLA_Media\\GTM_Kit\\Common\\Util' => $baseDir . '/src/Common/Util.php', 'TLA_Media\\GTM_Kit\\Frontend\\BasicDatalayerData' => $baseDir . '/src/Frontend/BasicDatalayerData.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3e36c17..deefaad 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -26,7 +26,6 @@ class ComposerStaticInit12fa396dcd6fc263a33fd78c6d8551b8 'TLA_Media\\GTM_Kit\\Admin\\AdminAPI' => __DIR__ . '/../..' . '/src/Admin/AdminAPI.php', 'TLA_Media\\GTM_Kit\\Admin\\Analytics' => __DIR__ . '/../..' . '/src/Admin/Analytics.php', 'TLA_Media\\GTM_Kit\\Admin\\AssetsTrait' => __DIR__ . '/../..' . '/src/Admin/AssetsTrait.php', - 'TLA_Media\\GTM_Kit\\Admin\\Check' => __DIR__ . '/../..' . '/src/Admin/Check.php', 'TLA_Media\\GTM_Kit\\Admin\\GeneralOptionsPage' => __DIR__ . '/../..' . '/src/Admin/GeneralOptionsPage.php', 'TLA_Media\\GTM_Kit\\Admin\\HelpOptionsPage' => __DIR__ . '/../..' . '/src/Admin/HelpOptionsPage.php', 'TLA_Media\\GTM_Kit\\Admin\\Integrations' => __DIR__ . '/../..' . '/src/Admin/Integrations.php', @@ -36,6 +35,10 @@ class ComposerStaticInit12fa396dcd6fc263a33fd78c6d8551b8 'TLA_Media\\GTM_Kit\\Admin\\NotificationsHandler' => __DIR__ . '/../..' . '/src/Admin/NotificationsHandler.php', 'TLA_Media\\GTM_Kit\\Admin\\SetupWizard' => __DIR__ . '/../..' . '/src/Admin/SetupWizard.php', 'TLA_Media\\GTM_Kit\\Admin\\TemplatesOptionsPage' => __DIR__ . '/../..' . '/src/Admin/TemplatesOptionsPage.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\Conditional' => __DIR__ . '/../..' . '/src/Common/Conditionals/Conditional.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\ContactForm7Conditional' => __DIR__ . '/../..' . '/src/Common/Conditionals/ContactForm7Conditional.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\EasyDigitalDownloadsConditional' => __DIR__ . '/../..' . '/src/Common/Conditionals/EasyDigitalDownloadsConditional.php', + 'TLA_Media\\GTM_Kit\\Common\\Conditionals\\WoocommerceConditional' => __DIR__ . '/../..' . '/src/Common/Conditionals/WoocommerceConditional.php', 'TLA_Media\\GTM_Kit\\Common\\RestAPIServer' => __DIR__ . '/../..' . '/src/Common/RestAPIServer.php', 'TLA_Media\\GTM_Kit\\Common\\Util' => __DIR__ . '/../..' . '/src/Common/Util.php', 'TLA_Media\\GTM_Kit\\Frontend\\BasicDatalayerData' => __DIR__ . '/../..' . '/src/Frontend/BasicDatalayerData.php', diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index ce09017..c7d65b3 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'tlamedia/gtm-kit', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '9872766de93b13886fed8aeb86dd95b5affc21a1', + 'reference' => '73df48d7704e2d9ef8e7bb375cccfc5e1bdeea52', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'tlamedia/gtm-kit' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '9872766de93b13886fed8aeb86dd95b5affc21a1', + 'reference' => '73df48d7704e2d9ef8e7bb375cccfc5e1bdeea52', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),