From 1fe7fbb57cb5151c4431e7112fb043f76601106b Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 5 Sep 2023 13:43:48 -0700 Subject: [PATCH 01/39] when creating matomo config, set trusted_host to domain in home URL not the entire home URL --- classes/WpMatomo/Installer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/WpMatomo/Installer.php b/classes/WpMatomo/Installer.php index 4e7eb3269..57258211e 100644 --- a/classes/WpMatomo/Installer.php +++ b/classes/WpMatomo/Installer.php @@ -258,6 +258,7 @@ private function create_db() { private function create_config( $db_info ) { $this->logger->log( 'Matomo is now creating the config' ); $domain = home_url(); + $domain = parse_url($domain, PHP_URL_HOST) ?: $domain; $general = [ 'trusted_hosts' => [ $domain ], 'salt' => Common::generateUniqId(), From 8a1bdb075ec1c148366c79d6f0a7576908958789 Mon Sep 17 00:00:00 2001 From: Lance Gilmore Date: Wed, 6 Sep 2023 13:33:20 +1200 Subject: [PATCH 02/39] changed the tests to run on push --- .github/workflows/tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 57a4b2ab1..ddb198bcb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,10 +10,7 @@ name: Matomo for WordPress Tests -on: - pull_request: - types: [ opened, review_requested ] - workflow_dispatch: +on: [push] permissions: actions: read From fa651c7fbd97641ea9372406f5470d48db0bec36 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 5 Sep 2023 18:44:23 -0700 Subject: [PATCH 03/39] fix linting error --- classes/WpMatomo/Installer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/WpMatomo/Installer.php b/classes/WpMatomo/Installer.php index 57258211e..61ba229b9 100644 --- a/classes/WpMatomo/Installer.php +++ b/classes/WpMatomo/Installer.php @@ -257,8 +257,9 @@ private function create_db() { private function create_config( $db_info ) { $this->logger->log( 'Matomo is now creating the config' ); - $domain = home_url(); - $domain = parse_url($domain, PHP_URL_HOST) ?: $domain; + $homeUrl = home_url(); + $domain = wp_parse_url($homeUrl, PHP_URL_HOST); + $domain = $domain ? $homeUrl : $domain; $general = [ 'trusted_hosts' => [ $domain ], 'salt' => Common::generateUniqId(), From 10b2d80640fbe39ef78bff2b7c60e080638e6192 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 6 Sep 2023 20:05:38 -0700 Subject: [PATCH 04/39] fix more linting errors --- classes/WpMatomo/Installer.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/WpMatomo/Installer.php b/classes/WpMatomo/Installer.php index 61ba229b9..8e5e0eded 100644 --- a/classes/WpMatomo/Installer.php +++ b/classes/WpMatomo/Installer.php @@ -257,15 +257,15 @@ private function create_db() { private function create_config( $db_info ) { $this->logger->log( 'Matomo is now creating the config' ); - $homeUrl = home_url(); - $domain = wp_parse_url($homeUrl, PHP_URL_HOST); - $domain = $domain ? $homeUrl : $domain; - $general = [ + $home_url = home_url(); + $domain = wp_parse_url( $home_url, PHP_URL_HOST ); + $domain = $domain ? $home_url : $domain; + $general = [ 'trusted_hosts' => [ $domain ], 'salt' => Common::generateUniqId(), ]; - $config = Config::getInstance(); - $path = $config->getLocalPath(); + $config = Config::getInstance(); + $path = $config->getLocalPath(); if ( ! is_dir( dirname( $path ) ) ) { wp_mkdir_p( dirname( $path ) ); } From 3b1eda53d1bff2bf43d8b04fd4f65befb3dc075d Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 9 Sep 2023 11:24:42 -0700 Subject: [PATCH 05/39] workaround https://github.com/WPManageNinja/fluent-smtp/issues/180 for users that use Fluent SMTP --- classes/WpMatomo/Email.php | 6 +- classes/WpMatomo/Workarounds/FluentSmtp.php | 67 +++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 classes/WpMatomo/Workarounds/FluentSmtp.php diff --git a/classes/WpMatomo/Email.php b/classes/WpMatomo/Email.php index 99c34a864..911664952 100644 --- a/classes/WpMatomo/Email.php +++ b/classes/WpMatomo/Email.php @@ -99,7 +99,7 @@ private function send_mail_through_wordpress( $recipients, $subject, $content, $ add_action( 'phpmailer_init', - function ( $phpmailer ) use ( $attachments, $subject, $random_id, &$executed_action ) { + function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_action ) { /** @var PHPMailer $phpmailer */ if ( $executed_action ) { return; // already done, do not execute another time @@ -135,6 +135,8 @@ function ( $phpmailer ) use ( $attachments, $subject, $random_id, &$executed_act ); } } + + $phpmailer = WpMatomo\Workarounds\FluentSmtp::make_php_mailer_proxy($phpmailer); } ); } @@ -144,6 +146,8 @@ function ( $phpmailer ) use ( $attachments, $subject, $random_id, &$executed_act remove_action( 'wp_mail_failed', [ $this, 'on_error' ] ); remove_filter( 'wp_mail_content_type', [ $this, 'set_content_type' ] ); + WpMatomo\Workarounds\FluentSmtp::unset_phpmailer(); + if ( ! $success ) { $message = 'Error unknown.'; if ( ! empty( $this->wp_email_error ) && is_object( $this->wp_email_error ) && $this->wp_email_error instanceof WP_Error ) { diff --git a/classes/WpMatomo/Workarounds/FluentSmtp.php b/classes/WpMatomo/Workarounds/FluentSmtp.php new file mode 100644 index 000000000..101cb8fce --- /dev/null +++ b/classes/WpMatomo/Workarounds/FluentSmtp.php @@ -0,0 +1,67 @@ +wrapped = $phpmailer; + } + + public function __get( $name ) + { + return $this->wrapped->$name; + } + + public function __set( $name, $value ) + { + $this->wrapped->$name = $value; + } + + public function __call( $name , $arguments ) { + if ( $name == 'addAttachment' ) { + return; + } + + return call_user_func_array([$this->wrapped, $name], $arguments); + } + }; + } + + // fluent smtp will check if the global phpmailer object's class is actually PHPMailer, and if not, abort + // so we need to make sure it doesn't see our wrapped proxy again. + public static function unset_phpmailer() { + global $phpmailer; + + if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { + return; + } + + $phpmailer = null; + } +} From 5e512acefff07a8952efbbec19317f53f95275f2 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 9 Sep 2023 11:41:37 -0700 Subject: [PATCH 06/39] fix linting errors --- classes/WpMatomo/Email.php | 4 +- classes/WpMatomo/Workarounds/FluentSmtp.php | 87 ++++++++----------- .../Workarounds/FluentSmtp/PHPMailerProxy.php | 40 +++++++++ 3 files changed, 76 insertions(+), 55 deletions(-) create mode 100644 classes/WpMatomo/Workarounds/FluentSmtp/PHPMailerProxy.php diff --git a/classes/WpMatomo/Email.php b/classes/WpMatomo/Email.php index 911664952..4134e4b81 100644 --- a/classes/WpMatomo/Email.php +++ b/classes/WpMatomo/Email.php @@ -136,7 +136,7 @@ function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_ac } } - $phpmailer = WpMatomo\Workarounds\FluentSmtp::make_php_mailer_proxy($phpmailer); + $phpmailer = WpMatomo\Workarounds\FluentSmtp::make_php_mailer_proxy( $phpmailer ); } ); } @@ -146,7 +146,7 @@ function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_ac remove_action( 'wp_mail_failed', [ $this, 'on_error' ] ); remove_filter( 'wp_mail_content_type', [ $this, 'set_content_type' ] ); - WpMatomo\Workarounds\FluentSmtp::unset_phpmailer(); + WpMatomo\Workarounds\FluentSmtp::unset_phpmailer(); if ( ! $success ) { $message = 'Error unknown.'; diff --git a/classes/WpMatomo/Workarounds/FluentSmtp.php b/classes/WpMatomo/Workarounds/FluentSmtp.php index 101cb8fce..27a31d43e 100644 --- a/classes/WpMatomo/Workarounds/FluentSmtp.php +++ b/classes/WpMatomo/Workarounds/FluentSmtp.php @@ -9,59 +9,40 @@ namespace WpMatomo\Workarounds; +use WpMatomo\Workarounds\FluentSmtp\PHPMailerProxy; + /** - * Workarounds for bugs in the Fluent SMTP wordpress plugin. + * Workarounds for bugs in the Fluent SMTP WordPress plugin. */ -class FluentSmtp -{ - /** - * Worksaround this bug in Fluent SMTP: https://github.com/WPManageNinja/fluent-smtp/issues/180 - * by creating a proxy to the global PHPMailer object that disables the addAttachment() method. - * - * Should be used in a phpmailer_init action after manually adding attachments to the original - * PHPMailer instance. - */ - public static function make_php_mailer_proxy( $phpmailer ) { - if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { - return $phpmailer; - } - - return new class( $phpmailer ) { - private $wrapped; - - public function __construct( $phpmailer ) { - $this->wrapped = $phpmailer; - } - - public function __get( $name ) - { - return $this->wrapped->$name; - } - - public function __set( $name, $value ) - { - $this->wrapped->$name = $value; - } - - public function __call( $name , $arguments ) { - if ( $name == 'addAttachment' ) { - return; - } - - return call_user_func_array([$this->wrapped, $name], $arguments); - } - }; - } - - // fluent smtp will check if the global phpmailer object's class is actually PHPMailer, and if not, abort - // so we need to make sure it doesn't see our wrapped proxy again. - public static function unset_phpmailer() { - global $phpmailer; - - if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { - return; - } - - $phpmailer = null; - } +class FluentSmtp { + /** + * Worksaround this bug in Fluent SMTP: https://github.com/WPManageNinja/fluent-smtp/issues/180 + * by creating a proxy to the global PHPMailer object that disables the addAttachment() method. + * + * Should be used in a phpmailer_init action after manually adding attachments to the original + * PHPMailer instance. + */ + public static function make_php_mailer_proxy( $phpmailer ) { + if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { + return $phpmailer; + } + + return new PHPMailerProxy( $phpmailer ); + } + + /** + * FluentSMTP will check if the global phpmailer object's class is actually PHPMailer, and if not, abort + * so we need to make sure it doesn't see our wrapped proxy again. + */ + public static function unset_phpmailer() { + global $phpmailer; + + if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { + return; + } + + // @codingStandardsIgnoreStart + $phpmailer = null; + // @codingStandardsIgnoreEnd + } } diff --git a/classes/WpMatomo/Workarounds/FluentSmtp/PHPMailerProxy.php b/classes/WpMatomo/Workarounds/FluentSmtp/PHPMailerProxy.php new file mode 100644 index 000000000..6c20aaeca --- /dev/null +++ b/classes/WpMatomo/Workarounds/FluentSmtp/PHPMailerProxy.php @@ -0,0 +1,40 @@ +wrapped = $phpmailer; + } + + // @codingStandardsIgnoreStart + + public function __get( $name ) + { + return $this->wrapped->$name; + } + + public function __set( $name, $value ) + { + $this->wrapped->$name = $value; + } + + public function __call( $name , $arguments ) { + if ( $name == 'addAttachment' ) { + return; + } + + return call_user_func_array([$this->wrapped, $name], $arguments); + } + + // @codingStandardsIgnoreEnd +} From e29106e6feaa2b13b558cb7e1abeca5ea4e3acaa Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 9 Sep 2023 11:43:01 -0700 Subject: [PATCH 07/39] add editor config so supported IDEs will automatically edit files correctly --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..4ca7aafec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[*.php] +indent_style = tab +indent_size = 4 From 5e81c3a1ea775e73584fdd3ea35a472d37a4631a Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 9 Sep 2023 11:44:59 -0700 Subject: [PATCH 08/39] do not export editorconfig file --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 7382ea25b..b10c8613f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -39,3 +39,4 @@ phpbench.json export-ignore composer.travis.json export-ignore karma.conf.js export-ignore .DS_Store export-ignore +.editorconfig export-ignore From 572cc70267114f93e4ef68698a87a8e47e7cbbc0 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sun, 10 Sep 2023 18:43:16 -0700 Subject: [PATCH 09/39] reset phpmailer global if applying the fluentsmtp workaround, rather than unsetting it --- classes/WpMatomo/Email.php | 8 +++++--- classes/WpMatomo/Workarounds/FluentSmtp.php | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/classes/WpMatomo/Email.php b/classes/WpMatomo/Email.php index 4134e4b81..8afefbeac 100644 --- a/classes/WpMatomo/Email.php +++ b/classes/WpMatomo/Email.php @@ -97,9 +97,11 @@ private function send_mail_through_wordpress( $recipients, $subject, $content, $ $header = 'X-Matomo: ' . $random_id; $executed_action = false; + $fluent_smtp_workaround = new WpMatomo\Workarounds\FluentSmtp(); + add_action( 'phpmailer_init', - function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_action ) { + function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_action, $fluent_smtp_workaround ) { /** @var PHPMailer $phpmailer */ if ( $executed_action ) { return; // already done, do not execute another time @@ -136,7 +138,7 @@ function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_ac } } - $phpmailer = WpMatomo\Workarounds\FluentSmtp::make_php_mailer_proxy( $phpmailer ); + $phpmailer = $fluent_smtp_workaround->make_php_mailer_proxy( $phpmailer ); } ); } @@ -146,7 +148,7 @@ function ( &$phpmailer ) use ( $attachments, $subject, $random_id, &$executed_ac remove_action( 'wp_mail_failed', [ $this, 'on_error' ] ); remove_filter( 'wp_mail_content_type', [ $this, 'set_content_type' ] ); - WpMatomo\Workarounds\FluentSmtp::unset_phpmailer(); + $fluent_smtp_workaround->reset_phpmailer(); if ( ! $success ) { $message = 'Error unknown.'; diff --git a/classes/WpMatomo/Workarounds/FluentSmtp.php b/classes/WpMatomo/Workarounds/FluentSmtp.php index 27a31d43e..b41100390 100644 --- a/classes/WpMatomo/Workarounds/FluentSmtp.php +++ b/classes/WpMatomo/Workarounds/FluentSmtp.php @@ -15,6 +15,11 @@ * Workarounds for bugs in the Fluent SMTP WordPress plugin. */ class FluentSmtp { + + private $original_phpmailer = null; + + private $was_phpmailer_replaced = false; + /** * Worksaround this bug in Fluent SMTP: https://github.com/WPManageNinja/fluent-smtp/issues/180 * by creating a proxy to the global PHPMailer object that disables the addAttachment() method. @@ -22,11 +27,13 @@ class FluentSmtp { * Should be used in a phpmailer_init action after manually adding attachments to the original * PHPMailer instance. */ - public static function make_php_mailer_proxy( $phpmailer ) { + public function make_php_mailer_proxy( $phpmailer ) { if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { return $phpmailer; } + $this->was_phpmailer_replaced = true; + return new PHPMailerProxy( $phpmailer ); } @@ -34,15 +41,19 @@ public static function make_php_mailer_proxy( $phpmailer ) { * FluentSMTP will check if the global phpmailer object's class is actually PHPMailer, and if not, abort * so we need to make sure it doesn't see our wrapped proxy again. */ - public static function unset_phpmailer() { + public function reset_phpmailer() { global $phpmailer; + if ( ! $this->was_phpmailer_replaced ) { + return; + } + if ( ! is_plugin_active( 'fluent-smtp/fluent-smtp.php' ) ) { return; } // @codingStandardsIgnoreStart - $phpmailer = null; + $phpmailer = $this->original_phpmailer; // @codingStandardsIgnoreEnd } } From 31f511f794b8f9f4c66ba8dad980f54cb3a0f847 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 2 Sep 2023 16:49:54 -0700 Subject: [PATCH 10/39] initial docker-compose that will download a variable version of wordpress, set up the mariadb/mysql database and setup the wordpress config w/ matomo-for-wordpress available as a plugin via docker volume --- .gitattributes | 1 + .gitignore | 7 ++- docker-compose.yml | 131 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/.gitattributes b/.gitattributes index b10c8613f..645f82942 100644 --- a/.gitattributes +++ b/.gitattributes @@ -40,3 +40,4 @@ composer.travis.json export-ignore karma.conf.js export-ignore .DS_Store export-ignore .editorconfig export-ignore +docker-compose.yml export-ignore diff --git a/.gitignore b/.gitignore index 369334ed7..d9ca7e0de 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,9 @@ /vendor/ .php-cs-fixer.cache .*~ -*~ \ No newline at end of file +*~ +.idea/ + +# for local docker dev +docker +.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..e24f56b97 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,131 @@ +# to override the environment, you can configure environment variables in a .env file saved in this directory. +# the following environment variables are supported: +# - PHP_VERSION (defaults to 8.1, must be a version that has an official docker container available) +# - BACKEND ('mariadb' or 'mysql', defaults to 'mariadb') +# - WORDPRESS_VERSION (defaults to ) +# - PORT (the port to expose wordpress on, defaults to 3000) + +services: + wordpress: + image: "php:${PHP_VERSION:-8.1}-apache" + volumes: + - ./docker/wordpress:/var/www/html + - ./docker/wordpress_php:/usr/src/php + - ./docker/wordpress_php_extensions:/usr/local/lib/php/extensions + - ./docker/wordpress_php_conf:/usr/local/etc/php/conf.d + - .:/var/www/html/matomo-for-wordpress + ports: + - "${PORT:-3000}:80" + environment: + WP_DB_USER: root + WP_DB_PASSWORD: pass + WP_DB_HOST: "${BACKEND:-mariadb}" + entrypoint: + - bash + - -c + - | + set -e + + cd /var/www/html + + LATEST_WORDPRESS_VERSION=6.3.1 # can't use the github API, too easy to get rate limited + + # install PHP extensions needed + for extension in mysqli pdo pdo_mysql; do + if [ ! -f /usr/local/lib/php/extensions/*/$$extension.so ]; then + docker-php-ext-install $$extension + fi + done + + # install wordpress if not present + WORDPRESS_VERSION=$${WORDPRESS_VERSION:-$$LATEST_WORDPRESS_VERSION} + if [ ! -d "/var/www/html/$$WORDPRESS_VERSION" ]; then + WORDPRESS_URL="https://wordpress.org/wordpress-$$WORDPRESS_VERSION.tar.gz" + echo "installing wordpress $$WORDPRESS_VERSION from $$WORDPRESS_URL..." + + curl -O "$$WORDPRESS_URL" + tar -xvf "wordpress-$$WORDPRESS_VERSION.tar.gz" + mv wordpress "$$WORDPRESS_VERSION" + + echo "wordpress installed!" + else + echo "wordpress $$WORDPRESS_VERSION already installed." + fi + + # create database if it does not already exist + export WP_DB_NAME="wp_matomo_$$WORDPRESS_VERSION" + php -r "\$$pdo = new PDO('mysql:host=$$WP_DB_HOST', '$$WP_DB_USER', '$$WP_DB_PASSWORD'); \$$pdo->exec('CREATE DATABASE IF NOT EXISTS \`$$WP_DB_NAME\`');" + + # setup wordpress config if not done so + if [ ! -f "/var/www/html/$$WORDPRESS_VERSION/wp-config.php" ]; then + cat > "/var/www/html/$$WORDPRESS_VERSION/wp-config.php" < Date: Sat, 2 Sep 2023 20:15:21 -0700 Subject: [PATCH 11/39] wait for database on startup, grant all privileges and when chowning wordpress files, ignore recursive volume --- docker-compose.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e24f56b97..ca542ba17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ # the following environment variables are supported: # - PHP_VERSION (defaults to 8.1, must be a version that has an official docker container available) # - BACKEND ('mariadb' or 'mysql', defaults to 'mariadb') -# - WORDPRESS_VERSION (defaults to ) +# - WORDPRESS_VERSION (defaults to latest (defined below)) # - PORT (the port to expose wordpress on, defaults to 3000) services: @@ -52,9 +52,13 @@ services: echo "wordpress $$WORDPRESS_VERSION already installed." fi + sleep 5 # wait for database + # create database if it does not already exist - export WP_DB_NAME="wp_matomo_$$WORDPRESS_VERSION" - php -r "\$$pdo = new PDO('mysql:host=$$WP_DB_HOST', '$$WP_DB_USER', '$$WP_DB_PASSWORD'); \$$pdo->exec('CREATE DATABASE IF NOT EXISTS \`$$WP_DB_NAME\`');" + export WP_DB_NAME=$$(echo "wp_matomo_$$WORDPRESS_VERSION" | sed 's/\./_/g') + php -r "\$$pdo = new PDO('mysql:host=$$WP_DB_HOST', '$$WP_DB_USER', '$$WP_DB_PASSWORD'); + \$$pdo->exec('CREATE DATABASE IF NOT EXISTS \`$$WP_DB_NAME\`');\ + \$$pdo->exec('GRANT ALL PRIVILEGES ON $$WP_DB_NAME.* TO \'root\'@\'%\' IDENTIFIED BY \'pass\'');" # setup wordpress config if not done so if [ ! -f "/var/www/html/$$WORDPRESS_VERSION/wp-config.php" ]; then @@ -99,7 +103,7 @@ services: fi # make sure the files can be edited outside of docker (for easier debugging) - chown -R "${UID:-1000}:${GID:-1000}" /var/www/html + find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chown "${UID:-1000}:${GID:-1000}" {} + # ordinarily the command is passed to the entrypoint as an argument, but this doesn't seem to work when overriding the entrypoint # through docker-compose From 22f365e5f12a2da85de54b716448127605efef4f Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sun, 3 Sep 2023 11:11:30 -0700 Subject: [PATCH 12/39] solve more filesystem issues --- docker-compose.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index ca542ba17..dbf40a5f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - ./docker/wordpress_php_extensions:/usr/local/lib/php/extensions - ./docker/wordpress_php_conf:/usr/local/etc/php/conf.d - .:/var/www/html/matomo-for-wordpress + - /var/www/html/matomo-for-wordpress/app/tmp ports: - "${PORT:-3000}:80" environment: @@ -52,7 +53,9 @@ services: echo "wordpress $$WORDPRESS_VERSION already installed." fi + echo "waiting for database..." sleep 5 # wait for database + echo "done." # create database if it does not already exist export WP_DB_NAME=$$(echo "wp_matomo_$$WORDPRESS_VERSION" | sed 's/\./_/g') @@ -80,7 +83,10 @@ services: define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); define( 'NONCE_SALT', 'put your unique phrase here' ); - + + define( 'FS_CHMOD_DIR', ( 0777 & ~ umask() ) ); + define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) ); + $$table_prefix = 'wp_'; /* That's all, stop editing! Happy publishing. */ @@ -103,7 +109,10 @@ services: fi # make sure the files can be edited outside of docker (for easier debugging) + # TODO: file permissions becoming a pain, shouldn't have to deal with this for dev env. this works for now though. find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chown "${UID:-1000}:${GID:-1000}" {} + + find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chmod 0777 {} + + chmod -R 0777 "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo/app/tmp" # ordinarily the command is passed to the entrypoint as an argument, but this doesn't seem to work when overriding the entrypoint # through docker-compose From ead653ebedc9ca217ec8bdd2b3bb4600b563ae08 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sun, 3 Sep 2023 12:02:02 -0700 Subject: [PATCH 13/39] allow matomo for wordpress to work in local dev when symlinked in --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index dbf40a5f9..1410d5594 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -87,6 +87,8 @@ services: define( 'FS_CHMOD_DIR', ( 0777 & ~ umask() ) ); define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) ); + define( 'MATOMO_ANALYTICS_FILE', __DIR__ . '/wp-content/plugins/matomo/matomo.php' ); + $$table_prefix = 'wp_'; /* That's all, stop editing! Happy publishing. */ From 1386de0ca1ca267f38467c01eb2cabef601ccfff Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 4 Sep 2023 22:05:06 -0700 Subject: [PATCH 14/39] set FS_MODE const in local dev environment --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 1410d5594..be3bd555b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -86,6 +86,7 @@ services: define( 'FS_CHMOD_DIR', ( 0777 & ~ umask() ) ); define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) ); + define( 'FS_METHOD', 'direct' ); define( 'MATOMO_ANALYTICS_FILE', __DIR__ . '/wp-content/plugins/matomo/matomo.php' ); From 59a5ab6333d9468db185aa2786e179ce7482c4d8 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 5 Sep 2023 13:27:23 -0700 Subject: [PATCH 15/39] in local environment add index.php that lists available wordpress installs so devs are not confused if they go to localhost:3000/ --- docker-compose.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index be3bd555b..e2f076a71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -111,11 +111,43 @@ services: ln -s /var/www/html/matomo-for-wordpress "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" fi + # add index.php file listing available installs to root /var/www/html + if [ ! -f "/var/www/html/index.php" ]; then + cat > "/var/www/html/index.php" < + + + + +

Available Wordpress Installs

+
+
    + +
  • + +
+
+ + + EOF + fi + # make sure the files can be edited outside of docker (for easier debugging) # TODO: file permissions becoming a pain, shouldn't have to deal with this for dev env. this works for now though. find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chown "${UID:-1000}:${GID:-1000}" {} + find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chmod 0777 {} + - chmod -R 0777 "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo/app/tmp" + chmod -R 0777 "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo/app/tmp" "/var/www/html/index.php" # ordinarily the command is passed to the entrypoint as an argument, but this doesn't seem to work when overriding the entrypoint # through docker-compose From 85209ddb89b5366299b90b449407dcdb6fded82d Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 8 Sep 2023 12:58:30 -0700 Subject: [PATCH 16/39] fix unescaped dollar sign in bash script --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e2f076a71..569edcd43 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -90,7 +90,7 @@ services: define( 'MATOMO_ANALYTICS_FILE', __DIR__ . '/wp-content/plugins/matomo/matomo.php' ); - $$table_prefix = 'wp_'; + \$$table_prefix = 'wp_'; /* That's all, stop editing! Happy publishing. */ From 85d4ec9d174298afe0a06cf813accf28a0dd444a Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 8 Sep 2023 14:58:58 -0700 Subject: [PATCH 17/39] Add docker based local dev environment docs to README.md. --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 0785d79fe..86e7522cb 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,35 @@ Now run the below command to have phpunit etc available. Requires [Composer](htt composer install # or composer.phar install ``` +#### Local environment through docker + +If you have docker and docker-compose installed, you can setup a local development environment with a single command: + +```bash +docker-compose up wordpress; docker-compose stop +``` + +The first time the container starts it will compile php extensions within the container it needs, download wordpress +and set it up. + +After starting the container, visit `https://localhost:3000/` to see the list of available wordpress versions. +Pick one, and it will take you to the Wordpress installer. + +After installing Wordpress, go to the plugins page and activate Matomo for Wordpress. + +Note: docker related files, such as the downloaded wordpress and database files, will be stored in a new folder named `./docker`. As long +as you are using this local dev environment, you should not delete this folder. + +**Customizing your local environment** + +You can customize your local environment by setting environment variables in a `.env` file. Currently, the following +variables are supported: + +- `PHP_VERSION` - (defaults to 8.1, must be a version that has an official docker container available) +- `BACKEND` - ('mariadb' or 'mysql', defaults to 'mariadb') +- `WORDPRESS_VERSION` - (defaults to 6.3.1) +- `PORT` - (the port to expose wordpress on, defaults to 3000) + ## Security Security is a top priority at Matomo. As potential issues are discovered, we validate, patch and release fixes as quickly as we can. We have a security bug bounty program in place that rewards researchers for finding security issues and disclosing them to us. From e922db426cbef152680bcadf856012b48a552d79 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 8 Sep 2023 15:45:22 -0700 Subject: [PATCH 18/39] allow php conf.d volume to be writeable so php can be configured differently --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 569edcd43..b5a7319b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -147,7 +147,7 @@ services: # TODO: file permissions becoming a pain, shouldn't have to deal with this for dev env. this works for now though. find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chown "${UID:-1000}:${GID:-1000}" {} + find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chmod 0777 {} + - chmod -R 0777 "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo/app/tmp" "/var/www/html/index.php" + chmod -R 0777 "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo/app/tmp" "/var/www/html/index.php" "/usr/local/etc/php/conf.d" # ordinarily the command is passed to the entrypoint as an argument, but this doesn't seem to work when overriding the entrypoint # through docker-compose From 95d263a17557c7e37e5c7a525cdcc36ab0ee95e1 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 8 Sep 2023 20:57:47 -0700 Subject: [PATCH 19/39] separate php related volumes by php version --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b5a7319b1..07e1ecad9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,9 @@ services: image: "php:${PHP_VERSION:-8.1}-apache" volumes: - ./docker/wordpress:/var/www/html - - ./docker/wordpress_php:/usr/src/php - - ./docker/wordpress_php_extensions:/usr/local/lib/php/extensions - - ./docker/wordpress_php_conf:/usr/local/etc/php/conf.d + - "./docker/php-${PHP_VERSION:-8.1}/php:/usr/src/php" + - "./docker/php-${PHP_VERSION:-8.1}/extensions:/usr/local/lib/php/extensions" + - "./docker/php-${PHP_VERSION:-8.1}/conf:/usr/local/etc/php/conf.d" - .:/var/www/html/matomo-for-wordpress - /var/www/html/matomo-for-wordpress/app/tmp ports: From 8f40d7e432146c44879c028416f5ca81410ac60a Mon Sep 17 00:00:00 2001 From: dizzy Date: Mon, 11 Sep 2023 14:21:15 -0700 Subject: [PATCH 20/39] Update FluentSmtp.php --- classes/WpMatomo/Workarounds/FluentSmtp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/WpMatomo/Workarounds/FluentSmtp.php b/classes/WpMatomo/Workarounds/FluentSmtp.php index b41100390..2355bc57c 100644 --- a/classes/WpMatomo/Workarounds/FluentSmtp.php +++ b/classes/WpMatomo/Workarounds/FluentSmtp.php @@ -33,6 +33,7 @@ public function make_php_mailer_proxy( $phpmailer ) { } $this->was_phpmailer_replaced = true; + $this->original_phpmailer = $phpmailer; return new PHPMailerProxy( $phpmailer ); } From 45979948aa777c82a5cd8715e2fd28979fd41f98 Mon Sep 17 00:00:00 2001 From: dizzy Date: Mon, 11 Sep 2023 14:28:02 -0700 Subject: [PATCH 21/39] Update FluentSmtp.php --- classes/WpMatomo/Workarounds/FluentSmtp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/WpMatomo/Workarounds/FluentSmtp.php b/classes/WpMatomo/Workarounds/FluentSmtp.php index 2355bc57c..ab35033a4 100644 --- a/classes/WpMatomo/Workarounds/FluentSmtp.php +++ b/classes/WpMatomo/Workarounds/FluentSmtp.php @@ -33,7 +33,7 @@ public function make_php_mailer_proxy( $phpmailer ) { } $this->was_phpmailer_replaced = true; - $this->original_phpmailer = $phpmailer; + $this->original_phpmailer = $phpmailer; return new PHPMailerProxy( $phpmailer ); } From 25c444ca7973aba2b48fff01f72e4ea0debde1da Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 19:18:34 -0700 Subject: [PATCH 22/39] install wp-cli in local dev and download/install specified wp plugins before start --- docker-compose.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 07e1ecad9..eee509649 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: set -e cd /var/www/html - + LATEST_WORDPRESS_VERSION=6.3.1 # can't use the github API, too easy to get rate limited # install PHP extensions needed @@ -143,6 +143,31 @@ services: EOF fi + # download WP_PLUGINS plugins if not present + if [ ! -f "/var/www/html/wp-cli.phar" ]; then + curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /var/www/html/wp-cli.phar + fi + chmod +x /var/www/html/wp-cli.phar + + for PLUGIN_VERSION in $WP_PLUGINS + do + PLUGIN_VERSION_ARRAY=($${PLUGIN_VERSION//:/ }) + PLUGIN=$${PLUGIN_VERSION_ARRAY[0]} + VERSION=$${PLUGIN_VERSION_ARRAY[1]} + + if [ "$$PLUGIN" = "matomo" ]; then + echo "skipping matomo plugin install" + continue + fi + + if [[ ! -z "$$VERSION" ]]; then + VERSION_ARGUMENT="--version=$$VERSION" + fi + + echo "installing plugin $$PLUGIN $$VERSION_ARGUMENT" + /var/www/html/wp-cli.phar --allow-root --path=/var/www/html/$$WORDPRESS_VERSION plugin install --activate $$VERSION_ARGUMENT $$PLUGIN || true + done + # make sure the files can be edited outside of docker (for easier debugging) # TODO: file permissions becoming a pain, shouldn't have to deal with this for dev env. this works for now though. find "/var/www/html/$$WORDPRESS_VERSION" -path "/var/www/html/$$WORDPRESS_VERSION/wp-content/plugins/matomo" -prune -o -exec chown "${UID:-1000}:${GID:-1000}" {} + From ff39ecec44560330db32726e27f00c8a354c23f3 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 19:33:04 -0700 Subject: [PATCH 23/39] add versions to active plugins entry in system report --- classes/WpMatomo/Admin/SystemReport.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/WpMatomo/Admin/SystemReport.php b/classes/WpMatomo/Admin/SystemReport.php index 184b731d7..7072558f2 100644 --- a/classes/WpMatomo/Admin/SystemReport.php +++ b/classes/WpMatomo/Admin/SystemReport.php @@ -1633,11 +1633,15 @@ private function get_db_grants() { private function get_actives_plugins() { $active_plugins = get_option( 'active_plugins', [] ); if ( ! empty( $active_plugins ) && is_array( $active_plugins ) ) { + $plugins = get_plugins(); $active_plugins = array_map( - function ( $active_plugin ) { - $parts = explode( '/', trim( $active_plugin ) ); + function ( $active_plugin ) use ( $plugins ) { + $plugin_version = isset($plugins[$active_plugin]['Version']) ? $plugins[$active_plugin]['Version'] : null; + $result_suffix = $plugin_version ? (':' . $plugin_version) : ''; - return trim( $parts[0] ); + $parts = explode( '/', trim( $active_plugin ) ); + + return trim( $parts[0] ) . $result_suffix; }, $active_plugins ); From 2e1930a49d3d8240094f53bb064d6ba0fd898357 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 19:49:00 -0700 Subject: [PATCH 24/39] add entry in readme for WP_PLUGINS --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 86e7522cb..9ae6e985f 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,13 @@ as you are using this local dev environment, you should not delete this folder. You can customize your local environment by setting environment variables in a `.env` file. Currently, the following variables are supported: -- `PHP_VERSION` - (defaults to 8.1, must be a version that has an official docker container available) -- `BACKEND` - ('mariadb' or 'mysql', defaults to 'mariadb') -- `WORDPRESS_VERSION` - (defaults to 6.3.1) -- `PORT` - (the port to expose wordpress on, defaults to 3000) +- `PHP_VERSION` - defaults to 8.1, must be a version that has an official docker container available +- `BACKEND` - 'mariadb' or 'mysql', defaults to 'mariadb' +- `WORDPRESS_VERSION` - defaults to 6.3.1 +- `PORT` - the port to expose wordpress on, defaults to 3000 +- `WP_PLUGINS` - a list of plugin/version pairs like "my-plugin my-other-plugin:1.2.3". for each item, wp-cli will attempt to download and activate the plugin. + This is the same format as the Active Plugins entry in the System Report, so you could copy that value to this environment variable to quickly (or more quickly) + replicate a user's setup. ## Security From 2013a05b6b9f84d2bf636d892165282086f962c0 Mon Sep 17 00:00:00 2001 From: dizzy Date: Mon, 11 Sep 2023 19:51:36 -0700 Subject: [PATCH 25/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ae6e985f..1dd9e79ab 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ variables are supported: - `BACKEND` - 'mariadb' or 'mysql', defaults to 'mariadb' - `WORDPRESS_VERSION` - defaults to 6.3.1 - `PORT` - the port to expose wordpress on, defaults to 3000 -- `WP_PLUGINS` - a list of plugin/version pairs like "my-plugin my-other-plugin:1.2.3". for each item, wp-cli will attempt to download and activate the plugin. +- `WP_PLUGINS` - a list of plugin/version pairs like "my-plugin my-other-plugin:1.2.3". For each item, wp-cli will attempt to download and activate the plugin. This is the same format as the Active Plugins entry in the System Report, so you could copy that value to this environment variable to quickly (or more quickly) replicate a user's setup. From 2c588e55b4c813a4d80af8b7fe75774ee3ffc16e Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 19:54:18 -0700 Subject: [PATCH 26/39] fix linting errors --- classes/WpMatomo/Admin/SystemReport.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/classes/WpMatomo/Admin/SystemReport.php b/classes/WpMatomo/Admin/SystemReport.php index 7072558f2..e3ae62e9c 100644 --- a/classes/WpMatomo/Admin/SystemReport.php +++ b/classes/WpMatomo/Admin/SystemReport.php @@ -1636,11 +1636,9 @@ private function get_actives_plugins() { $plugins = get_plugins(); $active_plugins = array_map( function ( $active_plugin ) use ( $plugins ) { - $plugin_version = isset($plugins[$active_plugin]['Version']) ? $plugins[$active_plugin]['Version'] : null; - $result_suffix = $plugin_version ? (':' . $plugin_version) : ''; - + $plugin_version = isset( $plugins[ $active_plugin ]['Version'] ) ? $plugins[ $active_plugin ]['Version'] : null; + $result_suffix = $plugin_version ? ( ':' . $plugin_version ) : ''; $parts = explode( '/', trim( $active_plugin ) ); - return trim( $parts[0] ) . $result_suffix; }, $active_plugins From 497be2c70f746f71c6b67000bac13b6853c04c7a Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 19:57:43 -0700 Subject: [PATCH 27/39] add ecommerce tracking setting to system report --- classes/WpMatomo/Admin/SystemReport.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/WpMatomo/Admin/SystemReport.php b/classes/WpMatomo/Admin/SystemReport.php index 184b731d7..908a7f07b 100644 --- a/classes/WpMatomo/Admin/SystemReport.php +++ b/classes/WpMatomo/Admin/SystemReport.php @@ -758,6 +758,7 @@ private function get_matomo_info() { // always show these settings $global_settings_always_show = [ 'track_mode', + 'track_ecommerce', 'track_codeposition', 'track_api_endpoint', 'track_js_endpoint', From 3b88cefadd30e9a69f7e194425270dcb4cab5887 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 20:08:59 -0700 Subject: [PATCH 28/39] in .editorconfig set trim_trailing_whitespace = true --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 4ca7aafec..682a2be1c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,6 +3,7 @@ root = true [*] end_of_line = lf insert_final_newline = true +trim_trailing_whitespace = true [*.php] indent_style = tab From 9ede8ecb4894c6787fc4e2d774002ef60f5e56b8 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 11 Sep 2023 20:21:39 -0700 Subject: [PATCH 29/39] add section in readme for accessing the mariadb/mysql database in the local dev environment --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 86e7522cb..a83d6e8cd 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,19 @@ variables are supported: - `WORDPRESS_VERSION` - (defaults to 6.3.1) - `PORT` - (the port to expose wordpress on, defaults to 3000) +**Accessing MariaDB/MySQL** + +First ensure the database you want to inspect (mariadb or mysql) is the one that's currently being used by your local +environment. Then, while the local environment is running in one shell, open another and run the command: + +```bash +docker-compose run mariadb mariadb -h mariadb -u root -p +``` + +Enter `pass` for the password. + +(For mysql, replace instances of "mariadb" in the command with "mysql".) + ## Security Security is a top priority at Matomo. As potential issues are discovered, we validate, patch and release fixes as quickly as we can. We have a security bug bounty program in place that rewards researchers for finding security issues and disclosing them to us. From b28c5677317ae34551fcd5bc471340bb64e20f0d Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 16 Sep 2023 15:39:50 -0700 Subject: [PATCH 30/39] register woocommerce hooks, even if in admin page for plugins that do ajax through admin-ajax.php --- classes/WpMatomo/Ecommerce/Woocommerce.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/classes/WpMatomo/Ecommerce/Woocommerce.php b/classes/WpMatomo/Ecommerce/Woocommerce.php index 43f32cf86..0ec011cdb 100644 --- a/classes/WpMatomo/Ecommerce/Woocommerce.php +++ b/classes/WpMatomo/Ecommerce/Woocommerce.php @@ -24,10 +24,6 @@ class Woocommerce extends Base { private $order_status_ignore = MATOMO_WOOCOMMERCE_IGNORED_ORDER_STATUS; public function register_hooks() { - if ( is_admin() ) { - return; - } - parent::register_hooks(); add_action( 'wp_head', [ $this, 'maybe_track_order_complete' ], 99999 ); @@ -63,10 +59,10 @@ public function anonymise_orderid_in_url( $order_id ) { $order_id = (int) $order_id; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo "