wp/wp-admin/plugin-editor.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    22 
    22 
    23 wp_reset_vars( array( 'action', 'error', 'file', 'plugin' ) );
    23 wp_reset_vars( array( 'action', 'error', 'file', 'plugin' ) );
    24 
    24 
    25 $plugins = get_plugins();
    25 $plugins = get_plugins();
    26 
    26 
    27 if ( empty($plugins) )
    27 if ( empty( $plugins ) ) {
    28 	wp_die( __('There are no plugins installed on this site.') );
    28 	include( ABSPATH . 'wp-admin/admin-header.php' );
       
    29 	?>
       
    30 	<div class="wrap">
       
    31 		<h2><?php echo esc_html( $title ); ?></h2>
       
    32 		<div id="message" class="error"><p><?php _e( 'You do not appear to have any plugins available at this time.' ); ?></p></div>
       
    33 	</div>
       
    34 	<?php
       
    35 	include( ABSPATH . 'wp-admin/admin-footer.php' );
       
    36 	exit;
       
    37 }
    29 
    38 
    30 if ( $file ) {
    39 if ( $file ) {
    31 	$plugin = $file;
    40 	$plugin = $file;
    32 } elseif ( empty( $plugin ) ) {
    41 } elseif ( empty( $plugin ) ) {
    33 	$plugin = array_keys($plugins);
    42 	$plugin = array_keys($plugins);
    71 		wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
    80 		wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
    72 	} else {
    81 	} else {
    73 		wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") );
    82 		wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") );
    74 	}
    83 	}
    75 	exit;
    84 	exit;
    76 
       
    77 break;
       
    78 
    85 
    79 default:
    86 default:
    80 
    87 
    81 	if ( isset($_GET['liveupdate']) ) {
    88 	if ( isset($_GET['liveupdate']) ) {
    82 		check_admin_referer('edit-plugin-test_' . $file);
    89 		check_admin_referer('edit-plugin-test_' . $file);
   121 	'title'		=> __('Overview'),
   128 	'title'		=> __('Overview'),
   122 	'content'	=>
   129 	'content'	=>
   123 		'<p>' . __('You can use the 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>' .
   130 		'<p>' . __('You can use the 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>' .
   124 		'<p>' . __('Choose a plugin to edit from the menu in the upper right 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>' .
   131 		'<p>' . __('Choose a plugin to edit from the menu in the upper right 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>' .
   125 		'<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>' .
   132 		'<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>' .
   126 		'<p id="newcontent-description">' . __('In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key.') . '</p>' .
   133 		'<p id="newcontent-description">' . __( 'In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.' ) . '</p>' .
   127 		'<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>' .
   134 		'<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>' .
   128 		( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' )
   135 		( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' )
   129 	) );
   136 	) );
   130 
   137 
   131 	get_current_screen()->set_help_sidebar(
   138 	get_current_screen()->set_help_sidebar(
   132 		'<p><strong>' . __('For more information:') . '</strong></p>' .
   139 		'<p><strong>' . __('For more information:') . '</strong></p>' .
   133 		'<p>' . __('<a href="http://codex.wordpress.org/Plugins_Editor_Screen" target="_blank">Documentation on Editing Plugins</a>') . '</p>' .
   140 		'<p>' . __('<a href="https://codex.wordpress.org/Plugins_Editor_Screen" target="_blank">Documentation on Editing Plugins</a>') . '</p>' .
   134 		'<p>' . __('<a href="http://codex.wordpress.org/Writing_a_Plugin" target="_blank">Documentation on Writing Plugins</a>') . '</p>' .
   141 		'<p>' . __('<a href="https://codex.wordpress.org/Writing_a_Plugin" target="_blank">Documentation on Writing Plugins</a>') . '</p>' .
   135 		'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   142 		'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   136 	);
   143 	);
   137 
   144 
   138 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   145 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   139 
   146 
   140 	update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
   147 	update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
   155 	}
   162 	}
   156 
   163 
   157 	$content = esc_textarea( $content );
   164 	$content = esc_textarea( $content );
   158 	?>
   165 	?>
   159 <?php if (isset($_GET['a'])) : ?>
   166 <?php if (isset($_GET['a'])) : ?>
   160  <div id="message" class="updated"><p><?php _e('File edited successfully.') ?></p></div>
   167  <div id="message" class="updated notice is-dismissible"><p><?php _e('File edited successfully.') ?></p></div>
   161 <?php elseif (isset($_GET['phperror'])) : ?>
   168 <?php elseif (isset($_GET['phperror'])) : ?>
   162  <div id="message" class="updated"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p>
   169  <div id="message" class="updated"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p>
   163 	<?php
   170 	<?php
   164 		if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?>
   171 		if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?>
   165 	<iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo esc_attr($file); ?>&amp;_wpnonce=<?php echo esc_attr($_GET['_error_nonce']); ?>"></iframe>
   172 	<iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo esc_attr($file); ?>&amp;_wpnonce=<?php echo esc_attr($_GET['_error_nonce']); ?>"></iframe>
   166 	<?php } ?>
   173 	<?php } ?>
   167 </div>
   174 </div>
   168 <?php endif; ?>
   175 <?php endif; ?>
   169 <div class="wrap">
   176 <div class="wrap">
   170 <?php screen_icon(); ?>
       
   171 <h2><?php echo esc_html( $title ); ?></h2>
   177 <h2><?php echo esc_html( $title ); ?></h2>
   172 
   178 
   173 <div class="fileedit-sub">
   179 <div class="fileedit-sub">
   174 <div class="alignleft">
   180 <div class="alignleft">
   175 <big><?php
   181 <big><?php
   254 			submit_button( __( 'Update File' ), 'primary', 'submit', false );
   260 			submit_button( __( 'Update File' ), 'primary', 'submit', false );
   255 		}
   261 		}
   256 	?>
   262 	?>
   257 	</p>
   263 	</p>
   258 <?php else : ?>
   264 <?php else : ?>
   259 	<p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
   265 	<p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="https://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
   260 <?php endif; ?>
   266 <?php endif; ?>
   261 </form>
   267 </form>
   262 <br class="clear" />
   268 <br class="clear" />
   263 </div>
   269 </div>
   264 <script type="text/javascript">
   270 <script type="text/javascript">