PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.3.3
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.3.3
5.13.0 5.12.1 5.12.0 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 / MarketplaceSetupWizard.php
matomo / classes / WpMatomo / Admin Last commit date
TrackingSettings 1 year ago views 1 year ago AccessSettings.php 4 years ago Admin.php 1 year ago AdminSettings.php 2 years ago AdminSettingsInterface.php 6 years ago AdvancedSettings.php 1 year ago Chart.php 4 years ago CookieConsent.php 4 years ago Dashboard.php 4 years ago ExclusionSettings.php 4 years ago GeolocationSettings.php 2 years ago GetStarted.php 4 years ago ImportWpStatistics.php 4 years ago Info.php 4 years ago InvalidIpException.php 4 years ago Marketplace.php 2 years ago MarketplaceSetupWizard.php 1 year ago Menu.php 1 year ago PluginMeasurableSettings.php 2 years ago PrivacySettings.php 1 year ago SafeModeMenu.php 4 years ago Summary.php 1 year ago SystemReport.php 1 year ago TrackingSettings.php 1 year ago WhatsNewNotifications.php 1 year ago
MarketplaceSetupWizard.php
87 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 class MarketplaceSetupWizard {
13 const MARKETPLACE_PLUGIN_FILE = 'matomo-marketplace-for-wordpress/matomo-marketplace-for-wordpress.php';
14 const AJAX_IS_ACTIVE_NONCE_NAME = 'matomo-marketplace-setup-wizard-is-active';
15 const AJAX_ACTIVATE_NONCE_NAME = 'matomo-marketplace-setup-wizard-activate';
16
17 public function __construct() {
18 $this->add_hooks();
19 }
20
21 public function show() {
22 $matomo_logo_big = plugins_url( 'assets/img/logo-big.png', MATOMO_ANALYTICS_FILE );
23 $user_can_upload_plugins = current_user_can( 'upload_plugins' );
24 $user_can_activate_plugins = current_user_can( 'activate_plugins' );
25 $is_plugin_installed = is_file( WP_PLUGIN_DIR . '/' . self::MARKETPLACE_PLUGIN_FILE )
26 || is_file( WP_CONTENT_DIR . '/mu-plugins/' . self::MARKETPLACE_PLUGIN_FILE );
27
28 include dirname( __FILE__ ) . '/views/marketplace_setup_wizard.php';
29 }
30
31 private function add_hooks() {
32 if ( ! current_user_can( 'upload_plugins' )
33 || ! current_user_can( 'activate_plugins' )
34 ) {
35 return;
36 }
37
38 $this->enqueue_scripts();
39 }
40
41 private function enqueue_scripts() {
42 wp_enqueue_script(
43 'matomo-marketplace-setup-wizard',
44 plugins_url( '/assets/js/marketplace_setup_wizard.js', MATOMO_ANALYTICS_FILE ),
45 [ 'jquery' ],
46 '1.0.0',
47 true
48 );
49
50 wp_localize_script(
51 'matomo-marketplace-setup-wizard',
52 'mtmMarketplaceWizardAjax',
53 [
54 'ajax_url' => admin_url( 'admin-ajax.php' ),
55 'is_active_nonce' => wp_create_nonce( self::AJAX_IS_ACTIVE_NONCE_NAME ),
56 'activate_nonce' => wp_create_nonce( self::AJAX_ACTIVATE_NONCE_NAME ),
57 ]
58 );
59 }
60
61 public static function register_ajax() {
62 add_action( 'wp_ajax_matomo_is_marketplace_active', [ self::class, 'is_marketplace_active' ] );
63 add_action( 'wp_ajax_matomo_activate_marketplace', [ self::class, 'activate_marketplace_plugin' ] );
64 }
65
66 public static function is_marketplace_active() {
67 check_ajax_referer( self::AJAX_IS_ACTIVE_NONCE_NAME );
68
69 if ( ! current_user_can( 'activate_plugins' ) ) {
70 wp_send_json_error( [ 'message' => 'forbidden' ], 403 );
71 }
72
73 wp_send_json( [ 'active' => is_plugin_active( self::MARKETPLACE_PLUGIN_FILE ) ] );
74 }
75
76 public static function activate_marketplace_plugin() {
77 check_ajax_referer( self::AJAX_ACTIVATE_NONCE_NAME );
78
79 if ( ! current_user_can( 'activate_plugins' ) ) {
80 wp_send_json_error( [ 'message' => 'forbidden' ], 403 );
81 }
82
83 activate_plugin( self::MARKETPLACE_PLUGIN_FILE );
84 wp_send_json( [] );
85 }
86 }
87