[ Index ]
 

Code source de WordPress 2.1.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/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( PLUGINDIR . "/$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      if ( !current_user_can('edit_plugins') )
  45          wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
  46  
  47      require_once ('admin-header.php');
  48  
  49      update_recently_edited(PLUGINDIR . "/$file");
  50  
  51      if (!is_file($real_file))
  52          $error = 1;
  53  
  54      if (!$error) {
  55          $f = fopen($real_file, 'r');
  56          $content = fread($f, filesize($real_file));
  57          $content = htmlspecialchars($content);
  58      }
  59  
  60      ?>
  61  <?php if (isset($_GET['a'])) : ?>
  62   <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
  63  <?php endif; ?>
  64   <div class="wrap">
  65      <?php
  66      if (is_writeable($real_file)) {
  67          echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
  68      } else {
  69          echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
  70      }
  71      ?>
  72      <div id="templateside">
  73  <h3><?php _e('Plugin files') ?></h3>
  74  
  75  <?php
  76  if ($plugin_files) :
  77  ?>
  78      <ul>
  79      <?php foreach($plugin_files as $plugin_file) : ?>
  80           <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
  81      <?php endforeach; ?>
  82      </ul>
  83  <?php endif; ?>
  84  </div>
  85  <?php    if (!$error) { ?>
  86      <form name="template" id="template" action="plugin-editor.php" method="post">
  87      <?php wp_nonce_field('edit-plugin_' . $file) ?>
  88          <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
  89          <input type="hidden" name="action" value="update" />
  90          <input type="hidden" name="file" value="<?php echo $file ?>" />
  91          </div>
  92  <?php if ( is_writeable($real_file) ) : ?>
  93      <p class="submit">
  94      <?php
  95          echo "<input type='submit' name='submit' value='    " . __('Update File &raquo;') . "' tabindex='2' />";
  96      ?>
  97      </p>
  98  <?php else : ?>
  99      <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
 100  <?php endif; ?>
 101   </form>
 102  <?php
 103      } else {
 104          echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
 105      }
 106  ?>
 107  <div class="clear"> &nbsp; </div>
 108  </div>
 109  <?php
 110  break;
 111  }
 112  
 113  include ("admin-footer.php") ?>


Généré le : Fri Mar 30 19:41:27 2007 par Balluche grâce à PHPXref 0.7