diff --git a/assets/css/admin-style.css b/assets/css/admin-style.css index 6f6c8203d..8ad84590a 100644 --- a/assets/css/admin-style.css +++ b/assets/css/admin-style.css @@ -317,6 +317,10 @@ table.matomo-tracking-form th { color: #2271b1; } +.matomo-primary-color-fill { + fill: #2271b1; +} + .matomo-secondary-color-fg { color: #f6f7f7; } @@ -333,6 +337,10 @@ table.matomo-tracking-form th { color: var(--wp-admin-theme-color, #3858e9); } +.mtm-wp-gte-7 .matomo-primary-color-fill { + fill: var(--wp-admin-theme-color, #3858e9); +} + .mtm-wp-gte-7 .matomo-secondary-color-fg { color: white; } diff --git a/assets/img/suggestions/custom-alerts.png b/assets/img/suggestions/custom-alerts.png new file mode 100644 index 000000000..5494cfdb0 --- /dev/null +++ b/assets/img/suggestions/custom-alerts.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f2b0e8ea732c64e30b917071418c0b0af1a917cafcf51a6d1d96cf27cdd31e2 +size 36712 diff --git a/assets/img/suggestions/custom-reports.png b/assets/img/suggestions/custom-reports.png new file mode 100644 index 000000000..1870c435b --- /dev/null +++ b/assets/img/suggestions/custom-reports.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:530986846f7e54ca191cc3e0f99f60d967beee8da4e521cbc3834201dab382dc +size 55306 diff --git a/assets/img/suggestions/marketing-campaign-analytics.png b/assets/img/suggestions/marketing-campaign-analytics.png new file mode 100644 index 000000000..027ddc259 --- /dev/null +++ b/assets/img/suggestions/marketing-campaign-analytics.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bb627da00a2c53610bf3ecd862fe8d673f7d97e418c10db4eed28f456c13325 +size 77508 diff --git a/assets/img/suggestions/media-analytics.jpg b/assets/img/suggestions/media-analytics.jpg new file mode 100644 index 000000000..3d21b7e9e Binary files /dev/null and b/assets/img/suggestions/media-analytics.jpg differ diff --git a/assets/js/marketplace_setup_wizard.js b/assets/js/marketplace_setup_wizard.js index 5a4d6d075..0eed5cf62 100644 --- a/assets/js/marketplace_setup_wizard.js +++ b/assets/js/marketplace_setup_wizard.js @@ -7,8 +7,12 @@ */ window.jQuery(document).ready(function ($) { - function pollForPluginActivation() { - $('.wizard-waiting-for').show(); + function pollForPluginActivation(setActiveClass) { + if (setActiveClass) { + $('.wizard-waiting-for').addClass('active').find('.waiting-for-install').show(); + } else { + $('.wizard-waiting-for').show(); + } var interval = setInterval(function () { $.post(mtmMarketplaceWizardAjax.ajax_url, { @@ -16,11 +20,23 @@ window.jQuery(document).ready(function ($) { action: 'matomo_is_marketplace_active', }, function (data) { if (data.active) { - $('.wizard-waiting-for').hide(); + if (!setActiveClass) { + $('.wizard-waiting-for').hide(); + } else { + $('.wizard-waiting-for .waiting-for-activation').hide(); + } + $('.wizard-reloading').show(); - window.location.reload(); + // reload after the dom has had a chance to update + setTimeout(function () { + window.location.reload(); + }); + clearInterval(interval); + } else if (data.installed && setActiveClass) { + $('.wizard-waiting-for .waiting-for-install').hide(); + $('.wizard-waiting-for .waiting-for-activation').show(); } }); }, 2000); @@ -39,7 +55,14 @@ window.jQuery(document).ready(function ($) { } if (typeof mtmMarketplaceWizardAjax !== 'undefined' && mtmMarketplaceWizardAjax.ajax_url) { - $('.matomo-marketplace-wizard-body .open-plugin-upload').on('click', pollForPluginActivation); - $('.matomo-marketplace-wizard-body .activate-plugin').on('click', activateMarketplace); + var pollFn = pollForPluginActivation; + var activateFn = activateMarketplace; + if (mtmMarketplaceWizardAjax.is_welcome_page) { + pollFn = pollForPluginActivation.bind(null, true); + activateFn = activateMarketplace.bind(null, true); + } + + $('.matomo-marketplace-wizard-body .open-plugin-upload').on('click', pollFn); + $('.matomo-marketplace-wizard-body .activate-plugin').on('click', activateFn); } }); diff --git a/classes/WpMatomo/Admin/Marketplace.php b/classes/WpMatomo/Admin/Marketplace.php index 01d42297d..53b33d53a 100644 --- a/classes/WpMatomo/Admin/Marketplace.php +++ b/classes/WpMatomo/Admin/Marketplace.php @@ -53,6 +53,9 @@ public function show() { $valid_tabs = $this->get_valid_tabs(); $marketplace_setup_wizard = \WpMatomo::get_active_feature( MarketplaceSetupWizard::class ); + $matomo_marketplace_url = MarketplaceSetupWizardBody::get_marketplace_zip_url(); + } else { + wp_safe_redirect( admin_url( 'admin.php?page=matomo-marketplace&tab=install' ) ); } $matomo_currency = $this->get_currency_based_on_timezone(); @@ -61,7 +64,14 @@ public function show() { } private function get_valid_tabs() { - $valid_tabs = [ 'marketplace' ]; + $valid_tabs = []; + if ( + ! MarketplaceSetupWizard::is_marketplace_installed() + || ! is_plugin_active( MarketplaceSetupWizard::MARKETPLACE_PLUGIN_FILE ) + ) { + $valid_tabs[] = 'marketplace'; + } + if ( $this->can_user_manage() ) { if ( current_user_can( 'install_plugins' ) ) { $valid_tabs[] = 'install'; diff --git a/classes/WpMatomo/Admin/MarketplaceSetupWizard.php b/classes/WpMatomo/Admin/MarketplaceSetupWizard.php index 283b0edb0..cb0e5fc59 100644 --- a/classes/WpMatomo/Admin/MarketplaceSetupWizard.php +++ b/classes/WpMatomo/Admin/MarketplaceSetupWizard.php @@ -22,6 +22,13 @@ public function is_active() { return false; } + if ( + $this->is_plugin_install_page() + || $this->is_plugin_activation_request() + ) { + return true; + } + if ( empty( $_REQUEST['page'] ) ) { return false; } @@ -34,9 +41,7 @@ public function is_active() { return false; } - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - $tab = isset( $_REQUEST['tab'] ) ? wp_unslash( $_REQUEST['tab'] ) : ''; - return 'install' === $tab || 'subscriptions' === $tab; + return true; // displayed in some manner on all tabs } public function get_body( $show_titles = true ) { @@ -52,6 +57,65 @@ public function show() { public function register_hooks() { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); + add_action( 'admin_notices', [ $this, 'admin_notices' ] ); + add_action( 'activated_plugin', [ $this, 'on_plugin_activated' ] ); + add_action( 'admin_footer', [ $this, 'on_admin_footer' ] ); + } + + public function on_plugin_activated( $plugin ) { + if ( 'matomo-marketplace-for-wordpress/matomo-marketplace-for-wordpress.php' !== $plugin ) { + return; + } + + if ( + empty( $_SERVER['HTTP_REFERER'] ) + || false === strpos( esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ), 'mtm_marketplace_install' ) + ) { + return; + } + + // if we are in the marketplace install workflow, and the plugin has been + // activated, close the current window to go back to the marketplace setup + ?> + +
+ + + + + is_plugin_install_page() ) { + return; + } + ?> ++ +
++ +
++ +
++ +
+ +
+ + +
++ +
++ +
+ + ++ ', + '' + ); + ?> +
+