mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-08 16:41:44 +01:00
Die on file error. Cleanup. Props hakre. fixes #9452
git-svn-id: http://svn.automattic.com/wordpress/trunk@11214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c0f2a493ee
commit
d3ef269013
@ -85,29 +85,27 @@ default:
|
|||||||
|
|
||||||
wp_enqueue_script( 'codepress' );
|
wp_enqueue_script( 'codepress' );
|
||||||
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
|
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
|
||||||
require_once('admin-header.php');
|
|
||||||
|
|
||||||
update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
|
|
||||||
|
|
||||||
// List of allowable extensions
|
// List of allowable extensions
|
||||||
$editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
|
$editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
|
||||||
$extra_extensions = apply_filters('editable_extensions', null);
|
$editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions);
|
||||||
if ( is_array($extra_extensions) )
|
|
||||||
$editable_extensions = array_merge($editable_extensions, $extra_extensions);
|
|
||||||
|
|
||||||
if ( ! is_file($real_file) ) {
|
if ( ! is_file($real_file) ) {
|
||||||
$error = __('No such file exists! Double check the name and try again.');
|
wp_die(sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));
|
||||||
} else {
|
} else {
|
||||||
// Get the extension of the file
|
// Get the extension of the file
|
||||||
if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) {
|
if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) {
|
||||||
$ext = strtolower($matches[1]);
|
$ext = strtolower($matches[1]);
|
||||||
// If extension is not in the acceptable list, skip it
|
// If extension is not in the acceptable list, skip it
|
||||||
if ( !in_array( $ext, $editable_extensions) )
|
if ( !in_array( $ext, $editable_extensions) )
|
||||||
$error = __('Files of this type are not editable.');
|
wp_die(sprintf('<p>%s</p>', __('Files of this type are not editable.')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $error ) {
|
require_once('admin-header.php');
|
||||||
|
|
||||||
|
update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
|
||||||
|
|
||||||
$content = file_get_contents( $real_file );
|
$content = file_get_contents( $real_file );
|
||||||
|
|
||||||
if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) {
|
if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) {
|
||||||
@ -123,7 +121,6 @@ default:
|
|||||||
|
|
||||||
$content = htmlspecialchars( $content );
|
$content = htmlspecialchars( $content );
|
||||||
$codepress_lang = codepress_get_lang($real_file);
|
$codepress_lang = codepress_get_lang($real_file);
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?php if (isset($_GET['a'])) : ?>
|
<?php if (isset($_GET['a'])) : ?>
|
||||||
@ -141,7 +138,7 @@ default:
|
|||||||
<h2><?php echo wp_specialchars( $title ); ?></h2>
|
<h2><?php echo wp_specialchars( $title ); ?></h2>
|
||||||
<div class="bordertitle">
|
<div class="bordertitle">
|
||||||
<form id="themeselector" action="plugin-editor.php" method="post">
|
<form id="themeselector" action="plugin-editor.php" method="post">
|
||||||
<strong><label for="theme"><?php _e('Select plugin to edit:'); ?> </label></strong>
|
<strong><label for="plugin"><?php _e('Select plugin to edit:'); ?> </label></strong>
|
||||||
<select name="plugin" id="plugin">
|
<select name="plugin" id="plugin">
|
||||||
<?php
|
<?php
|
||||||
foreach ( $plugins as $plugin_key => $a_plugin ) {
|
foreach ( $plugins as $plugin_key => $a_plugin ) {
|
||||||
@ -195,11 +192,10 @@ foreach ( $plugin_files as $plugin_file ) :
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li>
|
<li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<?php if ( ! $error ) { ?>
|
|
||||||
<form name="template" id="template" action="plugin-editor.php" method="post">
|
<form name="template" id="template" action="plugin-editor.php" method="post">
|
||||||
<?php wp_nonce_field('edit-plugin_' . $file) ?>
|
<?php wp_nonce_field('edit-plugin_' . $file) ?>
|
||||||
<div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress <?php echo $codepress_lang ?>"><?php echo $content ?></textarea>
|
<div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress <?php echo $codepress_lang ?>"><?php echo $content ?></textarea>
|
||||||
@ -208,7 +204,7 @@ foreach ( $plugin_files as $plugin_file ) :
|
|||||||
<input type="hidden" name="plugin" value="<?php echo esc_attr($plugin) ?>" />
|
<input type="hidden" name="plugin" value="<?php echo esc_attr($plugin) ?>" />
|
||||||
</div>
|
</div>
|
||||||
<?php if ( count( $functions ) ) : ?>
|
<?php if ( count( $functions ) ) : ?>
|
||||||
<div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" /></div>
|
<div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" /></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ( is_writeable($real_file) ) : ?>
|
<?php if ( is_writeable($real_file) ) : ?>
|
||||||
<?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
|
<?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
|
||||||
@ -226,11 +222,6 @@ foreach ( $plugin_files as $plugin_file ) :
|
|||||||
<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>
|
<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>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
|
||||||
} else {
|
|
||||||
echo '<div class="error"><p>' . $error . '</p></div>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="clear"> </div>
|
<div class="clear"> </div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
Loading…
Reference in New Issue
Block a user