Skip to content

Commit c2fc480

Browse files
authored
Merge pull request #299 from plausible/privacy_policy
Added: suggested content for Privacy Policy
2 parents 2db4fc1 + 1436d1a commit c2fc480

2 files changed

Lines changed: 107 additions & 51 deletions

File tree

src/Admin/PrivacyPolicy.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Plausible Analytics | Admin Actions.
4+
*
5+
* @since 2.5.8
6+
* @package WordPress
7+
* @subpackage Plausible Analytics
8+
*/
9+
10+
namespace Plausible\Analytics\WP\Admin;
11+
12+
class PrivacyPolicy {
13+
/**
14+
* Constructor.
15+
*/
16+
public function __construct() {
17+
$this->init();
18+
}
19+
20+
/**
21+
* Action & filter hooks.
22+
*
23+
* @return void
24+
*/
25+
private function init() {
26+
add_action( 'admin_init', [ $this, 'add_suggested_content' ] );
27+
}
28+
29+
/**
30+
* The content to add to WP's Privacy Policy page.
31+
*
32+
* @return void
33+
*
34+
* @codeCoverageIgnore
35+
*/
36+
public function add_suggested_content() {
37+
if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
38+
return;
39+
}
40+
41+
$content = '<h2 class="wp-block-heading">' . __( 'Analytics', 'plausible-analytics' ) . '</h2>';
42+
$content .= '<p>' . '<strong class="privacy-policy-tutorial">' . __( 'Suggested text:', 'plausible-analytics' ) . '</strong></p>';
43+
$content .= sprintf(
44+
/* translators: %s: URL to Plausible's data policy page. */
45+
__( "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.
46+
47+
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.
48+
49+
For more details, see Plausible's data policy: %s", 'plausible-analytics' ),
50+
'<a href="https://plausible.io/data-policy" target="_blank" rel="noopener noreferrer">https://plausible.io/data-policy</a>'
51+
);
52+
53+
wp_add_privacy_policy_content( 'Plausible Analytics', wp_kses_post( wpautop( $content, false ) ) );
54+
}
55+
}

src/Plugin.php

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,57 @@
88
* @since 1.0.0
99
*/
1010
final class Plugin {
11+
/**
12+
* Load @see Integrations()
13+
*
14+
* @return void
15+
*
16+
* @codeCoverageIgnore
17+
*/
18+
public function load_integrations() {
19+
new Integrations();
20+
}
21+
22+
/**
23+
* Loads the plugin's translated strings.
24+
*
25+
* @since 1.0.0
26+
* @access public
27+
* @return void
28+
*
29+
* @codeCoverageIgnore
30+
*/
31+
public function load_plugin_textdomain() {
32+
load_plugin_textdomain(
33+
'plausible-analytics',
34+
false,
35+
dirname( plugin_basename( PLAUSIBLE_ANALYTICS_PLUGIN_FILE ) ) . '/languages/'
36+
);
37+
}
38+
39+
/**
40+
* Load @see Admin\Provisioning()
41+
*
42+
* @return void
43+
*
44+
* @codeCoverageIgnore
45+
*/
46+
public function load_provisioning() {
47+
new Admin\Provisioning();
48+
new Admin\Provisioning\Integrations();
49+
}
50+
51+
/**
52+
* Load @see Admin\Settings\Page()
53+
*
54+
* @return void
55+
*
56+
* @codeCoverageIgnore
57+
*/
58+
public function load_settings() {
59+
new Admin\Settings\Page();
60+
}
61+
1162
/**
1263
* Registers functionality with WordPress hooks.
1364
*
@@ -51,6 +102,7 @@ public function register_services() {
51102
new Admin\Filters();
52103
new Admin\Actions();
53104
new Admin\Module();
105+
new Admin\PrivacyPolicy();
54106
}
55107

56108
add_action( 'init', [ $this, 'load_integrations' ] );
@@ -63,55 +115,4 @@ public function register_services() {
63115
new Proxy();
64116
new Verification();
65117
}
66-
67-
/**
68-
* Load @see Admin\Settings\Page()
69-
*
70-
* @return void
71-
*
72-
* @codeCoverageIgnore
73-
*/
74-
public function load_settings() {
75-
new Admin\Settings\Page();
76-
}
77-
78-
/**
79-
* Load @see Admin\Provisioning()
80-
*
81-
* @return void
82-
*
83-
* @codeCoverageIgnore
84-
*/
85-
public function load_provisioning() {
86-
new Admin\Provisioning();
87-
new Admin\Provisioning\Integrations();
88-
}
89-
90-
/**
91-
* Load @see Integrations()
92-
*
93-
* @return void
94-
*
95-
* @codeCoverageIgnore
96-
*/
97-
public function load_integrations() {
98-
new Integrations();
99-
}
100-
101-
/**
102-
* Loads the plugin's translated strings.
103-
*
104-
* @since 1.0.0
105-
* @access public
106-
* @return void
107-
*
108-
* @codeCoverageIgnore
109-
*/
110-
public function load_plugin_textdomain() {
111-
load_plugin_textdomain(
112-
'plausible-analytics',
113-
false,
114-
dirname( plugin_basename( PLAUSIBLE_ANALYTICS_PLUGIN_FILE ) ) . '/languages/'
115-
);
116-
}
117118
}

0 commit comments

Comments
 (0)