[ Index ]
 

Code source de WordPress 2.1.2

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

title

Body

[fermer]

/wp-admin/ -> plugins.php (source)

   1  <?php
   2  require_once ('admin.php');
   3  
   4  if ( isset($_GET['action']) ) {
   5      if ('activate' == $_GET['action']) {
   6          check_admin_referer('activate-plugin_' . $_GET['plugin']);
   7          $current = get_option('active_plugins');
   8          $plugin = trim($_GET['plugin']);
   9          if ( validate_file($plugin) )
  10              wp_die(__('Invalid plugin.'));
  11          if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
  12              wp_die(__('Plugin file does not exist.'));
  13          if (!in_array($plugin, $current)) {
  14              $current[] = $plugin;
  15              sort($current);
  16              update_option('active_plugins', $current);
  17              include(ABSPATH . PLUGINDIR . '/' . $plugin);
  18              do_action('activate_' . $plugin);
  19          }
  20          wp_redirect('plugins.php?activate=true');
  21      } else if ('deactivate' == $_GET['action']) {
  22          check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
  23          $current = get_option('active_plugins');
  24          array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
  25          update_option('active_plugins', $current);
  26          do_action('deactivate_' . trim( $_GET['plugin'] ));
  27          wp_redirect('plugins.php?deactivate=true');
  28      }
  29      exit;
  30  }
  31  
  32  $title = __('Manage Plugins');
  33  require_once ('admin-header.php');
  34  
  35  // Clean up options
  36  // If any plugins don't exist, axe 'em
  37  
  38  $check_plugins = get_option('active_plugins');
  39  
  40  // Sanity check.  If the active plugin list is not an array, make it an
  41  // empty array.
  42  if ( !is_array($check_plugins) ) {
  43      $check_plugins = array();
  44      update_option('active_plugins', $check_plugins);
  45  }
  46  
  47  // If a plugin file does not exist, remove it from the list of active
  48  // plugins.
  49  foreach ($check_plugins as $check_plugin) {
  50      if (!file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin)) {
  51              $current = get_option('active_plugins');
  52              $key = array_search($check_plugin, $current);
  53              if ( false !== $key && NULL !== $key ) {
  54                  unset($current[$key]);
  55                  update_option('active_plugins', $current);
  56              }
  57      }
  58  }
  59  ?>
  60  
  61  <?php if (isset($_GET['activate'])) : ?>
  62  <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
  63  </div>
  64  <?php endif; ?>
  65  <?php if (isset($_GET['deactivate'])) : ?>
  66  <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
  67  </div>
  68  <?php endif; ?>
  69  
  70  <div class="wrap">
  71  <h2><?php _e('Plugin Management'); ?></h2>
  72  <p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p>
  73  <?php
  74  
  75  if ( get_option('active_plugins') )
  76      $current_plugins = get_option('active_plugins');
  77  
  78  $plugins = get_plugins();
  79  
  80  if (empty($plugins)) {
  81      echo '<p>';
  82      _e("Couldn&#8217;t open plugins directory or there are no plugins available."); // TODO: make more helpful
  83      echo '</p>';
  84  } else {
  85  ?>
  86  <table class="widefat plugins">
  87      <thead>
  88      <tr>
  89          <th><?php _e('Plugin'); ?></th>
  90          <th style="text-align: center"><?php _e('Version'); ?></th>
  91          <th><?php _e('Description'); ?></th>
  92          <th style="text-align: center"<?php if ( current_user_can('edit_plugins') ) echo ' colspan="2"'; ?>><?php _e('Action'); ?></th>
  93      </tr>
  94      </thead>
  95  <?php
  96      $style = '';
  97  
  98      foreach($plugins as $plugin_file => $plugin_data) {
  99          $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
 100  
 101          if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
 102              $toggle = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
 103              $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
 104              $style .= $style == 'alternate' ? ' active' : 'active';
 105          } else {
 106              $toggle = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
 107          }
 108  
 109          $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
 110  
 111          // Sanitize all displayed data
 112          $plugin_data['Title']       = wp_kses($plugin_data['Title'], $plugins_allowedtags);
 113          $plugin_data['Version']     = wp_kses($plugin_data['Version'], $plugins_allowedtags);
 114          $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
 115          $plugin_data['Author']      = wp_kses($plugin_data['Author'], $plugins_allowedtags);
 116  
 117          if ( $style != '' )
 118              $style = 'class="' . $style . '"';
 119          if ( is_writable(ABSPATH . 'wp-content/plugins/' . $plugin_file) )
 120              $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
 121          else
 122              $edit = '';
 123  
 124          echo "
 125      <tr $style>
 126          <td class='name'>{$plugin_data['Title']}</td>
 127          <td class='vers'>{$plugin_data['Version']}</td>
 128          <td class='desc'><p>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></p></td>
 129          <td class='togl'>$toggle</td>";
 130          if ( current_user_can('edit_plugins') )
 131          echo "
 132          <td>$edit</td>";
 133          echo"
 134      </tr>";
 135      }
 136  ?>
 137  
 138  </table>
 139  <?php
 140  }
 141  ?>
 142  
 143  <p><?php printf(__('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), PLUGINDIR); ?></p>
 144  
 145  <h2><?php _e('Get More Plugins'); ?></h2>
 146  <p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.'); ?></p>
 147  <p><?php printf(__('To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.'), PLUGINDIR); ?></p>
 148  
 149  </div>
 150  
 151  <?php
 152  include ('admin-footer.php');
 153  ?>


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