wp/wp-admin/tools.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 if ( isset( $_GET['page'] ) && ! empty( $_POST ) ) {
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 	// Ensure POST-ing to `tools.php?page=export_personal_data` and `tools.php?page=remove_personal_data`
    11 
    11 	// continues to work after creating the new files for exporting and erasing of personal data.
    12 $is_privacy_guide = ( isset( $_GET['wp-privacy-policy-guide'] ) && current_user_can( 'manage_privacy_options' ) );
    12 	if ( 'export_personal_data' === $_GET['page'] ) {
    13 
    13 		require_once ABSPATH . 'wp-admin/export-personal-data.php';
    14 if ( $is_privacy_guide ) {
    14 		return;
    15 	$title = __( 'Privacy Policy Guide' );
    15 	} elseif ( 'remove_personal_data' === $_GET['page'] ) {
    16 
    16 		require_once ABSPATH . 'wp-admin/erase-personal-data.php';
    17 	// "Borrow" xfn.js for now so we don't have to create new files.
    17 		return;
    18 	wp_enqueue_script( 'xfn' );
    18 	}
    19 
       
    20 } else {
       
    21 
       
    22 	$title = __( 'Tools' );
       
    23 
       
    24 	get_current_screen()->add_help_tab(
       
    25 		array(
       
    26 			'id'      => 'converter',
       
    27 			'title'   => __( 'Categories and Tags Converter' ),
       
    28 			'content' => '<p>' . __( 'Categories have hierarchy, meaning that you can nest sub-categories. Tags do not have hierarchy and cannot be nested. Sometimes people start out using one on their posts, then later realize that the other would work better for their content.' ) . '</p>' .
       
    29 			'<p>' . __( 'The Categories and Tags Converter link on this screen will take you to the Import screen, where that Converter is one of the plugins you can install. Once that plugin is installed, the Activate Plugin &amp; Run Importer link will take you to a screen where you can choose to convert tags into categories or vice versa.' ) . '</p>',
       
    30 		)
       
    31 	);
       
    32 
       
    33 	get_current_screen()->set_help_sidebar(
       
    34 		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
       
    35 		'<p>' . __( '<a href="https://codex.wordpress.org/Tools_Screen">Documentation on Tools</a>' ) . '</p>' .
       
    36 		'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
       
    37 	);
       
    38 }
    19 }
    39 
    20 
    40 require_once( ABSPATH . 'wp-admin/admin-header.php' );
    21 // The privacy policy guide used to be outputted from here. Since WP 5.3 it is in wp-admin/privacy-policy-guide.php.
       
    22 if ( isset( $_GET['wp-privacy-policy-guide'] ) ) {
       
    23 	require_once dirname( __DIR__ ) . '/wp-load.php';
       
    24 	wp_redirect( admin_url( 'privacy-policy-guide.php' ), 301 );
       
    25 	exit;
       
    26 } elseif ( isset( $_GET['page'] ) ) {
       
    27 	// These were also moved to files in WP 5.3.
       
    28 	if ( 'export_personal_data' === $_GET['page'] ) {
       
    29 		require_once dirname( __DIR__ ) . '/wp-load.php';
       
    30 		wp_redirect( admin_url( 'export-personal-data.php' ), 301 );
       
    31 		exit;
       
    32 	} elseif ( 'remove_personal_data' === $_GET['page'] ) {
       
    33 		require_once dirname( __DIR__ ) . '/wp-load.php';
       
    34 		wp_redirect( admin_url( 'erase-personal-data.php' ), 301 );
       
    35 		exit;
       
    36 	}
       
    37 }
       
    38 
       
    39 /** WordPress Administration Bootstrap */
       
    40 require_once __DIR__ . '/admin.php';
       
    41 
       
    42 $title = __( 'Tools' );
       
    43 
       
    44 get_current_screen()->add_help_tab(
       
    45 	array(
       
    46 		'id'      => 'converter',
       
    47 		'title'   => __( 'Categories and Tags Converter' ),
       
    48 		'content' => '<p>' . __( 'Categories have hierarchy, meaning that you can nest sub-categories. Tags do not have hierarchy and cannot be nested. Sometimes people start out using one on their posts, then later realize that the other would work better for their content.' ) . '</p>' .
       
    49 		'<p>' . __( 'The Categories and Tags Converter link on this screen will take you to the Import screen, where that Converter is one of the plugins you can install. Once that plugin is installed, the Activate Plugin &amp; Run Importer link will take you to a screen where you can choose to convert tags into categories or vice versa.' ) . '</p>',
       
    50 	)
       
    51 );
       
    52 
       
    53 get_current_screen()->set_help_sidebar(
       
    54 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
       
    55 	'<p>' . __( '<a href="https://wordpress.org/support/article/tools-screen/">Documentation on Tools</a>' ) . '</p>' .
       
    56 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
       
    57 );
       
    58 
       
    59 require_once ABSPATH . 'wp-admin/admin-header.php';
    41 
    60 
    42 ?>
    61 ?>
    43 <div class="wrap">
    62 <div class="wrap">
    44 <h1><?php echo esc_html( $title ); ?></h1>
    63 <h1><?php echo esc_html( $title ); ?></h1>
    45 <?php
    64 <?php
    46 
    65 
    47 if ( $is_privacy_guide ) {
    66 if ( current_user_can( 'import' ) ) :
    48 	?>
    67 	$cats = get_taxonomy( 'category' );
    49 	<div class="wp-privacy-policy-guide">
    68 	$tags = get_taxonomy( 'post_tag' );
    50 		<?php WP_Privacy_Policy_Content::privacy_policy_guide(); ?>
    69 	if ( current_user_can( $cats->cap->manage_terms ) || current_user_can( $tags->cap->manage_terms ) ) :
    51 	</div>
    70 		?>
    52 	<?php
    71 		<div class="card">
       
    72 			<h2 class="title"><?php _e( 'Categories and Tags Converter' ); ?></h2>
       
    73 			<p>
       
    74 			<?php
       
    75 				printf(
       
    76 					/* translators: %s: URL to Import screen. */
       
    77 					__( 'If you want to convert your categories to tags (or vice versa), use the <a href="%s">Categories and Tags Converter</a> available from the Import screen.' ),
       
    78 					'import.php'
       
    79 				);
       
    80 			?>
       
    81 			</p>
       
    82 		</div>
       
    83 		<?php
       
    84 	endif;
       
    85 endif;
    53 
    86 
    54 } else {
    87 /**
       
    88  * Fires at the end of the Tools Administration screen.
       
    89  *
       
    90  * @since 2.8.0
       
    91  */
       
    92 do_action( 'tool_box' );
    55 
    93 
    56 	if ( current_user_can( 'import' ) ) :
       
    57 		$cats = get_taxonomy( 'category' );
       
    58 		$tags = get_taxonomy( 'post_tag' );
       
    59 		if ( current_user_can( $cats->cap->manage_terms ) || current_user_can( $tags->cap->manage_terms ) ) :
       
    60 			?>
       
    61 	<div class="card">
       
    62 		<h2 class="title"><?php _e( 'Categories and Tags Converter' ); ?></h2>
       
    63 		<p><?php printf( __( 'If you want to convert your categories to tags (or vice versa), use the <a href="%s">Categories and Tags Converter</a> available from the Import screen.' ), 'import.php' ); ?></p>
       
    64 	</div>
       
    65 			<?php
       
    66 	endif;
       
    67 	endif;
       
    68 
       
    69 	/**
       
    70 	 * Fires at the end of the Tools Administration screen.
       
    71 	 *
       
    72 	 * @since 2.8.0
       
    73 	 */
       
    74 	do_action( 'tool_box' );
       
    75 }
       
    76 ?>
    94 ?>
    77 </div>
    95 </div>
    78 <?php
    96 <?php
    79 include( ABSPATH . 'wp-admin/admin-footer.php' );
    97 
       
    98 require_once ABSPATH . 'wp-admin/admin-footer.php';