diff --git a/CHANGELOG.md b/CHANGELOG.md index aadf637e3..0fc0cd455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +0.2.4 +- Add new feature: Safe mode + 0.2.3 - Better handling of stripslashes diff --git a/classes/WpMatomo.php b/classes/WpMatomo.php index e157a57cb..6f1ef2a9f 100644 --- a/classes/WpMatomo.php +++ b/classes/WpMatomo.php @@ -48,6 +48,14 @@ public function __construct() { $this->settings = new Settings(); + if ( self::is_safe_mode() ) { + if ( is_admin() ) { + new \WpMatomo\Admin\SafeModeMenu($this->settings); + } + + return; + } + add_action( 'init', array( $this, 'init_plugin' ) ); $capabilities = new Capabilities( $this->settings ); @@ -141,6 +149,11 @@ public static function is_admin_user() { return is_super_admin(); } + public static function is_safe_mode() + { + return defined('MATOMO_SAFE_MODE') && MATOMO_SAFE_MODE; + } + public function add_settings_link( $links ) { $get_started = new \WpMatomo\Admin\GetStarted( $this->settings ); diff --git a/classes/WpMatomo/Admin/SafeModeMenu.php b/classes/WpMatomo/Admin/SafeModeMenu.php new file mode 100644 index 000000000..58ac8cbb7 --- /dev/null +++ b/classes/WpMatomo/Admin/SafeModeMenu.php @@ -0,0 +1,57 @@ +settings = $settings; + add_action( 'admin_menu', array( $this, 'add_menu' ) ); + add_action( 'network_admin_menu', array( $this, 'add_menu' ) ); + } + + public function add_menu() { + if (!\WpMatomo::is_admin_user()) { + return; + } + + $system_report = new SystemReport( $this->settings ); + + add_menu_page( 'Matomo Analytics', 'Matomo Analytics', Menu::CAP_NOT_EXISTS, 'matomo', null, 'dashicons-analytics' ); + + add_submenu_page( $this->parentSlug, __( 'System Report', 'matomo' ), __( 'System Report', 'matomo' ), 'administrator', Menu::SLUG_SYSTEM_REPORT, array( + $system_report, + 'show' + ) ); + + } + +} diff --git a/classes/WpMatomo/Admin/SystemReport.php b/classes/WpMatomo/Admin/SystemReport.php index fa2f5e647..30b1fc34d 100644 --- a/classes/WpMatomo/Admin/SystemReport.php +++ b/classes/WpMatomo/Admin/SystemReport.php @@ -269,16 +269,18 @@ private function get_matomo_info() { } - $rows[] = array( - 'section' => __( 'Mandatory checks', 'matomo' ), - ); + if ( ! \WpMatomo::is_safe_mode() ) { + $rows[] = array( + 'section' => __( 'Mandatory checks', 'matomo' ), + ); - $rows = $this->add_diagnostic_results( $rows, $report->getMandatoryDiagnosticResults() ); + $rows = $this->add_diagnostic_results( $rows, $report->getMandatoryDiagnosticResults() ); - $rows[] = array( - 'section' => __( 'Optional checks', 'matomo' ), - ); - $rows = $this->add_diagnostic_results( $rows, $report->getOptionalDiagnosticResults() ); + $rows[] = array( + 'section' => __( 'Optional checks', 'matomo' ), + ); + $rows = $this->add_diagnostic_results( $rows, $report->getOptionalDiagnosticResults() ); + } $cliMulti = new CliMulti(); diff --git a/matomo.php b/matomo.php index eff871d93..2b4cb6de2 100644 --- a/matomo.php +++ b/matomo.php @@ -4,7 +4,7 @@ * Description: Most powerful web analytics for WordPress giving you 100% data ownership and privacy protection * Author: Matomo * Author URI: https://matomo.org - * Version: 0.2.3 + * Version: 0.2.4 * Domain Path: /languages * WC requires at least: 2.4.0 * WC tested up to: 3.2.6