PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.0.5
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.0.5
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 / config / config.php
matomo / config Last commit date
.htaccess 6 years ago common.config.ini.php 6 years ago config.php 6 years ago index.php 6 years ago
config.php
161 lines
1 <?php
2
3 if (!defined( 'ABSPATH')) {
4 exit; // if accessed directly
5 }
6
7 use WpMatomo\Capabilities;
8 use WpMatomo\Paths;
9 use WpMatomo\Settings;
10
11 return array(
12 'path.tmp' => function () {
13 $paths = new \WpMatomo\Paths();
14 return $paths->get_tmp_dir();
15 },
16 'path.misc.user' => function () {
17 $paths = new \WpMatomo\Paths();
18 return $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir()) . '/';
19 },
20 'path.geoip2' => function () {
21 $paths = new \WpMatomo\Paths();
22 return $paths->get_gloal_upload_dir_if_possible('DBIP-City.mmdb') . '/';
23 },
24 // we want to avoid the regular monolog logger as it could interfere with other plugins maybe. for now lets use a
25 // custom logger
26 'Psr\Log\LoggerInterface' => DI\get('\Piwik\Plugins\WordPress\Logger'),
27 'TagManagerContainerStorageDir' => function () {
28 // the location where we store the generated javascript or json container files
29 $paths = new \WpMatomo\Paths();
30 return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/'), '/');
31 },
32 'TagManagerContainerWebDir' => function () {
33 // the location where we store the generated javascript or json container files
34 $paths = new \WpMatomo\Paths();
35 return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/'), '/');
36 },
37 'Piwik\Auth' => DI\object('Piwik\Plugins\WordPress\Auth'),
38 \Piwik\Config::class => DI\decorate(function ($previous) {
39
40 \Piwik\Plugins\TagManager\TagManager::$enableAutoContainerCreation = false;
41
42 if (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) {
43 $general = $previous->General;
44 $general['force_ssl'] = 1;
45 $general['assume_secure_protocol'] = 1;
46 $previous->General = $general;
47 }
48
49 $database = $previous->database;
50 $previous->database = \WpMatomo\Installer::get_db_infos($database);
51
52 $paths = new Paths();
53 if ( file_exists( $paths->get_config_ini_path() ) ) {
54 $general = $previous->General;
55
56 if (defined('MATOMO_TRIGGER_BROWSER_ARCHIVING')) {
57 $general['enable_browser_archiving_triggering'] = (int) MATOMO_TRIGGER_BROWSER_ARCHIVING;
58 }
59
60 $matomo_salt_key = Settings::OPTION_PREFIX . 'matomo_salt';
61 $matomo_salt = get_option($matomo_salt_key); // needs to per site!
62 if (!$matomo_salt) {
63 $matomo_salt = \Piwik\Common::getRandomString(32);
64 update_option($matomo_salt_key, $matomo_salt);
65 }
66
67 $general['salt'] = $matomo_salt;
68
69 if (empty($general['trusted_hosts'])) {
70 $general['trusted_hosts'] = array();
71 }
72 if (!in_array(site_url(), $general['trusted_hosts'])) {
73 $general['trusted_hosts'][] = site_url();
74 }
75 $previous->General = $general;
76
77 add_action('switch_blog', function ($new_blog) {
78 global $wpdb;
79 $config = \Piwik\Config::getInstance();
80 $database = $config->database;
81 $database['tables_prefix'] = $wpdb->prefix . MATOMO_DATABASE_PREFIX;
82 $config->database = $database;
83 });
84 }
85
86 return $previous;
87 }),
88 'Zend_Mail_Transport_Abstract' => DI\object('WpMatomo\Email'),
89 'Piwik\Plugins\CustomPiwikJs\TrackerUpdater' => DI\decorate(function ($previous) {
90 /** @var \Piwik\Plugins\CustomPiwikJs\TrackerUpdater $previous */
91
92 $paths = new Paths();
93 $dir = $paths->get_matomo_js_upload_path();
94
95 $previous->setToFile($dir);
96
97 return $previous;
98 }),
99 'diagnostics.optional' => DI\decorate(function ($checks) {
100 foreach ($checks as $index => $check) {
101 if ($check && is_object($check)) {
102 $class_name = get_class($check);
103 if ($class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\ForceSSLCheck'
104 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\LoadDataInfileCheck'
105 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\FileIntegrityCheck') {
106 $checks[$index] = null;
107 }
108 }
109 }
110 return array_values(array_filter($checks));
111 }),
112 'observers.global' => DI\add(array(
113 array('FrontController.modifyErrorPage', function (&$result, $ex) {
114 if (!empty($ex) && is_object($ex) && $ex instanceof \Piwik\Exception\NoWebsiteFoundException) {
115 // try to repair itself in case for some reason the site was not yet synced... on next reload it would
116 // then work
117 $sync = new \WpMatomo\Site\Sync(new Settings());
118 $sync->sync_current_site();
119 }
120 if (!empty($ex)
121 && is_object($ex)
122 && $ex instanceof \Piwik\Exception\NoPrivilegesException
123 && is_user_logged_in()) {
124 if (current_user_can(Capabilities::KEY_VIEW)) {
125 // some error... it looks like user should by synced but isn't yet
126 // could happen eg when in network activated mode the super admin changes permission and another
127 // user from a blog wants to access the UI while not all users are synced just yet
128 // try to repair itself in case for some reason the user was not yet synced... on next reload it would
129 // then work
130 $sync = new \WpMatomo\User\Sync();
131 $sync->sync_current_users();
132 }
133 }
134 }),
135 array('Db.getDatabaseConfig', function (&$config) {
136 // we don't want to save these and instead detect them on demand.
137 // for security reasons etc we don't want to duplicate these values
138 include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
139 }),
140 array('Tracker.getDatabaseConfig', function (&$configDb) {
141 // we don't want to save these and instead detect them on demand.
142 // for security reasons etc we don't want to duplicate these values
143 include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
144 }),
145 array('Config.beforeSave', function (&$values) {
146 // we don't want to save these and instead detect them on demand.
147 // for security reasons etc we don't want to duplicate these values
148 unset($values['database']['host']);
149 unset($values['database']['username']);
150 unset($values['database']['password']);
151 unset($values['database']['dbname']);
152 unset($values['database']['tables_prefix']);
153 unset($values['Plugins']);
154 unset($values['General']['enable_users_admin']);
155 unset($values['General']['enable_sites_admin']);
156 unset($values['General']['salt']);
157 }),
158 )),
159
160 );
161