28 | | /* |
29 | | * Don't always link to the menu customizer: |
30 | | * |
31 | | * - Unpublished pages can't be selected by default. |
32 | | * - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities. |
33 | | * - Themes might not "officially" support menus. |
34 | | */ |
| 37 | /* |
| 38 | * Don't always link to the menu customizer: |
| 39 | * |
| 40 | * - Unpublished pages can't be selected by default. |
| 41 | * - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities. |
| 42 | * - Themes might not "officially" support menus. |
| 43 | */ |
115 | | $title = __( 'Privacy Settings' ); |
116 | | $parent_file = 'options-general.php'; |
117 | | |
118 | | require_once ABSPATH . 'wp-admin/admin-header.php'; |
119 | | |
120 | | ?> |
121 | | <div class="wrap"> |
122 | | <h1><?php echo $title; ?></h1> |
123 | | <h2><?php _e( 'Privacy Policy Page' ); ?></h2> |
124 | | <p> |
125 | | <?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.' ); ?> |
126 | | <?php _e( 'If you already have a Privacy Policy page, please select it below. If not, please create one.' ); ?> |
127 | | </p> |
128 | | <p> |
129 | | <?php _e( 'The new page will include help and suggestions for your Privacy Policy.' ); ?> |
130 | | <?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.' ); ?> |
131 | | </p> |
132 | | <p> |
133 | | <?php _e( 'After your Privacy Policy page is set, we suggest that you edit it.' ); ?> |
134 | | <?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.' ); ?> |
135 | | </p> |
136 | | <?php |
137 | | |
138 | | if ( $privacy_policy_page_exists ) { |
148 | | ?> |
149 | | <p class="tools-privacy-edit"><strong> |
150 | | <?php |
151 | | if ( 'publish' === get_post_status( $privacy_policy_page_id ) ) { |
152 | | printf( |
153 | | /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page. */ |
154 | | __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ), |
| 142 | |
| 143 | if ( $create_page ) { |
| 144 | $privacy_page_create_message = sprintf( |
| 145 | /* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page, 3: URL to Customizer -> Menus */ |
| 146 | __( 'You can already <a href="%1$s">edit</a> or <a href="%2$s">preview</a> your Privacy Policy page content. Remember to <a href="%3$s">update your menus</a>!' ), |
| 148 | esc_url( $view_href ), |
| 149 | esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) ) |
| 150 | ); |
| 151 | add_settings_error( 'page_for_privacy_policy', 'page_for_privacy_policy', $privacy_page_create_message, 'success' ); |
| 152 | |
| 153 | } else { |
| 154 | $tools_privacy_edit = ( 'publish' === get_post_status( $privacy_policy_page_id ) ) |
| 155 | ? sprintf( |
| 156 | /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page. */ |
| 157 | __( 'You can already <a href="%1$s">edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ), |
| 158 | esc_url( $edit_href ), |
183 | | <hr> |
184 | | <table class="form-table tools-privacy-policy-page" role="presentation"> |
185 | | <tr> |
186 | | <th scope="row"> |
187 | | <label for="page_for_privacy_policy"> |
188 | | <?php |
189 | | if ( $privacy_policy_page_exists ) { |
190 | | _e( 'Change your Privacy Policy page' ); |
191 | | } else { |
192 | | _e( 'Select a Privacy Policy page' ); |
193 | | } |
194 | | ?> |
195 | | </label> |
196 | | </th> |
197 | | <td> |
198 | | <?php |
199 | | $has_pages = (bool) get_posts( |
200 | | array( |
201 | | 'post_type' => 'page', |
202 | | 'posts_per_page' => 1, |
203 | | 'post_status' => array( |
204 | | 'publish', |
205 | | 'draft', |
206 | | ), |
207 | | ) |
208 | | ); |
| 171 | get_current_screen()->add_help_tab( |
| 172 | array( |
| 173 | 'id' => 'overview', |
| 174 | 'title' => __( 'Overview' ), |
| 175 | 'content' => '<p>' . __( 'This screen contains the settings that help you to set up or affect your privacy policy.' ) . '</p>' . |
| 176 | '<p>' . __( '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.' ) . '</p>', |
| 177 | ) |
| 178 | ); |
210 | | if ( $has_pages ) : |
211 | | ?> |
212 | | <form method="post" action=""> |
213 | | <input type="hidden" name="action" value="set-privacy-page" /> |
214 | | <?php |
215 | | wp_dropdown_pages( |
216 | | array( |
217 | | 'name' => 'page_for_privacy_policy', |
218 | | 'show_option_none' => __( '— Select —' ), |
219 | | 'option_none_value' => '0', |
220 | | 'selected' => $privacy_policy_page_id, |
221 | | 'post_status' => array( 'draft', 'publish' ), |
222 | | ) |
223 | | ); |
| 180 | get_current_screen()->add_help_tab( |
| 181 | array( |
| 182 | 'id' => 'privacy-policy-page', |
| 183 | 'title' => __( 'Policy Page' ), |
| 184 | 'content' => '<p>' . __( 'If you already have a Privacy Policy page, please select it. If not, please create one.' ) . '</p>' . |
| 185 | '<p>' . __( 'The new page will include help and suggestions for your Privacy Policy.' ) . '</p>' . |
| 186 | '<p>' . __( '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.' ) . '</p>' . |
| 187 | '<p>' . __( 'After your Privacy Policy page is set, we suggest that you edit it.' ) . '</p>' . |
| 188 | '<p>' . __( '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.' ) . '</p>', |
| 189 | ) |
| 190 | ); |
225 | | wp_nonce_field( 'set-privacy-page' ); |
| 192 | get_current_screen()->set_help_sidebar( |
| 193 | '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
| 194 | /* translators: 1: Privacy Policy guide URL */ |
| 195 | '<p>' . sprintf( __( '<a href="%1$s">Privacy Policy guide</a>' ), esc_url( admin_url( 'privacy-policy-guide.php' ) ) ) . '</p>' . |
| 196 | '<p>' . __( '<a href="https://wordpress.org/support/article/settings-privacy-screen/">Documentation on Privacy Settings</a>' ) . '</p>' . |
| 197 | '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
| 198 | ); |
246 | | submit_button( __( 'Create New Page' ), 'primary', 'submit', false, array( 'id' => 'create-page' ) ); |
247 | | ?> |
248 | | </form> |
249 | | </td> |
250 | | </tr> |
251 | | </table> |
| 207 | <form method="post" action=""> |
| 208 | <?php settings_fields( 'privacy' ); ?> |
| 209 | |
| 210 | <h2><?php _e( 'Policy Page' ); ?></h2> |
| 211 | <p class="tools-privacy-edit"><?php echo $tools_privacy_edit; ?></p> |
| 212 | |
| 213 | <table class="form-table tools-privacy-policy-page" role="presentation"> |
| 214 | <tr> |
| 215 | <th scope="row"><label for="page_for_privacy_policy"><?php _e( 'Your Privacy Policy page' ); ?></label></th> |
| 216 | <td> |
| 217 | <?php |
| 218 | |
| 219 | $has_pages = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status IN ( 'publish', 'draft' );", 'page' ) ); |
| 220 | |
| 221 | if ( $has_pages ) { |
| 222 | wp_dropdown_pages( |
| 223 | array( |
| 224 | 'name' => 'page_for_privacy_policy', |
| 225 | 'show_option_none' => __( '— Select —' ), |
| 226 | 'option_none_value' => '0', |
| 227 | 'selected' => $privacy_policy_page_id, |
| 228 | 'post_status' => array( 'draft', 'publish' ), |
| 229 | ) |
| 230 | ); |
| 231 | echo '<br /><br />'; |
| 232 | // Allegedly, the admin has already been through the privacy page creation process ! |
| 233 | |
| 234 | $create_privacy_page_text = __( 'Or create a new one : ' ); |
| 235 | $create_privacy_page_text2 = ''; |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | $create_privacy_page_text = __( 'Create page : ' ); |
| 240 | $create_privacy_page_text2 = __( 'Once saved, you will have a link to modify (and publish) your new privacy page' ); |
| 241 | } |
| 242 | ?> |
| 243 | <span id="create_privacy_page"> |
| 244 | <?php echo $create_privacy_page_text; ?> |
| 245 | <input name="create_privacy_page" type="checkbox" value="on" /> |
| 246 | </span> |
| 247 | <?php if ( !empty( $create_privacy_page_text2 ) ) echo '<br />' . $create_privacy_page_text2; ?> |
| 248 | </td> |
| 249 | </tr> |
| 250 | |
| 251 | <?php do_settings_fields( 'privacy', 'default' ); ?> |
| 252 | </table> |
| 253 | |
| 254 | <?php do_settings_sections( 'privacy' ); ?> |
| 255 | |
| 256 | <?php submit_button(); ?> |
| 257 | |
| 258 | </form> |
| 259 | |