X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/449d082fcc4873c1f7d363a0d9f7409be7f6e77d..672d6bc6da735e745275ef7a86341dc1178da8d2:/wp-admin/plugin-editor.php diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index b807de89..8b1602c3 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -12,20 +12,29 @@ require_once('admin.php'); $title = __("Edit Plugins"); $parent_file = 'plugins.php'; -wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); +wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'plugin')); wp_admin_css( 'theme-editor' ); $plugins = get_plugins(); -$plugin_files = array_keys($plugins); -if (empty($file)) +if ( isset($_REQUEST['file']) ) + $plugin = $_REQUEST['file']; + +if ( empty($plugin) ) { + $plugin = array_keys($plugins); + $plugin = $plugin[0]; +} + +$plugin_files = get_plugin_files($plugin); + +if ( empty($file) ) $file = $plugin_files[0]; $file = validate_file_to_edit($file, $plugin_files); $real_file = WP_PLUGIN_DIR . '/' . $file; -switch($action) { +switch ( $action ) { case 'update': @@ -64,25 +73,53 @@ default: check_admin_referer('edit-plugin-test_' . $file); $error = validate_plugin($file); - if( is_wp_error($error) ) + if ( is_wp_error($error) ) wp_die( $error ); if ( ! is_plugin_active($file) ) - activate_plugin($file, "plugin-editor.php?file=$file&phperror=1");// we'll override this later if the plugin can be included without fatal error + activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error wp_redirect("plugin-editor.php?file=$file&a=te"); exit; } + // List of allowable extensions + $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include'); + $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions); + + if ( ! is_file($real_file) ) { + 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) ) + wp_die(sprintf('

%s

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

fatal error.') ?>

- +
-

+

-
+
%s (active)'), $file); else @@ -115,26 +152,60 @@ default: } ?>
-
+
+
+ + + +

-
-

+
+ +
+

-

    - -
  • + + >
-
- -
+
+ -
+
- + +
+ +
+

Warning: Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?>

@@ -142,23 +213,18 @@ default:

"; + echo ""; else - echo ""; + echo ""; ?>

the Codex for more information.'); ?>

- -

' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

'; - } -?> -
 
+ +
\ No newline at end of file +include("admin-footer.php");