PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 4.13.3
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v4.13.3
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 4 years ago config.php 3 years ago index.php 6 years ago
config.php
189 lines
1 <?php
2
3 if (!defined( 'ABSPATH')) {
4 exit; // if accessed directly
5 }
6
7 use Piwik\Cache;
8 use Piwik\Container\StaticContainer;
9 use Piwik\Option;
10 use Piwik\Plugin\API;
11 use WpMatomo\Capabilities;
12 use WpMatomo\Paths;
13 use WpMatomo\Settings;
14
15 return array(
16 'path.tmp' => function () {
17 $paths = new \WpMatomo\Paths();
18 return $paths->get_tmp_dir();
19 },
20 'path.misc.user' => function () {
21 $paths = new \WpMatomo\Paths();
22 return $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir()) . '/';
23 },
24 'log.handlers' => array(), // required in the console
25 'EnableDbVersionCheck' => false,
26 'path.geoip2' => function () {
27 $paths = new \WpMatomo\Paths();
28 return $paths->get_gloal_upload_dir_if_possible('DBIP-City.mmdb') . '/';
29 },
30 // we want to avoid the regular monolog logger as it could interfere with other plugins maybe. for now lets use a
31 // custom logger
32 'Psr\Log\LoggerInterface' => DI\get('\Piwik\Plugins\WordPress\Logger'),
33 'TagManagerContainerStorageDir' => function () {
34 // the location where we store the generated javascript or json container files
35 $paths = new \WpMatomo\Paths();
36 return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/'), '/');
37 },
38 'TagManagerContainerWebDir' => function () {
39 // the location where we store the generated javascript or json container files
40 $paths = new \WpMatomo\Paths();
41 return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/'), '/');
42 },
43 'Piwik\Plugins\Login\PasswordVerifier' => DI\autowire('Piwik\Plugins\WordPress\WpPasswordVerifier'),
44 'Piwik\Session\SessionAuth' => DI\autowire('Piwik\Plugins\WordPress\SessionAuth'),
45 'Piwik\Auth' => DI\autowire('Piwik\Plugins\WordPress\Auth'),
46 \Piwik\Config::class => DI\decorate(function ($previous) {
47
48 \Piwik\Plugins\TagManager\TagManager::$enableAutoContainerCreation = false;
49
50 if (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) {
51 $general = $previous->General;
52 $general['force_ssl'] = 1;
53 $general['assume_secure_protocol'] = 1;
54 $previous->General = $general;
55 }
56
57 $database = $previous->database;
58 $previous->database = \WpMatomo\Installer::get_db_infos($database);
59
60 $paths = new Paths();
61 if ( file_exists( $paths->get_config_ini_path() ) ) {
62 $general = $previous->General;
63
64 if (defined('MATOMO_TRIGGER_BROWSER_ARCHIVING')) {
65 $general['enable_browser_archiving_triggering'] = (int) MATOMO_TRIGGER_BROWSER_ARCHIVING;
66 }
67
68 $matomo_salt_key = Settings::OPTION_PREFIX . 'matomo_salt';
69 $matomo_salt = get_option($matomo_salt_key); // needs to be per site!
70 if (!$matomo_salt) {
71 $matomo_salt = \Piwik\Common::getRandomString(32);
72 update_option($matomo_salt_key, $matomo_salt, true);
73 }
74
75 $general['salt'] = $matomo_salt;
76
77 if (empty($general['trusted_hosts'])) {
78 $general['trusted_hosts'] = array();
79 }
80 $site_url = site_url();
81 if (!in_array($site_url, $general['trusted_hosts'])) {
82 $general['trusted_hosts'][] = $site_url;
83 }
84 $previous->General = $general;
85
86 if (empty($GLOBALS['MATOMO_SWITCH_BLOG_SET_UP'])) {
87 // only execute it once since we might init this several times...
88 $GLOBALS['MATOMO_SWITCH_BLOG_SET_UP'] = true;
89
90 add_action('switch_blog', function ($new_blog, $prev_blog) {
91 if ($new_blog == $prev_blog) {
92 return;
93 }
94 // ensure correct path to config is set, ensure to update tables_prefix etc.
95 $container = StaticContainer::getContainer();
96 $container->set(\Piwik\Application\Kernel\GlobalSettingsProvider::class, $container->make(\Piwik\Application\Kernel\GlobalSettingsProvider::class));
97 $container->set(\Piwik\Config::class, $container->make(\Piwik\Config::class));
98 Option::clearCache();
99 \Piwik\Site::clearCache();
100 Cache::getTransientCache()->flushAll();
101 API::unsetAllInstances();
102 }, 10, 2);
103 }
104 }
105
106 return $previous;
107 }),
108 'Piwik\Mail\Transport' => DI\autowire('WpMatomo\Email'),
109 'Piwik\Plugins\CustomJsTracker\TrackerUpdater' => DI\decorate(function ($previous) {
110 /** @var \Piwik\Plugins\CustomJsTracker\TrackerUpdater $previous */
111
112 $paths = new Paths();
113 $dir = $paths->get_matomo_js_upload_path();
114
115 $previous->setToFile($dir);
116
117 return $previous;
118 }),
119 'diagnostics.optional' => DI\decorate(function ($checks) {
120 foreach ($checks as $index => $check) {
121 if ($check && is_object($check)) {
122 $class_name = get_class($check);
123 if ($class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\ForceSSLCheck'
124 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\LoadDataInfileCheck'
125 || $class_name === 'Piwik\Plugins\CustomJsTracker\Diagnostic\TrackerJsCheck'
126 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\RequiredPrivateDirectories' // it doesn't resolve config path correctly as it is outside matomo dir etc
127 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\RecommendedPrivateDirectories' // tmp check doesn't work so far see matomo-org/matomo#18684
128 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\CronArchivingCheck'
129 || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\FileIntegrityCheck') {
130 $checks[$index] = null;
131 }
132 }
133 }
134 return array_values(array_filter($checks));
135 }),
136 'diagnostics.disabled' => \DI\add([
137 \DI\get(\Piwik\Plugins\Diagnostics\Diagnostic\PageSpeedCheck::class),
138 ]),
139 'observers.global' => DI\add(array(
140 array('FrontController.modifyErrorPage', DI\value(function (&$result, $ex) {
141 if (!empty($ex) && is_object($ex) && $ex instanceof \Piwik\Exception\NoWebsiteFoundException) {
142 // try to repair itself in case for some reason the site was not yet synced... on next reload it would
143 // then work
144 $sync = new \WpMatomo\Site\Sync(new Settings());
145 $sync->sync_current_site();
146 }
147 if (!empty($ex)
148 && is_object($ex)
149 && $ex instanceof \Piwik\Exception\NoPrivilegesException
150 && is_user_logged_in()) {
151 if (current_user_can(Capabilities::KEY_VIEW)) {
152 // some error... it looks like user should by synced but isn't yet
153 // could happen eg when in network activated mode the super admin changes permission and another
154 // user from a blog wants to access the UI while not all users are synced just yet
155 // try to repair itself in case for some reason the user was not yet synced... on next reload it would
156 // then work
157 $sync = new \WpMatomo\User\Sync();
158 $sync->sync_current_users();
159 }
160 }
161 })),
162 array('Db.getDatabaseConfig', DI\value(function (&$config) {
163 // we don't want to save these and instead detect them on demand.
164 // for security reasons etc we don't want to duplicate these values
165 include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
166 })),
167 array('Tracker.getDatabaseConfig', DI\value(function (&$configDb) {
168 // we don't want to save these and instead detect them on demand.
169 // for security reasons etc we don't want to duplicate these values
170 include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
171 })),
172 array('Config.beforeSave', DI\value(function (&$values) {
173 // we don't want to save these and instead detect them on demand.
174 // for security reasons etc we don't want to duplicate these values
175 unset($values['database']['host']);
176 unset($values['database']['username']);
177 unset($values['database']['password']);
178 unset($values['database']['dbname']);
179 unset($values['database']['tables_prefix']);
180 unset($values['database']['charset']);
181 unset($values['Plugins']);
182 unset($values['General']['enable_users_admin']);
183 unset($values['General']['enable_sites_admin']);
184 unset($values['General']['salt']);
185 })),
186 )),
187
188 );
189