1 <?php |
1 <?php |
2 /** |
2 /** |
3 * Privacy Settings Screen. |
3 * Privacy administration panel. |
4 * |
4 * |
5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
9 /** WordPress Administration Bootstrap */ |
9 /** WordPress Administration Bootstrap */ |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
10 require_once __DIR__ . '/admin.php'; |
11 |
11 |
12 if ( ! current_user_can( 'manage_privacy_options' ) ) { |
12 $title = __( 'Privacy' ); |
13 wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) ); |
|
14 } |
|
15 |
13 |
16 $action = isset( $_POST['action'] ) ? $_POST['action'] : ''; |
14 list( $display_version ) = explode( '-', get_bloginfo( 'version' ) ); |
17 |
15 |
18 if ( ! empty( $action ) ) { |
16 require_once ABSPATH . 'wp-admin/admin-header.php'; |
19 check_admin_referer( $action ); |
17 ?> |
|
18 <div class="wrap about__container"> |
20 |
19 |
21 if ( 'set-privacy-page' === $action ) { |
20 <div class="about__header"> |
22 $privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0; |
21 <div class="about__header-text"> |
23 update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id ); |
22 <?php _e( 'Speed. Search. Security.' ); ?> |
|
23 </div> |
24 |
24 |
25 $privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' ); |
25 <div class="about__header-title"> |
|
26 <p> |
|
27 <?php _e( 'WordPress' ); ?> |
|
28 <span><?php echo $display_version; ?></span> |
|
29 </p> |
|
30 </div> |
26 |
31 |
27 if ( $privacy_policy_page_id ) { |
32 <nav class="about__header-navigation nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> |
28 /* |
33 <a href="about.php" class="nav-tab"><?php _e( 'What’s New' ); ?></a> |
29 * Don't always link to the menu customizer: |
34 <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a> |
30 * |
35 <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a> |
31 * - Unpublished pages can't be selected by default. |
36 <a href="privacy.php" class="nav-tab nav-tab-active" aria-current="page"><?php _e( 'Privacy' ); ?></a> |
32 * - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities. |
37 </nav> |
33 * - Themes might not "officially" support menus. |
38 </div> |
34 */ |
39 |
35 if ( |
40 <div class="about__section"> |
36 'publish' === get_post_status( $privacy_policy_page_id ) |
41 <div class="column"> |
37 && current_user_can( 'edit_theme_options' ) |
42 <h1><?php _e( 'Privacy' ); ?></h1> |
38 && current_theme_supports( 'menus' ) |
43 |
39 ) { |
44 <p><?php _e( 'From time to time, your WordPress site may send data to WordPress.org — including, but not limited to — the version of WordPress you are using, and a list of installed plugins and themes.' ); ?></p> |
40 $privacy_page_updated_message = sprintf( |
45 |
41 /* translators: %s: URL to Customizer -> Menus */ |
46 <p> |
42 __( 'Privacy Policy page setting updated successfully. Remember to <a href="%s">update your menus</a>!' ), |
47 <?php |
43 esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) ) |
48 printf( |
|
49 /* translators: %s: https://wordpress.org/about/stats/ */ |
|
50 __( 'This data is used to provide general enhancements to WordPress, which includes helping to protect your site by finding and automatically installing new updates. It is also used to calculate statistics, such as those shown on the <a href="%s">WordPress.org stats page</a>.' ), |
|
51 __( 'https://wordpress.org/about/stats/' ) |
44 ); |
52 ); |
45 } |
53 ?> |
46 } |
54 </p> |
47 |
55 |
48 add_settings_error( |
56 <p> |
49 'page_for_privacy_policy', |
57 <?php |
50 'page_for_privacy_policy', |
58 printf( |
51 $privacy_page_updated_message, |
59 /* translators: %s: https://wordpress.org/about/privacy/ */ |
52 'updated' |
60 __( 'We take privacy and transparency very seriously. To learn more about what data we collect, and how we use it, please visit <a href="%s">WordPress.org/about/privacy</a>.' ), |
53 ); |
61 __( 'https://wordpress.org/about/privacy/' ) |
54 } elseif ( 'create-privacy-page' === $action ) { |
62 ); |
|
63 ?> |
|
64 </p> |
|
65 </div> |
|
66 </div> |
55 |
67 |
56 if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { |
|
57 require_once( ABSPATH . 'wp-admin/includes/misc.php' ); |
|
58 } |
|
59 |
|
60 $privacy_policy_page_content = WP_Privacy_Policy_Content::get_default_content(); |
|
61 $privacy_policy_page_id = wp_insert_post( |
|
62 array( |
|
63 'post_title' => __( 'Privacy Policy' ), |
|
64 'post_status' => 'draft', |
|
65 'post_type' => 'page', |
|
66 'post_content' => $privacy_policy_page_content, |
|
67 ), |
|
68 true |
|
69 ); |
|
70 |
|
71 if ( is_wp_error( $privacy_policy_page_id ) ) { |
|
72 add_settings_error( |
|
73 'page_for_privacy_policy', |
|
74 'page_for_privacy_policy', |
|
75 __( 'Unable to create a Privacy Policy page.' ), |
|
76 'error' |
|
77 ); |
|
78 } else { |
|
79 update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id ); |
|
80 |
|
81 wp_redirect( admin_url( 'post.php?post=' . $privacy_policy_page_id . '&action=edit' ) ); |
|
82 exit; |
|
83 } |
|
84 } |
|
85 } |
|
86 |
|
87 // If a Privacy Policy page ID is available, make sure the page actually exists. If not, display an error. |
|
88 $privacy_policy_page_exists = false; |
|
89 $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); |
|
90 |
|
91 if ( ! empty( $privacy_policy_page_id ) ) { |
|
92 |
|
93 $privacy_policy_page = get_post( $privacy_policy_page_id ); |
|
94 |
|
95 if ( ! $privacy_policy_page instanceof WP_Post ) { |
|
96 add_settings_error( |
|
97 'page_for_privacy_policy', |
|
98 'page_for_privacy_policy', |
|
99 __( 'The currently selected Privacy Policy page does not exist. Please create or select a new page.' ), |
|
100 'error' |
|
101 ); |
|
102 } else { |
|
103 if ( 'trash' === $privacy_policy_page->post_status ) { |
|
104 add_settings_error( |
|
105 'page_for_privacy_policy', |
|
106 'page_for_privacy_policy', |
|
107 sprintf( |
|
108 /* translators: URL to Pages Trash */ |
|
109 __( 'The currently selected Privacy Policy page is in the trash. Please create or select a new Privacy Policy page or <a href="%s">restore the current page</a>.' ), |
|
110 'edit.php?post_status=trash&post_type=page' |
|
111 ), |
|
112 'error' |
|
113 ); |
|
114 } else { |
|
115 $privacy_policy_page_exists = true; |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 $title = __( 'Privacy Settings' ); |
|
121 $parent_file = 'options-general.php'; |
|
122 |
|
123 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
124 |
|
125 ?> |
|
126 <div class="wrap"> |
|
127 <h1><?php echo $title; ?></h1> |
|
128 <h2><?php _e( 'Privacy Policy page' ); ?></h2> |
|
129 <p> |
|
130 <?php _e( 'As a website owner, you may need to follow national or international privacy laws. For example, you may need to create and display a Privacy Policy.' ); ?> |
|
131 <?php _e( 'If you already have a Privacy Policy page, please select it below. If not, please create one.' ); ?> |
|
132 </p> |
|
133 <p> |
|
134 <?php _e( 'The new page will include help and suggestions for your Privacy Policy.' ); ?> |
|
135 <?php _e( 'However, it is your responsibility to use those resources correctly, to provide the information that your Privacy Policy requires, and to keep that information current and accurate.' ); ?> |
|
136 </p> |
|
137 <p> |
|
138 <?php _e( 'After your Privacy Policy page is set, we suggest that you edit it.' ); ?> |
|
139 <?php _e( 'We would also suggest reviewing your Privacy Policy from time to time, especially after installing or updating any themes or plugins. There may be changes or new suggested information for you to consider adding to your policy.' ); ?> |
|
140 </p> |
|
141 <?php |
|
142 |
|
143 if ( $privacy_policy_page_exists ) { |
|
144 $edit_href = add_query_arg( |
|
145 array( |
|
146 'post' => $privacy_policy_page_id, |
|
147 'action' => 'edit', |
|
148 ), |
|
149 admin_url( 'post.php' ) |
|
150 ); |
|
151 |
|
152 $view_href = get_permalink( $privacy_policy_page_id ); |
|
153 |
|
154 ?> |
|
155 <p class="tools-privacy-edit"><strong> |
|
156 <?php |
|
157 |
|
158 if ( 'publish' === get_post_status( $privacy_policy_page_id ) ) { |
|
159 printf( |
|
160 /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page */ |
|
161 __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ), |
|
162 esc_url( $edit_href ), |
|
163 esc_url( $view_href ) |
|
164 ); |
|
165 } else { |
|
166 printf( |
|
167 /* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page */ |
|
168 __( '<a href="%1$s">Edit</a> or <a href="%2$s">preview</a> your Privacy Policy page content.' ), |
|
169 esc_url( $edit_href ), |
|
170 esc_url( $view_href ) |
|
171 ); |
|
172 } |
|
173 |
|
174 ?> |
|
175 </strong></p> |
|
176 <?php |
|
177 } |
|
178 ?> |
|
179 <p> |
|
180 <?php |
|
181 |
|
182 printf( |
|
183 /* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: accessibility text */ |
|
184 __( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our guide%3$s</a> for recommendations on what content to include, along with policies suggested by your plugins and theme.' ), |
|
185 esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) ), |
|
186 '', |
|
187 '' |
|
188 ); |
|
189 |
|
190 ?> |
|
191 </p> |
|
192 |
|
193 <hr> |
|
194 <table class="form-table tools-privacy-policy-page" role="presentation"> |
|
195 <tr> |
|
196 <th scope="row"><label for="page_for_privacy_policy"> |
|
197 <?php |
|
198 if ( $privacy_policy_page_exists ) { |
|
199 _e( 'Change your Privacy Policy page' ); |
|
200 } else { |
|
201 _e( 'Select a Privacy Policy page' ); |
|
202 } |
|
203 ?> |
|
204 </label></th> |
|
205 <td> |
|
206 <?php |
|
207 $has_pages = (bool) get_posts( |
|
208 array( |
|
209 'post_type' => 'page', |
|
210 'posts_per_page' => 1, |
|
211 'post_status' => array( |
|
212 'publish', |
|
213 'draft', |
|
214 ), |
|
215 ) |
|
216 ); |
|
217 |
|
218 if ( $has_pages ) : |
|
219 ?> |
|
220 <form method="post" action=""> |
|
221 <input type="hidden" name="action" value="set-privacy-page" /> |
|
222 <?php |
|
223 wp_dropdown_pages( |
|
224 array( |
|
225 'name' => 'page_for_privacy_policy', |
|
226 'show_option_none' => __( '— Select —' ), |
|
227 'option_none_value' => '0', |
|
228 'selected' => $privacy_policy_page_id, |
|
229 'post_status' => array( 'draft', 'publish' ), |
|
230 ) |
|
231 ); |
|
232 |
|
233 wp_nonce_field( 'set-privacy-page' ); |
|
234 |
|
235 submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); |
|
236 ?> |
|
237 </form> |
|
238 <?php endif; ?> |
|
239 |
|
240 <form class="wp-create-privacy-page" method="post" action=""> |
|
241 <input type="hidden" name="action" value="create-privacy-page" /> |
|
242 <span> |
|
243 <?php |
|
244 if ( $has_pages ) { |
|
245 _e( 'Or:' ); |
|
246 } else { |
|
247 _e( 'There are no pages.' ); |
|
248 } |
|
249 ?> |
|
250 </span> |
|
251 <?php |
|
252 wp_nonce_field( 'create-privacy-page' ); |
|
253 |
|
254 submit_button( __( 'Create New Page' ), 'primary', 'submit', false, array( 'id' => 'create-page' ) ); |
|
255 ?> |
|
256 </form> |
|
257 </td> |
|
258 </tr> |
|
259 </table> |
|
260 </div> |
68 </div> |
261 <?php |
69 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?> |
262 |
|
263 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|