[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Privacy Settings Screen. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once __DIR__ . '/admin.php'; 11 12 if ( ! current_user_can( 'manage_privacy_options' ) ) { 13 wp_die( __( 'Sorry, you are not allowed to manage privacy options on this site.' ) ); 14 } 15 16 if ( isset( $_GET['tab'] ) && 'policyguide' === $_GET['tab'] ) { 17 require_once dirname( __FILE__ ) . '/privacy-policy-guide.php'; 18 return; 19 } 20 21 add_filter( 22 'admin_body_class', 23 static function( $body_class ) { 24 $body_class .= ' privacy-settings '; 25 26 return $body_class; 27 } 28 ); 29 30 $action = isset( $_POST['action'] ) ? $_POST['action'] : ''; 31 32 get_current_screen()->add_help_tab( 33 array( 34 'id' => 'overview', 35 'title' => __( 'Overview' ), 36 'content' => 37 '<p>' . __( 'The Privacy screen lets you either build a new privacy-policy page or choose one you already have to show.' ) . '</p>' . 38 '<p>' . __( 'This screen includes suggestions to help you write your own privacy policy. However, it is your responsibility to use these resources correctly, to provide the information required by your privacy policy, and to keep this information current and accurate.' ) . '</p>', 39 ) 40 ); 41 42 get_current_screen()->set_help_sidebar( 43 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 44 '<p>' . __( '<a href="https://wordpress.org/support/article/settings-privacy-screen/">Documentation on Privacy Settings</a>' ) . '</p>' 45 ); 46 47 if ( ! empty( $action ) ) { 48 check_admin_referer( $action ); 49 50 if ( 'set-privacy-page' === $action ) { 51 $privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0; 52 update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id ); 53 54 $privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' ); 55 56 if ( $privacy_policy_page_id ) { 57 /* 58 * Don't always link to the menu customizer: 59 * 60 * - Unpublished pages can't be selected by default. 61 * - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities. 62 * - Themes might not "officially" support menus. 63 */ 64 if ( 65 'publish' === get_post_status( $privacy_policy_page_id ) 66 && current_user_can( 'edit_theme_options' ) 67 && current_theme_supports( 'menus' ) 68 ) { 69 $privacy_page_updated_message = sprintf( 70 /* translators: %s: URL to Customizer -> Menus. */ 71 __( 'Privacy Policy page setting updated successfully. Remember to <a href="%s">update your menus</a>!' ), 72 esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) ) 73 ); 74 } 75 } 76 77 add_settings_error( 'page_for_privacy_policy', 'page_for_privacy_policy', $privacy_page_updated_message, 'success' ); 78 } elseif ( 'create-privacy-page' === $action ) { 79 80 if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { 81 require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php'; 82 } 83 84 $privacy_policy_page_content = WP_Privacy_Policy_Content::get_default_content(); 85 $privacy_policy_page_id = wp_insert_post( 86 array( 87 'post_title' => __( 'Privacy Policy' ), 88 'post_status' => 'draft', 89 'post_type' => 'page', 90 'post_content' => $privacy_policy_page_content, 91 ), 92 true 93 ); 94 95 if ( is_wp_error( $privacy_policy_page_id ) ) { 96 add_settings_error( 97 'page_for_privacy_policy', 98 'page_for_privacy_policy', 99 __( 'Unable to create a Privacy Policy page.' ), 100 'error' 101 ); 102 } else { 103 update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id ); 104 105 wp_redirect( admin_url( 'post.php?post=' . $privacy_policy_page_id . '&action=edit' ) ); 106 exit; 107 } 108 } 109 } 110 111 // If a Privacy Policy page ID is available, make sure the page actually exists. If not, display an error. 112 $privacy_policy_page_exists = false; 113 $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); 114 115 if ( ! empty( $privacy_policy_page_id ) ) { 116 117 $privacy_policy_page = get_post( $privacy_policy_page_id ); 118 119 if ( ! $privacy_policy_page instanceof WP_Post ) { 120 add_settings_error( 121 'page_for_privacy_policy', 122 'page_for_privacy_policy', 123 __( 'The currently selected Privacy Policy page does not exist. Please create or select a new page.' ), 124 'error' 125 ); 126 } else { 127 if ( 'trash' === $privacy_policy_page->post_status ) { 128 add_settings_error( 129 'page_for_privacy_policy', 130 'page_for_privacy_policy', 131 sprintf( 132 /* translators: %s: URL to Pages Trash. */ 133 __( '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>.' ), 134 'edit.php?post_status=trash&post_type=page' 135 ), 136 'error' 137 ); 138 } else { 139 $privacy_policy_page_exists = true; 140 } 141 } 142 } 143 144 $parent_file = 'options-general.php'; 145 146 wp_enqueue_script( 'privacy-tools' ); 147 148 require_once ABSPATH . 'wp-admin/admin-header.php'; 149 150 ?> 151 <div class="privacy-settings-header"> 152 <div class="privacy-settings-title-section"> 153 <h1> 154 <?php _e( 'Privacy' ); ?> 155 </h1> 156 </div> 157 158 <nav class="privacy-settings-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> 159 <a href="<?php echo esc_url( admin_url( 'options-privacy.php' ) ); ?>" class="privacy-settings-tab active" aria-current="true"> 160 <?php 161 /* translators: Tab heading for Site Health Status page. */ 162 _ex( 'Settings', 'Privacy Settings' ); 163 ?> 164 </a> 165 166 <a href="<?php echo esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) ); ?>" class="privacy-settings-tab"> 167 <?php 168 /* translators: Tab heading for Site Health Status page. */ 169 _ex( 'Policy Guide', 'Privacy Settings' ); 170 ?> 171 </a> 172 </nav> 173 </div> 174 175 <hr class="wp-header-end"> 176 177 <div class="notice notice-error hide-if-js"> 178 <p><?php _e( 'The Privacy Settings require JavaScript.' ); ?></p> 179 </div> 180 181 <div class="privacy-settings-body hide-if-no-js"> 182 <h2><?php _e( 'Privacy Settings' ); ?></h2> 183 <p> 184 <?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.' ); ?> 185 <?php _e( 'If you already have a Privacy Policy page, please select it below. If not, please create one.' ); ?> 186 </p> 187 <p> 188 <?php _e( 'The new page will include help and suggestions for your Privacy Policy.' ); ?> 189 <?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.' ); ?> 190 </p> 191 <p> 192 <?php _e( 'After your Privacy Policy page is set, you should edit it.' ); ?> 193 <?php _e( 'You should also review 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.' ); ?> 194 </p> 195 <p> 196 <?php 197 if ( $privacy_policy_page_exists ) { 198 $edit_href = add_query_arg( 199 array( 200 'post' => $privacy_policy_page_id, 201 'action' => 'edit', 202 ), 203 admin_url( 'post.php' ) 204 ); 205 $view_href = get_permalink( $privacy_policy_page_id ); 206 ?> 207 <strong> 208 <?php 209 if ( 'publish' === get_post_status( $privacy_policy_page_id ) ) { 210 printf( 211 /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page. */ 212 __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ), 213 esc_url( $edit_href ), 214 esc_url( $view_href ) 215 ); 216 } else { 217 printf( 218 /* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page. */ 219 __( '<a href="%1$s">Edit</a> or <a href="%2$s">preview</a> your Privacy Policy page content.' ), 220 esc_url( $edit_href ), 221 esc_url( $view_href ) 222 ); 223 } 224 ?> 225 </strong> 226 <?php 227 } 228 printf( 229 /* translators: 1: Privacy Policy guide URL, 2: Additional link attributes, 3: Accessibility text. */ 230 __( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our Privacy Policy guide%3$s</a> for recommendations on what content to include, along with policies suggested by your plugins and theme.' ), 231 esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) ), 232 '', 233 '' 234 ); 235 ?> 236 </p> 237 <hr> 238 <?php 239 $has_pages = (bool) get_posts( 240 array( 241 'post_type' => 'page', 242 'posts_per_page' => 1, 243 'post_status' => array( 244 'publish', 245 'draft', 246 ), 247 ) 248 ); 249 ?> 250 <table class="form-table tools-privacy-policy-page" role="presentation"> 251 <tr> 252 <th scope="row"> 253 <label for="create-page"> 254 <?php 255 if ( $has_pages ) { 256 _e( 'Create a new Privacy Policy Page' ); 257 } else { 258 _e( 'There are no pages.' ); 259 } 260 ?> 261 </label> 262 </th> 263 <td> 264 <form class="wp-create-privacy-page" method="post" action=""> 265 <input type="hidden" name="action" value="create-privacy-page" /> 266 <?php 267 wp_nonce_field( 'create-privacy-page' ); 268 submit_button( __( 'Create' ), 'secondary', 'submit', false, array( 'id' => 'create-page' ) ); 269 ?> 270 </form> 271 </td> 272 </tr> 273 <?php if ( $has_pages ) : ?> 274 <tr> 275 <th scope="row"> 276 <label for="page_for_privacy_policy"> 277 <?php 278 if ( $privacy_policy_page_exists ) { 279 _e( 'Change your Privacy Policy page' ); 280 } else { 281 _e( 'Select a Privacy Policy page' ); 282 } 283 ?> 284 </label> 285 </th> 286 <td> 287 <form method="post" action=""> 288 <input type="hidden" name="action" value="set-privacy-page" /> 289 <?php 290 wp_dropdown_pages( 291 array( 292 'name' => 'page_for_privacy_policy', 293 'show_option_none' => __( '— Select —' ), 294 'option_none_value' => '0', 295 'selected' => $privacy_policy_page_id, 296 'post_status' => array( 'draft', 'publish' ), 297 ) 298 ); 299 300 wp_nonce_field( 'set-privacy-page' ); 301 302 submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); 303 ?> 304 </form> 305 </td> 306 </tr> 307 <?php endif; ?> 308 </table> 309 </div> 310 <?php 311 312 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Nov 23 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |