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; + } + ?> +
+

+ +

+
+ is_plugin_install_page() ) { + return; + } + + // add script to add query param to plugin upload form submit URL + ?> + + admin_url( 'admin-ajax.php' ), 'is_active_nonce' => wp_create_nonce( self::AJAX_IS_ACTIVE_NONCE_NAME ), 'activate_nonce' => wp_create_nonce( self::AJAX_ACTIVATE_NONCE_NAME ), + 'is_welcome_page' => isset( $_REQUEST['page'] ) + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + && Menu::SLUG_MARKETPLACE === wp_unslash( $_REQUEST['page'] ) + && isset( $_REQUEST['tab'] ) + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + && 'marketplace' === wp_unslash( $_REQUEST['tab'] ), ] ); } @@ -86,7 +156,12 @@ public static function is_marketplace_active() { wp_send_json_error( [ 'message' => 'forbidden' ], 403 ); } - wp_send_json( [ 'active' => is_plugin_active( self::MARKETPLACE_PLUGIN_FILE ) ] ); + wp_send_json( + [ + 'installed' => self::is_marketplace_installed(), + 'active' => is_plugin_active( self::MARKETPLACE_PLUGIN_FILE ), + ] + ); } public static function activate_marketplace_plugin() { @@ -104,4 +179,50 @@ public static function is_marketplace_installed() { return is_file( WP_PLUGIN_DIR . '/' . self::MARKETPLACE_PLUGIN_FILE ) || is_file( WP_CONTENT_DIR . '/mu-plugins/' . self::MARKETPLACE_PLUGIN_FILE ); } + + private function is_plugin_install_page() { + if ( empty( $_SERVER['REQUEST_URI'] ) ) { + return false; + } + + $request_path = wp_parse_url( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), PHP_URL_PATH ); + if ( ! preg_match( '%/wp-admin/plugin-install\\.php$%', $request_path ) ) { + return false; + } + + if ( + empty( $_REQUEST['tab'] ) + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + || 'upload' !== wp_unslash( $_REQUEST['tab'] ) + || empty( $_REQUEST['mtm_marketplace_install'] ) + ) { + return false; + } + + return true; + } + + private function is_plugin_activation_request() { + if ( empty( $_SERVER['REQUEST_URI'] ) ) { + return false; + } + + $request_path = wp_parse_url( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), PHP_URL_PATH ); + if ( ! preg_match( '%/wp-admin/plugins\\.php$%', $request_path ) ) { + return false; + } + + if ( + empty( $_REQUEST['action'] ) + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + || 'activate' !== wp_unslash( $_REQUEST['action'] ) + || empty( $_REQUEST['plugin'] ) + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + || 'matomo-marketplace-for-wordpress/matomo-marketplace-for-wordpress.php' !== wp_unslash( $_REQUEST['plugin'] ) + ) { + return false; + } + + return true; + } } diff --git a/classes/WpMatomo/Admin/MarketplaceSetupWizardBody.php b/classes/WpMatomo/Admin/MarketplaceSetupWizardBody.php index 5c68b18d8..cc6d2a46f 100644 --- a/classes/WpMatomo/Admin/MarketplaceSetupWizardBody.php +++ b/classes/WpMatomo/Admin/MarketplaceSetupWizardBody.php @@ -26,12 +26,12 @@ public function show() { $is_plugin_installed = MarketplaceSetupWizard::is_marketplace_installed(); $matomo_show_title = $this->matomo_show_title; $matomo_is_plugin_active = is_plugin_active( MarketplaceSetupWizard::MARKETPLACE_PLUGIN_FILE ); - $matomo_marketplace_url = $this->get_marketplace_zip_url(); + $matomo_marketplace_url = self::get_marketplace_zip_url(); include dirname( __FILE__ ) . '/views/marketplace_setup_wizard_body.php'; } - private function get_marketplace_zip_url() { + public static function get_marketplace_zip_url() { if ( defined( 'MATOMO_MARKETPLACE_ZIP_URL' ) && MATOMO_MARKETPLACE_ZIP_URL ) { return MATOMO_MARKETPLACE_ZIP_URL; } diff --git a/classes/WpMatomo/Admin/views/marketplace.php b/classes/WpMatomo/Admin/views/marketplace.php index 4d273d9e8..cb055d195 100644 --- a/classes/WpMatomo/Admin/views/marketplace.php +++ b/classes/WpMatomo/Admin/views/marketplace.php @@ -21,374 +21,400 @@ ); /** @var string $matomo_currency */ +/** @var string $matomo_marketplace_url */ ?> -
- -
- - + + + - show(); - return; +is_network_enabled() && ! is_network_admin() && is_super_admin() ) { ?> +
+

+
+ + +show(); + return; +} +?> + + + +
+

+ +

+ +

+

+ +

+

+ +

+ +
+
+
+ Matomo Logo +

+ +

+
+

+ +

+

+ +

+

+ +

+ +
+

+ ', + '' + ); + ?> +

+
+
+ + + + +
+
+
+
+
+ 1 + +
+

+ +

+
+ + + +
+
+
+
+ 2 + +
+

+ +

+
+ + + +
+
+
+ +

+

+ + [ + 'name' => __( 'Marketing Campaigns Reporting', 'matomo' ), + 'desc' => __( "Measure the effectiveness of your marketing campaigns. Track up to five channels instead of two: campaign, source, medium, keyword, content.', 'matomo'", 'matomo' ), + 'img' => 'marketing-campaign-analytics.png', ], - [ - 'title' => 'Top free plugins', - 'more_url' => 'https://plugins.matomo.org/free?wp=1&pk_campaign=WP&pk_source=Plugin', - 'more_text' => 'Browse all free plugins', - 'features' => - [ - [ - 'name' => 'Marketing Campaigns Reporting', - 'description' => 'Measure the effectiveness of your marketing campaigns. Track up to five channels instead of two: campaign, source, medium, keyword, content.', - 'price' => 'free', - 'download_url' => 'https://plugins.matomo.org/api/2.0/plugins/MarketingCampaignsReporting/download/latest?wp=1' . $matomo_extra_url_params, - 'url' => 'https://plugins.matomo.org/MarketingCampaignsReporting?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Custom Alerts', - 'description' => 'Create custom Alerts to be notified of important changes on your website or app!', - 'price' => 'free', - 'download_url' => 'https://plugins.matomo.org/api/2.0/plugins/CustomAlerts/download/latest?wp=1' . $matomo_extra_url_params, - 'url' => 'https://plugins.matomo.org/CustomAlerts?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - ], + 'SearchEngineKeywordsPerformance' => [ + 'name' => __( 'Search Engine Keywords Performance', 'matomo' ), + 'desc' => __( 'All keywords searched by your users on search engines are now visible into your Referrers reports! The ultimate solution to \'Keyword not defined\'.', 'matomo' ), + 'price' => '79EUR / 89USD', + 'img' => 'search-engine-keywords-performance.webp', ], - ]; - - /** @var \WpMatomo\Settings $settings */ - $matomo_version = $settings->get_matomo_major_version(); - - matomo_show_tables( $matomo_feature_sections, $matomo_version, $matomo_currency ); - - echo '
'; - - $matomo_feature_sections = [ - [ - 'title' => 'Most popular premium features', - 'features' => - [ - [ - 'name' => 'Heatmap & Session Recording', - 'description' => 'Truly understand your visitors by seeing where they click, hover, type and scroll. Replay their actions in a video and ultimately increase conversions.', - 'price' => '109EUR / 129USD', - 'url' => 'https://plugins.matomo.org/HeatmapSessionRecording?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Custom Reports', - 'description' => 'Pull out the information you need in order to be successful. Develop your custom strategy to meet your individualized goals while saving money & time.', - 'price' => '109EUR / 129USD', - 'url' => 'https://plugins.matomo.org/CustomReports?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - - [ - 'name' => 'Premium Bundle', - 'description' => 'All premium features in one bundle, make the most out of your Matomo for WordPress and enjoy discounts of over 25%!', - 'price' => '549EUR / 639USD', - 'url' => 'https://plugins.matomo.org/WpPremiumBundle?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - ], + 'HeatmapSessionRecording' => [ + 'name' => __( 'Heatmap & Session Recording', 'matomo' ), + 'desc' => __( 'Truly understand your visitors by seeing where they click, hover, type and scroll. Replay their actions in a video and ultimately increase conversions.', 'matomo' ), + 'price' => '109EUR / 129USD', + 'img' => 'heatmap-session-recording.webp', + ], + 'CustomAlerts' => [ + 'name' => __( 'Custom Alerts', 'matomo' ), + 'desc' => __( 'Create custom Alerts to be notified of important changes on your website or app!', 'matomo' ), + 'img' => 'custom-alerts.png', ], - [ - 'title' => 'Most popular content engagement', - 'features' => - [ - [ - 'name' => 'Form Analytics', - 'description' => 'Increase conversions on your online forms and lose less visitors by learning everything about your users behavior and their pain points on your forms.', - 'price' => '89EUR / 99USD', - 'url' => 'https://plugins.matomo.org/FormAnalytics?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Video & Audio Analytics', - 'description' => 'Grow your business with advanced video & audio analytics. Get powerful insights into how your audience watches your videos and listens to your audio.', - 'price' => '89EUR / 99USD', - 'url' => 'https://plugins.matomo.org/MediaAnalytics?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Users Flow', - 'description' => 'Users Flow is a visual representation of the most popular paths your users take through your website & app which lets you understand your users needs.', - 'price' => '49EUR / 59USD', - 'url' => 'https://plugins.matomo.org/UsersFlow?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - ], + 'MediaAnalytics' => [ + 'name' => __( 'Media Analytics', 'matomo' ), + 'desc' => __( 'Grow your business with advanced video & audio analytics. Get powerful insights into how your audience watches your videos and listens to your audio.', 'matomo' ), + 'price' => '89EUR / 99USD', + 'img' => 'media-analytics.jpg', ], - [ - 'title' => 'Most popular acquisition & SEO features', - 'features' => - [ - [ - 'name' => 'Search Engine Keywords Performance', - 'description' => 'All keywords searched by your users on search engines are now visible into your Referrers reports! The ultimate solution to \'Keyword not defined\'.', - 'price' => '79EUR / 89USD', - 'url' => 'https://plugins.matomo.org/SearchEngineKeywordsPerformance?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'SEO Web Vitals', - 'description' => 'Improve your website performance, rank higher in search results and optimise your visitor experience with SEO Web Vitals.', - 'price' => '49EUR / 59USD', - 'url' => 'https://plugins.matomo.org/SEOWebVitals?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - ], + 'CustomReports' => [ + 'name' => __( 'Custom Reports', 'matomo' ), + 'desc' => __( 'Pull out the information you need in order to be successful. Develop your custom strategy to meet your individualized goals while saving money & time.', 'matomo' ), + 'price' => '109EUR / 129USD', + 'img' => 'custom-reports.png', ], - [ - 'title' => '', - 'features' => - [ - [ - 'name' => 'Advertising Conversion Export', - 'description' => 'Provides an export of attributed goal conversions for usage in ad networks like Google Ads so you no longer need a conversion pixel.', - 'price' => '89EUR / 99USD', - 'url' => 'https://plugins.matomo.org/AdvertisingConversionExport?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Multi Attribution', - 'description' => 'Get a clear understanding of how much credit each of your marketing channel is actually responsible for to shift your marketing efforts wisely.', - 'price' => '49EUR / 59USD', - 'url' => 'https://plugins.matomo.org/MultiChannelConversionAttribution?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - ], + 'WpPremiumBundle' => [ + 'name' => __( 'WordPress Premium Bundle', 'matomo' ), + 'desc' => __( 'All premium features in one bundle, make the most out of your Matomo for WordPress and enjoy discounts of up to 25%!', 'matomo' ), + 'price' => '549EUR / 639USD', + 'img' => 'matomo-wordpress-premium-bundle.png', ], - [ - 'title' => 'Other premium features', - 'features' => - [ - [ - 'name' => 'Funnels', - 'description' => 'Identify and understand where your visitors drop off to increase your conversions, sales and revenue with your existing traffic.', - 'price' => '99EUR / 119USD', - 'url' => 'https://plugins.matomo.org/Funnels?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Cohorts', - 'description' => 'Track your retention efforts over time and keep your visitors engaged and coming back for more.', - 'price' => '49EUR / 59USD', - 'url' => 'https://plugins.matomo.org/Cohorts?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - [ - 'name' => 'Crash Analytics', - 'description' => 'Detect crashes to improve the user experience, increase conversions and recover revenue. Resolve them with insights to minimise developer hours.', - 'price' => '79EUR / 89USD', - 'url' => 'https://plugins.matomo.org/CrashAnalytics?wp=1&pk_campaign=WP&pk_source=Plugin', - 'image' => '', - ], - ], + 'UsersFlow' => [ + 'name' => __( 'Users Flow', 'matomo' ), + 'desc' => __( 'Users Flow is a visual representation of the most popular paths your users take through your website & app which lets you understand your users needs.', 'matomo' ), + 'price' => '49EUR / 59USD', + 'img' => 'users-flow.webp', ], ]; + ?> - matomo_show_tables( $matomo_feature_sections, $matomo_version, $matomo_currency ); + $matomo_feature_info ) { ?> + +
diff --git a/classes/WpMatomo/Admin/views/marketplace_setup_wizard_body.php b/classes/WpMatomo/Admin/views/marketplace_setup_wizard_body.php index dfe827b1c..22d1d1c67 100644 --- a/classes/WpMatomo/Admin/views/marketplace_setup_wizard_body.php +++ b/classes/WpMatomo/Admin/views/marketplace_setup_wizard_body.php @@ -46,7 +46,7 @@

- +
diff --git a/marketplace b/marketplace index 5789985a5..d058e2330 160000 --- a/marketplace +++ b/marketplace @@ -1 +1 @@ -Subproject commit 5789985a5f07af092e46f78fc9f17936c26fe7b9 +Subproject commit d058e2330f06fff6154cd3adc0f193dfabb00f92