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 if ( !current_user_can('edit_plugins') )
38 die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
40 $newcontent = stripslashes($_POST['newcontent']);
41 if (is_writeable($real_file)) {
42 $f = fopen($real_file, 'w+');
43 fwrite($f, $newcontent);
45 header("Location: plugin-editor.php?file=$file&a=te");
47 header("Location: plugin-editor.php?file=$file");
56 require_once('admin-header.php');
57 if ( !current_user_can('edit_plugins') )
58 die('<p>'.__('You have do not have sufficient permissions to edit plugins for this blog.').'</p>');
60 update_recently_edited("wp-content/plugins/$file");
62 if (!is_file($real_file))
66 $f = fopen($real_file, 'r');
67 $content = fread($f, filesize($real_file));
68 $content = htmlspecialchars($content);
72 <?php if (isset($_GET['a'])) : ?>
73 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
77 if (is_writeable($real_file)) {
78 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
80 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
83 <div id="templateside">
84 <h3><?php _e('Plugin files') ?></h3>
90 <?php foreach($plugin_files as $plugin_file) : ?>
91 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
96 <?php if (!$error) { ?>
97 <form name="template" id="template" action="plugin-editor.php" method="post">
98 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
99 <input type="hidden" name="action" value="update" />
100 <input type="hidden" name="file" value="<?php echo $file ?>" />
102 <?php if ( is_writeable($real_file) ) : ?>
105 echo "<input type='submit' name='submit' value=' " . __('Update File') . " »' tabindex='2' />";
109 <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
114 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
117 <div class="clear"> </div>
123 include("admin-footer.php") ?>