2 require_once('admin.php');
4 $title = __("Edit Plugins");
5 $parent_file = 'plugins.php';
7 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
9 $wpvar = $wpvarstoreset[$i];
10 if (!isset($$wpvar)) {
11 if (empty($_POST["$wpvar"])) {
12 if (empty($_GET["$wpvar"])) {
15 $$wpvar = $_GET["$wpvar"];
18 $$wpvar = $_POST["$wpvar"];
23 $plugins = get_plugins();
24 $plugin_files = array_keys($plugins);
27 $file = $plugin_files[0];
30 $file = validate_file_to_edit($file, $plugin_files);
31 $real_file = get_real_file_to_edit("wp-content/plugins/$file");
37 check_admin_referer('edit-plugin_' . $file);
39 if ( !current_user_can('edit_plugins') )
40 die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
42 $newcontent = stripslashes($_POST['newcontent']);
43 if (is_writeable($real_file)) {
44 $f = fopen($real_file, 'w+');
45 fwrite($f, $newcontent);
47 wp_redirect("plugin-editor.php?file=$file&a=te");
49 wp_redirect("plugin-editor.php?file=$file");
58 require_once('admin-header.php');
59 if ( !current_user_can('edit_plugins') )
60 die('<p>'.__('You have do not have sufficient permissions to edit plugins for this blog.').'</p>');
62 update_recently_edited("wp-content/plugins/$file");
64 if (!is_file($real_file))
68 $f = fopen($real_file, 'r');
69 $content = fread($f, filesize($real_file));
70 $content = htmlspecialchars($content);
74 <?php if (isset($_GET['a'])) : ?>
75 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
79 if (is_writeable($real_file)) {
80 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
82 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
85 <div id="templateside">
86 <h3><?php _e('Plugin files') ?></h3>
92 <?php foreach($plugin_files as $plugin_file) : ?>
93 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
98 <?php if (!$error) { ?>
99 <form name="template" id="template" action="plugin-editor.php" method="post">
100 <?php wp_nonce_field('edit-plugin_' . $file) ?>
101 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
102 <input type="hidden" name="action" value="update" />
103 <input type="hidden" name="file" value="<?php echo $file ?>" />
105 <?php if ( is_writeable($real_file) ) : ?>
108 echo "<input type='submit' name='submit' value=' " . __('Update File') . " »' tabindex='2' />";
112 <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
117 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
120 <div class="clear"> </div>
126 include("admin-footer.php") ?>