From 96375e5c6abcae9c59a8645febcb3521dfc124bd Mon Sep 17 00:00:00 2001 From: Torben Lundsgaard Date: Sun, 10 Mar 2024 12:35:43 +0100 Subject: [PATCH] Set default options on first install --- src/Installation/Upgrade.php | 14 ++++++++++++++ src/Options.php | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/Installation/Upgrade.php b/src/Installation/Upgrade.php index c68546c..c7cb16c 100644 --- a/src/Installation/Upgrade.php +++ b/src/Installation/Upgrade.php @@ -123,4 +123,18 @@ protected function v115_upgrade(): void { Options::init()->set( $values, false, false ); } + + /** + * Upgrade routine for v1.20 + */ + protected function v120_upgrade(): void { + + $values = [ + 'premium' => [ + 'addon_installed' => 0, + ], + ]; + + Options::init()->set( $values, false, false ); + } } diff --git a/src/Options.php b/src/Options.php index c934123..8cee53e 100644 --- a/src/Options.php +++ b/src/Options.php @@ -58,6 +58,10 @@ final class Options { 'default' => '', 'constant' => 'GTMKIT_PREVIEW', ], + 'datalayer_page_type' => [ + 'default' => true, + 'type' => 'boolean', + ], ], 'integrations' => [ 'woocommerce_shipping_info' => [ 'default' => 1 ], @@ -76,6 +80,9 @@ final class Options { 'type' => 'boolean', ], ], + 'premium' => [ + 'addon_installed' => 0, + ], ]; /** @@ -128,6 +135,22 @@ public static function get_defaults(): array { $map = self::$map; + if ( \is_plugin_active( 'woocommerce/woocommerce.php' ) ) { + $map['integrations']['woocommerce_integration'] = [ + 'default' => true, + ]; + } + if ( \is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) { + $map['integrations']['cf7_integration'] = [ + 'default' => true, + ]; + } + if ( ( \is_plugin_active( 'easy-digital-downloads/easy-digital-downloads.php' ) || \is_plugin_active( 'easy-digital-downloads-pro/easy-digital-downloads.php' ) ) ) { + $map['integrations']['edd_integration'] = [ + 'default' => true, + ]; + } + return $map; }