wp/wp-admin/includes/class-wp-privacy-policy-content.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
   118 			$state = 'not-changed';
   118 			$state = 'not-changed';
   119 		}
   119 		}
   120 
   120 
   121 		// Cache the result for use before `admin_init` (see above).
   121 		// Cache the result for use before `admin_init` (see above).
   122 		if ( $cached !== $state ) {
   122 		if ( $cached !== $state ) {
   123 			update_option( '_wp_suggested_policy_text_has_changed', $state );
   123 			update_option( '_wp_suggested_policy_text_has_changed', $state, false );
   124 		}
   124 		}
   125 
   125 
   126 		return 'changed' === $state;
   126 		return 'changed' === $state;
   127 	}
   127 	}
   128 
   128 
   331 
   331 
   332 		if ( 'post' !== $current_screen->base || $policy_page_id !== $post->ID ) {
   332 		if ( 'post' !== $current_screen->base || $policy_page_id !== $post->ID ) {
   333 			return;
   333 			return;
   334 		}
   334 		}
   335 
   335 
   336 		$message = __( 'Need help putting together your new Privacy Policy page? Check out our guide for recommendations on what content to include, along with policies suggested by your plugins and theme.' );
   336 		$message = __( 'Need help putting together your new Privacy Policy page? Check out the guide for recommendations on what content to include, along with policies suggested by your plugins and theme.' );
   337 		$url     = esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) );
   337 		$url     = esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) );
   338 		$label   = __( 'View Privacy Policy Guide.' );
   338 		$label   = __( 'View Privacy Policy Guide.' );
   339 
   339 
   340 		if ( get_current_screen()->is_block_editor() ) {
   340 		if ( get_current_screen()->is_block_editor() ) {
   341 			wp_enqueue_script( 'wp-notices' );
   341 			wp_enqueue_script( 'wp-notices' );
   376 	 * @since 4.9.6
   376 	 * @since 4.9.6
   377 	 */
   377 	 */
   378 	public static function privacy_policy_guide() {
   378 	public static function privacy_policy_guide() {
   379 
   379 
   380 		$content_array = self::get_suggested_policy_text();
   380 		$content_array = self::get_suggested_policy_text();
   381 		$content       = '';
       
   382 		$date_format   = __( 'F j, Y' );
   381 		$date_format   = __( 'F j, Y' );
   383 
   382 
       
   383 		$i = 0;
       
   384 
   384 		foreach ( $content_array as $section ) {
   385 		foreach ( $content_array as $section ) {
   385 			$class   = '';
   386 			++$i;
   386 			$meta    = '';
   387 
   387 			$removed = '';
   388 			$removed = '';
   388 
       
   389 			if ( ! empty( $section['removed'] ) ) {
   389 			if ( ! empty( $section['removed'] ) ) {
   390 				$badge_class = ' red';
   390 				$badge_class = ' red';
   391 				$date        = date_i18n( $date_format, $section['removed'] );
   391 				$date        = date_i18n( $date_format, $section['removed'] );
   392 				/* translators: %s: Date of plugin deactivation. */
   392 				/* translators: %s: Date of plugin deactivation. */
   393 				$badge_title = sprintf( __( 'Removed %s.' ), $date );
   393 				$badge_title = sprintf( __( 'Removed %s.' ), $date );
   407 				/* translators: %s: Date of privacy policy text update. */
   407 				/* translators: %s: Date of privacy policy text update. */
   408 				$badge_title = sprintf( __( 'Updated %s.' ), $date );
   408 				$badge_title = sprintf( __( 'Updated %s.' ), $date );
   409 			}
   409 			}
   410 
   410 
   411 			$plugin_name = esc_html( $section['plugin_name'] );
   411 			$plugin_name = esc_html( $section['plugin_name'] );
   412 
       
   413 			$sanitized_policy_name = sanitize_title_with_dashes( $plugin_name );
       
   414 			?>
   412 			?>
   415 			<h4 class="privacy-settings-accordion-heading">
   413 			<h4 class="privacy-settings-accordion-heading">
   416 			<button aria-expanded="false" class="privacy-settings-accordion-trigger" aria-controls="privacy-settings-accordion-block-<?php echo $sanitized_policy_name; ?>" type="button">
   414 				<button aria-expanded="false" class="privacy-settings-accordion-trigger" aria-controls="privacy-settings-accordion-block-<?php echo $i; ?>" type="button">
   417 				<span class="title"><?php echo $plugin_name; ?></span>
   415 				<span class="title"><?php echo $plugin_name; ?></span>
   418 				<?php if ( ! empty( $section['removed'] ) || ! empty( $section['updated'] ) ) : ?>
   416 				<?php if ( ! empty( $section['removed'] ) || ! empty( $section['updated'] ) ) : ?>
   419 				<span class="badge <?php echo $badge_class; ?>"> <?php echo $badge_title; ?></span>
   417 				<span class="badge <?php echo $badge_class; ?>"> <?php echo $badge_title; ?></span>
   420 				<?php endif; ?>
   418 				<?php endif; ?>
   421 				<span class="icon"></span>
   419 				<span class="icon"></span>
   422 			</button>
   420 			</button>
   423 			</h4>
   421 			</h4>
   424 			<div id="privacy-settings-accordion-block-<?php echo $sanitized_policy_name; ?>" class="privacy-settings-accordion-panel privacy-text-box-body" hidden="hidden">
   422 			<div id="privacy-settings-accordion-block-<?php echo $i; ?>" class="privacy-settings-accordion-panel privacy-text-box-body" hidden="hidden">
   425 				<?php
   423 				<?php
   426 				echo $removed;
   424 				echo $removed;
   427 				echo $section['policy_text'];
   425 				echo $section['policy_text'];
   428 				?>
   426 				?>
   429 				<?php if ( empty( $section['removed'] ) ) : ?>
   427 				<?php if ( empty( $section['removed'] ) ) : ?>