PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / classes / WpMatomo / Admin / GetStarted.php
matomo / classes / WpMatomo / Admin Last commit date
PluginSuggestions 2 months ago TrackingSettings 2 months ago views 2 months ago AccessSettings.php 4 years ago AdBlockDetector.php 7 months ago Admin.php 2 months ago AdminSettings.php 2 months ago AdminSettingsInterface.php 6 years ago AdvancedSettings.php 10 months ago Chart.php 2 months ago CookieConsent.php 4 years ago Dashboard.php 2 months ago ExclusionSettings.php 7 months ago GeolocationSettings.php 2 years ago GetStarted.php 2 months ago ImportWpStatistics.php 2 months ago Info.php 2 months ago InvalidIpException.php 4 years ago Marketplace.php 2 months ago MarketplaceSetupWizard.php 2 months ago MarketplaceSetupWizardBody.php 3 months ago MatomoPage.php 2 months ago MatomoPageContent.php 2 months ago Menu.php 2 months ago PluginMeasurableSettings.php 2 years ago PrivacySettings.php 1 year ago SafeModeMenu.php 2 months ago Summary.php 2 months ago SystemReport.php 2 months ago TrackingSettings.php 4 months ago WhatsNewNotifications.php 2 months ago
GetStarted.php
127 lines
1 <?php
2 /**
3 * Matomo - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 * @package matomo
8 */
9
10 namespace WpMatomo\Admin;
11
12 use WpMatomo\Settings;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // if accessed directly
16 }
17
18 class GetStarted implements MatomoPageContent {
19 const NONCE_NAME = 'matomo_enable_tracking';
20 const FORM_NAME = 'matomo';
21
22 /**
23 * @var Settings
24 */
25 private $settings;
26
27 /**
28 * @param Settings $settings
29 */
30 public function __construct( $settings ) {
31 $this->settings = $settings;
32 }
33
34 public static function register_hooks() {
35 add_action( 'matomo_before_add_menu', [ self::class, 'on_marketplace_plugin_activated' ] );
36 }
37
38 public static function on_marketplace_plugin_activated() {
39 $settings = new Settings();
40
41 $is_hidden = self::auto_hide_page_if_steps_completed( $settings );
42 if (
43 $is_hidden
44 && isset( $_REQUEST['page'] )
45 && Menu::SLUG_GET_STARTED === $_REQUEST['page']
46 ) {
47 wp_safe_redirect( admin_url( 'admin.php?page=' . Menu::SLUG_REPORT_SUMMARY ) );
48 exit;
49 }
50 }
51
52 public static function auto_hide_page_if_steps_completed( Settings $settings ) {
53 if ( self::should_auto_hide_get_started_page( $settings ) ) {
54 $settings->apply_changes(
55 [
56 Settings::SHOW_GET_STARTED_PAGE => 0,
57 ]
58 );
59
60 return true;
61 }
62
63 return false;
64 }
65 public function show() {
66 $was_updated = $this->update_if_submitted();
67 $settings = $this->settings;
68 $can_user_edit = $this->can_user_manage();
69 $show_this_page = $this->settings->get_global_option( Settings::SHOW_GET_STARTED_PAGE );
70 $matomo_is_marketplace_active = $this->is_marketplace_installed_and_active();
71
72 $matomo_marketplace_setup_wizard = new MarketplaceSetupWizard();
73 $matomo_marketplace_setup_wizard_body = $matomo_marketplace_setup_wizard->get_body( false );
74
75 include dirname( __FILE__ ) . '/views/get_started.php';
76 }
77
78 private function update_if_submitted() {
79 if ( isset( $_POST )
80 && ! empty( $_POST[ self::FORM_NAME ] )
81 && is_admin()
82 && check_admin_referer( self::NONCE_NAME )
83 && $this->can_user_manage() ) {
84 if ( ! empty( $_POST[ self::FORM_NAME ][ Settings::SHOW_GET_STARTED_PAGE ] )
85 && 'no' === $_POST[ self::FORM_NAME ][ Settings::SHOW_GET_STARTED_PAGE ] ) {
86 $this->settings->apply_changes(
87 [
88 Settings::SHOW_GET_STARTED_PAGE => 0,
89 ]
90 );
91
92 return true;
93 }
94 if ( ! empty( $_POST[ self::FORM_NAME ]['track_mode'] )
95 && TrackingSettings::TRACK_MODE_DEFAULT === $_POST[ self::FORM_NAME ]['track_mode'] ) {
96 $this->settings->apply_tracking_related_changes( [ 'track_mode' => TrackingSettings::TRACK_MODE_DEFAULT ] );
97
98 self::auto_hide_page_if_steps_completed( $this->settings );
99
100 return true;
101 }
102 }
103
104 return false;
105 }
106
107 public static function should_auto_hide_get_started_page( Settings $settings ) {
108 return $settings->is_tracking_enabled()
109 && self::is_marketplace_installed_and_active();
110 }
111
112 public static function is_marketplace_installed_and_active() {
113 return MarketplaceSetupWizard::is_marketplace_installed()
114 && is_plugin_active( MarketplaceSetupWizard::MARKETPLACE_PLUGIN_FILE );
115 }
116
117 public function can_user_manage() {
118 $tracking_settings = new TrackingSettings( $this->settings );
119
120 return $tracking_settings->can_user_manage();
121 }
122
123 public function get_title() {
124 return __( 'Start getting a full picture of your visitors', 'matomo' );
125 }
126 }
127