X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/ff81ee6e8304a1982a3ec4f5b134764a29d502cf..449d082fcc4873c1f7d363a0d9f7409be7f6e77d:/wp-admin/plugin-editor.php?file=%27%20.%20%24plugin_file%20.%20%27 diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index 37aed6b0..b807de89 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -1,123 +1,164 @@ '.__('You have do not have sufficient permissions to edit templates for this blog.').'

'); + wp_die('

'.__('You do not have sufficient permissions to edit templates for this blog.').'

'); $newcontent = stripslashes($_POST['newcontent']); - if (is_writeable($real_file)) { + if ( is_writeable($real_file) ) { $f = fopen($real_file, 'w+'); fwrite($f, $newcontent); fclose($f); - header("Location: plugin-editor.php?file=$file&a=te"); + + // Deactivate so we can test it. + if ( is_plugin_active($file) || isset($_POST['phperror']) ) { + if ( is_plugin_active($file) ) + deactivate_plugins($file, true); + wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); + exit; + } + wp_redirect("plugin-editor.php?file=$file&a=te"); } else { - header("Location: plugin-editor.php?file=$file"); + wp_redirect("plugin-editor.php?file=$file"); } - - exit(); + exit; break; default: - - require_once('admin-header.php'); + if ( !current_user_can('edit_plugins') ) - die('

'.__('You have do not have sufficient permissions to edit plugins for this blog.').'

'); + wp_die('

'.__('You do not have sufficient permissions to edit plugins for this blog.').'

'); - update_recently_edited("wp-content/plugins/$file"); - - if (!is_file($real_file)) - $error = 1; - - if (!$error) { - $f = fopen($real_file, 'r'); - $content = fread($f, filesize($real_file)); - $content = htmlspecialchars($content); + if ( isset($_GET['liveupdate']) ) { + check_admin_referer('edit-plugin-test_' . $file); + + $error = validate_plugin($file); + 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 + + wp_redirect("plugin-editor.php?file=$file&a=te"); + exit; } + require_once('admin-header.php'); + + update_recently_edited(WP_PLUGIN_DIR . '/' . $file); + + if ( ! is_file($real_file) ) + $error = 1; + + if ( ! $error ) + $content = htmlspecialchars(file_get_contents($real_file)); + ?>

+ +

fatal error.') ?>

+ + + +
-
- ' . sprintf(__('Editing %s'), $file) . ''; +
+ +

+ +
+
+%s (active)'), $file); + else + echo sprintf(__('Browsing %s (active)'), $file); } else { - echo '

' . sprintf(__('Browsing %s'), $file) . '

'; + if ( is_writeable($real_file) ) + echo sprintf(__('Editing %s (inactive)'), $file); + else + echo sprintf(__('Browsing %s (inactive)'), $file); } - ?> + ?>
+
+
+
+
-

+

- -
    +

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

-"; -?> -

+ +

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

+ +

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

-

+

the Codex for more information.'); ?>

-
- +

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

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