wp/wp-admin/plugin-editor.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Edit plugin editor administration panel.
     3  * Edit plugin file editor administration panel.
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
    16 
    16 
    17 if ( ! current_user_can( 'edit_plugins' ) ) {
    17 if ( ! current_user_can( 'edit_plugins' ) ) {
    18 	wp_die( __( 'Sorry, you are not allowed to edit plugins for this site.' ) );
    18 	wp_die( __( 'Sorry, you are not allowed to edit plugins for this site.' ) );
    19 }
    19 }
    20 
    20 
       
    21 // Used in the HTML title tag.
    21 $title       = __( 'Edit Plugins' );
    22 $title       = __( 'Edit Plugins' );
    22 $parent_file = 'plugins.php';
    23 $parent_file = 'plugins.php';
    23 
    24 
    24 $plugins = get_plugins();
    25 $plugins = get_plugins();
    25 
    26 
   121 get_current_screen()->add_help_tab(
   122 get_current_screen()->add_help_tab(
   122 	array(
   123 	array(
   123 		'id'      => 'overview',
   124 		'id'      => 'overview',
   124 		'title'   => __( 'Overview' ),
   125 		'title'   => __( 'Overview' ),
   125 		'content' =>
   126 		'content' =>
   126 				'<p>' . __( 'You can use the plugin editor to make changes to any of your plugins&#8217; individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.' ) . '</p>' .
   127 				'<p>' . __( 'You can use the plugin file editor to make changes to any of your plugins&#8217; individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.' ) . '</p>' .
   127 				'<p>' . __( 'Choose a plugin to edit from the dropdown menu and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don&#8217;t forget to save your changes (Update File) when you&#8217;re finished.' ) . '</p>' .
   128 				'<p>' . __( 'Choose a plugin to edit from the dropdown menu and click the Select button. Click once on any file name to load it in the editor, and make your changes. Do not forget to save your changes (Update File) when you are finished.' ) . '</p>' .
   128 				'<p>' . __( 'The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Look Up takes you to a web page about that particular function.' ) . '</p>' .
   129 				'<p>' . __( 'The documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Look Up takes you to a web page about that particular function.' ) . '</p>' .
   129 				'<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' .
   130 				'<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' .
   130 				'<ul>' .
   131 				'<ul>' .
   131 				'<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>' .
   132 				'<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>' .
   132 				'<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>' .
   133 				'<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>' .
   133 				'<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>' .
   134 				'<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>' .
   134 				'</ul>' .
   135 				'</ul>' .
   135 				'<p>' . __( 'If you want to make changes but don&#8217;t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.' ) . '</p>' .
   136 				'<p>' . __( 'If you want to make changes but do not want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.' ) . '</p>' .
   136 				( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ),
   137 				( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ),
   137 	)
   138 	)
   138 );
   139 );
   139 
   140 
   140 get_current_screen()->set_help_sidebar(
   141 get_current_screen()->set_help_sidebar(
   309 	// Get a back URL.
   310 	// Get a back URL.
   310 	$referer = wp_get_referer();
   311 	$referer = wp_get_referer();
   311 
   312 
   312 	$excluded_referer_basenames = array( 'plugin-editor.php', 'wp-login.php' );
   313 	$excluded_referer_basenames = array( 'plugin-editor.php', 'wp-login.php' );
   313 
   314 
   314 	if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
   315 	$return_url = admin_url( '/' );
   315 		$return_url = $referer;
   316 	if ( $referer ) {
   316 	} else {
   317 		$referer_path = parse_url( $referer, PHP_URL_PATH );
   317 		$return_url = admin_url( '/' );
   318 		if ( is_string( $referer_path ) && ! in_array( basename( $referer_path ), $excluded_referer_basenames, true ) ) {
       
   319 			$return_url = $referer;
       
   320 		}
   318 	}
   321 	}
   319 	?>
   322 	?>
   320 	<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden">
   323 	<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden">
   321 		<div class="notification-dialog-background"></div>
   324 		<div class="notification-dialog-background"></div>
   322 		<div class="notification-dialog">
   325 		<div class="notification-dialog">
   323 			<div class="file-editor-warning-content">
   326 			<div class="file-editor-warning-content">
   324 				<div class="file-editor-warning-message">
   327 				<div class="file-editor-warning-message">
   325 					<h1><?php _e( 'Heads up!' ); ?></h1>
   328 					<h1><?php _e( 'Heads up!' ); ?></h1>
   326 					<p><?php _e( 'You appear to be making direct edits to your plugin in the WordPress dashboard. We recommend that you don&#8217;t! Editing plugins directly may introduce incompatibilities that break your site and your changes may be lost in future updates.' ); ?></p>
   329 					<p><?php _e( 'You appear to be making direct edits to your plugin in the WordPress dashboard. Editing plugins directly is not recommended as it may introduce incompatibilities that break your site and your changes may be lost in future updates.' ); ?></p>
   327 					<p><?php _e( 'If you absolutely have to make direct edits to this plugin, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p>
   330 					<p><?php _e( 'If you absolutely have to make direct edits to this plugin, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p>
   328 				</div>
   331 				</div>
   329 				<p>
   332 				<p>
   330 					<a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a>
   333 					<a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a>
   331 					<button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button>
   334 					<button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button>