From d3ef2690131ce24051d623d00f66bb6fbb951575 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 6 May 2009 04:08:13 +0000 Subject: [PATCH] Die on file error. Cleanup. Props hakre. fixes #9452 git-svn-id: http://svn.automattic.com/wordpress/trunk@11214 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/plugin-editor.php | 55 ++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index 64959e34c..14e88f9ae 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -84,47 +84,44 @@ default: } wp_enqueue_script( 'codepress' ); - add_action( 'admin_print_footer_scripts', 'codepress_footer_js' ); - require_once('admin-header.php'); - - update_recently_edited(WP_PLUGIN_DIR . '/' . $file); - + add_action( 'admin_print_footer_scripts', 'codepress_footer_js' ); + // List of allowable extensions $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include'); - $extra_extensions = apply_filters('editable_extensions', null); - if ( is_array($extra_extensions) ) - $editable_extensions = array_merge($editable_extensions, $extra_extensions); + $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions); if ( ! is_file($real_file) ) { - $error = __('No such file exists! Double check the name and try again.'); + wp_die(sprintf('

%s

', __('No such file exists! Double check the name and try again.'))); } else { // Get the extension of the file if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) { $ext = strtolower($matches[1]); // If extension is not in the acceptable list, skip it if ( !in_array( $ext, $editable_extensions) ) - $error = __('Files of this type are not editable.'); + wp_die(sprintf('

%s

', __('Files of this type are not editable.'))); } } + + require_once('admin-header.php'); + + update_recently_edited(WP_PLUGIN_DIR . '/' . $file); - if ( ! $error ) { - $content = file_get_contents( $real_file ); + $content = file_get_contents( $real_file ); - if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { - $functions = wp_doc_link_parse( $content ); + if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { + $functions = wp_doc_link_parse( $content ); - $docs_select = ''; + $docs_select = ''; } + $content = htmlspecialchars( $content ); + $codepress_lang = codepress_get_lang($real_file); + ?>

@@ -141,7 +138,7 @@ default:

- + @@ -208,7 +204,7 @@ foreach ( $plugin_files as $plugin_file ) :
-
+
@@ -226,11 +222,6 @@ foreach ( $plugin_files as $plugin_file ) :

the Codex for more information.'); ?>

-

' . $error . '

'; - } -?>