From ee645ed9d86509d8f53d6ade64a7aba39947d649 Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 5 May 2026 19:15:13 +0200 Subject: [PATCH 1/5] Added: Privacy Policy suggested content. --- src/Admin/PrivacyPolicy.php | 54 +++++++++++++++++++ src/Plugin.php | 103 ++++++++++++++++++------------------ 2 files changed, 106 insertions(+), 51 deletions(-) create mode 100644 src/Admin/PrivacyPolicy.php diff --git a/src/Admin/PrivacyPolicy.php b/src/Admin/PrivacyPolicy.php new file mode 100644 index 00000000..ecc4e808 --- /dev/null +++ b/src/Admin/PrivacyPolicy.php @@ -0,0 +1,54 @@ +init(); + } + + /** + * Action & filter hooks. + * + * @return void + */ + private function init() { + add_action( 'admin_init', [ $this, 'add_content' ] ); + } + + /** + * The content to add to WP's Privacy Policy page. + * + * @return void + */ + public function add_content() { + if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { + return; + } + + $content = sprintf( + __( "We use Plausible Analytics to collect usage statistics about our website. + +Plausible is a privacy-focused analytics provider that does not use cookies or other persistent identifiers. + +The data collected includes information such as page URLs, referrer, device type, browser and country. + +The data is processed by Plausible Analytics on servers located in the European Union. + +For more details, see Plausible’s data policy: %s", 'plausible-analytics' ), + 'https://plausible.io/data-policy' + ); + + wp_add_privacy_policy_content( 'Example Plugin', wp_kses_post( wpautop( $content, false ) ) ); + } +} diff --git a/src/Plugin.php b/src/Plugin.php index 769e3942..ee5aede8 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -8,6 +8,57 @@ * @since 1.0.0 */ final class Plugin { + /** + * Load @see Integrations() + * + * @return void + * + * @codeCoverageIgnore + */ + public function load_integrations() { + new Integrations(); + } + + /** + * Loads the plugin's translated strings. + * + * @since 1.0.0 + * @access public + * @return void + * + * @codeCoverageIgnore + */ + public function load_plugin_textdomain() { + load_plugin_textdomain( + 'plausible-analytics', + false, + dirname( plugin_basename( PLAUSIBLE_ANALYTICS_PLUGIN_FILE ) ) . '/languages/' + ); + } + + /** + * Load @see Admin\Provisioning() + * + * @return void + * + * @codeCoverageIgnore + */ + public function load_provisioning() { + new Admin\Provisioning(); + new Admin\Provisioning\Integrations(); + } + + /** + * Load @see Admin\Settings\Page() + * + * @return void + * + * @codeCoverageIgnore + */ + public function load_settings() { + new Admin\Settings\Page(); + } + /** * Registers functionality with WordPress hooks. * @@ -51,6 +102,7 @@ public function register_services() { new Admin\Filters(); new Admin\Actions(); new Admin\Module(); + new Admin\PrivacyPolicy(); } add_action( 'init', [ $this, 'load_integrations' ] ); @@ -63,55 +115,4 @@ public function register_services() { new Proxy(); new Verification(); } - - /** - * Load @see Admin\Settings\Page() - * - * @return void - * - * @codeCoverageIgnore - */ - public function load_settings() { - new Admin\Settings\Page(); - } - - /** - * Load @see Admin\Provisioning() - * - * @return void - * - * @codeCoverageIgnore - */ - public function load_provisioning() { - new Admin\Provisioning(); - new Admin\Provisioning\Integrations(); - } - - /** - * Load @see Integrations() - * - * @return void - * - * @codeCoverageIgnore - */ - public function load_integrations() { - new Integrations(); - } - - /** - * Loads the plugin's translated strings. - * - * @since 1.0.0 - * @access public - * @return void - * - * @codeCoverageIgnore - */ - public function load_plugin_textdomain() { - load_plugin_textdomain( - 'plausible-analytics', - false, - dirname( plugin_basename( PLAUSIBLE_ANALYTICS_PLUGIN_FILE ) ) . '/languages/' - ); - } } From d6c07c68a56a3a95bf53c7a4a056b0a1728fe87e Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 5 May 2026 19:15:31 +0200 Subject: [PATCH 2/5] Minor refactor. --- src/Admin/PrivacyPolicy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Admin/PrivacyPolicy.php b/src/Admin/PrivacyPolicy.php index ecc4e808..845d1903 100644 --- a/src/Admin/PrivacyPolicy.php +++ b/src/Admin/PrivacyPolicy.php @@ -23,7 +23,7 @@ public function __construct() { * @return void */ private function init() { - add_action( 'admin_init', [ $this, 'add_content' ] ); + add_action( 'admin_init', [ $this, 'add_suggested_content' ] ); } /** @@ -31,7 +31,7 @@ private function init() { * * @return void */ - public function add_content() { + public function add_suggested_content() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } From d436c29c2b41e263d49fe915418d9f08a25608f5 Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 5 May 2026 19:19:37 +0200 Subject: [PATCH 3/5] Improved content. --- src/Admin/PrivacyPolicy.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Admin/PrivacyPolicy.php b/src/Admin/PrivacyPolicy.php index 845d1903..b5f18f1d 100644 --- a/src/Admin/PrivacyPolicy.php +++ b/src/Admin/PrivacyPolicy.php @@ -36,19 +36,17 @@ public function add_suggested_content() { return; } - $content = sprintf( - __( "We use Plausible Analytics to collect usage statistics about our website. + $content = '

' . __( 'Analytics', 'plausible-analytics' ) . '

'; + $content .= '

' . '' . __( 'Suggested text:', 'plausible-analytics' ) . '

'; + $content .= sprintf( + __( "We use Plausible Analytics to collect usage statistics about our website. Plausible is a privacy-focused analytics provider that does not use cookies or other persistent identifiers. -Plausible is a privacy-focused analytics provider that does not use cookies or other persistent identifiers. - -The data collected includes information such as page URLs, referrer, device type, browser and country. - -The data is processed by Plausible Analytics on servers located in the European Union. +The data collected includes information such as page URLs, referrer, device type, browser and country. The data is processed by Plausible Analytics on servers located in the European Union. For more details, see Plausible’s data policy: %s", 'plausible-analytics' ), 'https://plausible.io/data-policy' ); - wp_add_privacy_policy_content( 'Example Plugin', wp_kses_post( wpautop( $content, false ) ) ); + wp_add_privacy_policy_content( 'Plausible Analytics', wp_kses_post( wpautop( $content, false ) ) ); } } From 96eff52b7b8211083bd1a3a6a3da782fd585b721 Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 5 May 2026 20:38:46 +0200 Subject: [PATCH 4/5] Fixed: Data policy link renders as unclickable plain text; also missing translator comment --- src/Admin/PrivacyPolicy.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Admin/PrivacyPolicy.php b/src/Admin/PrivacyPolicy.php index b5f18f1d..2a61b3c9 100644 --- a/src/Admin/PrivacyPolicy.php +++ b/src/Admin/PrivacyPolicy.php @@ -39,12 +39,13 @@ public function add_suggested_content() { $content = '

' . __( 'Analytics', 'plausible-analytics' ) . '

'; $content .= '

' . '' . __( 'Suggested text:', 'plausible-analytics' ) . '

'; $content .= sprintf( + /* translators: %s: URL to Plausible's data policy page. */ __( "We use Plausible Analytics to collect usage statistics about our website. Plausible is a privacy-focused analytics provider that does not use cookies or other persistent identifiers. The data collected includes information such as page URLs, referrer, device type, browser and country. The data is processed by Plausible Analytics on servers located in the European Union. -For more details, see Plausible’s data policy: %s", 'plausible-analytics' ), - 'https://plausible.io/data-policy' +For more details, see Plausible's data policy: %s", 'plausible-analytics' ), + 'https://plausible.io/data-policy' ); wp_add_privacy_policy_content( 'Plausible Analytics', wp_kses_post( wpautop( $content, false ) ) ); From 1436d1a0c0f4464075902e73d700a31d56445152 Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 5 May 2026 20:39:40 +0200 Subject: [PATCH 5/5] Ignore this code. --- src/Admin/PrivacyPolicy.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Admin/PrivacyPolicy.php b/src/Admin/PrivacyPolicy.php index 2a61b3c9..2b5db0cb 100644 --- a/src/Admin/PrivacyPolicy.php +++ b/src/Admin/PrivacyPolicy.php @@ -30,6 +30,8 @@ private function init() { * The content to add to WP's Privacy Policy page. * * @return void + * + * @codeCoverageIgnore */ public function add_suggested_content() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {