[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/wp-admin/ -> plugin-editor.php (source)

   1  <?php
   2  require_once ('admin.php');
   3  
   4  $title = __("Edit Plugins");
   5  $parent_file = 'plugins.php';
   6  
   7  wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
   8  
   9  $plugins = get_plugins();
  10  $plugin_files = array_keys($plugins);
  11  
  12  if (empty($file)) {
  13      $file = $plugin_files[0];
  14  }
  15  
  16  $file = validate_file_to_edit($file, $plugin_files);
  17  $real_file = get_real_file_to_edit("wp-content/plugins/$file");
  18  
  19  switch($action) {
  20  
  21  case 'update':
  22  
  23      check_admin_referer('edit-plugin_' . $file);
  24  
  25      if ( !current_user_can('edit_plugins') )
  26          wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
  27  
  28      $newcontent = stripslashes($_POST['newcontent']);
  29      if (is_writeable($real_file)) {
  30          $f = fopen($real_file, 'w+');
  31          fwrite($f, $newcontent);
  32          fclose($f);
  33          wp_redirect("plugin-editor.php?file=$file&a=te");
  34      } else {
  35          wp_redirect("plugin-editor.php?file=$file");
  36      }
  37  
  38      exit();
  39  
  40  break;
  41  
  42  default:
  43  
  44      require_once ('admin-header.php');
  45      if ( !current_user_can('edit_plugins') )
  46          wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
  47  
  48      update_recently_edited("wp-content/plugins/$file");
  49  
  50      if (!is_file($real_file))
  51          $error = 1;
  52  
  53      if (!$error) {
  54          $f = fopen($real_file, 'r');
  55          $content = fread($f, filesize($real_file));
  56          $content = htmlspecialchars($content);
  57      }
  58  
  59      ?>
  60  <?php if (isset($_GET['a'])) : ?>
  61   <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
  62  <?php endif; ?>
  63   <div class="wrap"> 
  64    <?php
  65      if (is_writeable($real_file)) {
  66          echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
  67      } else {
  68          echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
  69      }
  70      ?>
  71      <div id="templateside">
  72  <h3><?php _e('Plugin files') ?></h3>
  73  
  74  <?php
  75  if ($plugin_files) :
  76  ?>
  77    <ul>
  78  <?php foreach($plugin_files as $plugin_file) : ?>
  79           <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
  80  <?php endforeach; ?>
  81    </ul>
  82  <?php endif; ?>
  83  </div>
  84      <?php    if (!$error) { ?> 
  85    <form name="template" id="template" action="plugin-editor.php" method="post">
  86    <?php wp_nonce_field('edit-plugin_' . $file) ?>
  87           <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea> 
  88       <input type="hidden" name="action" value="update" /> 
  89       <input type="hidden" name="file" value="<?php echo $file ?>" /> 
  90          </div>
  91  <?php if ( is_writeable($real_file) ) : ?>
  92       <p class="submit">
  93  <?php
  94      echo "<input type='submit' name='submit' value='    " . __('Update File &raquo;') . "' tabindex='2' />";
  95  ?>
  96  </p>
  97  <?php else : ?>
  98  <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
  99  <?php endif; ?>
 100     </form> 
 101    <?php
 102      } else {
 103          echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
 104      }
 105      ?>
 106  <div class="clear"> &nbsp; </div>
 107  </div> 
 108  <?php
 109  break;
 110  }
 111  
 112  include ("admin-footer.php") ?> 

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana