Make WordPress Core

Changeset 1010


Ignore:
Timestamp:
03/25/2004 08:10:26 AM (20 years ago)
Author:
saxmatt
Message:

Functional plugin implementation.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r1008 r1010  
    44require_once('admin-header.php');
    55
    6 if ($user_level == 0) //Checks to see if user has logged in
    7     die ("Cheatin' uh ?");
     6if ($user_level < 9) // Must be at least level 9
     7    die ("Sorry, you must be at least a level 8 user to modify plugins.");
     8
     9// Clean up options
     10// if any files are in the option that don't exist, axe 'em
     11
     12$check_plugins = explode("\n", (get_settings('active_plugins')));
     13foreach ($check_plugins as $check_plugin) {
     14    if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
     15            $current = get_settings('active_plugins') . "\n";
     16            $current = str_replace($check_plugin . "\n", '', $current);
     17            $current = preg_replace("|\n+|", "\n", $current);
     18            update_option('active_plugins', trim($current));
     19    }
     20}
     21
     22
     23if ('activate' == $_GET['action']) {
     24    $current = "\n" . get_settings('active_plugins') . "\n";
     25    $current = preg_replace("|(\n)+\s*|", "\n", $current);
     26    $current = trim($current) . "\n " . trim($_GET['plugin']);
     27    $current = trim($current);
     28    $current = preg_replace('|\n\s*|', '\n', $current); // I don't know where this is coming from
     29    update_option('active_plugins', $current);
     30    header('Location: plugins.php');
     31}
     32
     33if ('deactivate' == $_GET['action']) {
     34    $current = "\n" . get_settings('active_plugins') . "\n";
     35    $current = str_replace("\n" . $_GET['plugin'], '', $current);
     36    $current = preg_replace("|(\n)+\s*|", "\n", $current);
     37    update_option('active_plugins', trim($current));
     38    header('Location: plugins.php');
     39}
    840
    941?>
     
    1951
    2052if ('' != trim(get_settings('active_plugins'))) {
    21     $current_plugins = unserialize(get_settings('active_plugins'));
     53    $current_plugins = explode("\n", (get_settings('active_plugins')));
    2254}
    23 
    24 /*
    25 Plugin Name: matt's cool plugin
    26 Plugin URI: http://photomatt.net/plugins/cool-plugin
    27 Description: blah blah blah anything until a newline
    28 Author: photo matt
    29 Author URI: http://photomatt.net
    30 */
    3155
    3256if (!$plugins_dir || !$plugin_files) {
     
    6791
    6892        $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
     93
     94        if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
     95            $action = "<a href='plugins.php?action=deactivate&amp;plugin=$plugin_file' title='Deactivate this plugin' class='delete'>Deactivate</a>";
     96        } else {
     97            $action = "<a href='plugins.php?action=activate&amp;plugin=$plugin_file' title='Activate this plugin' class='edit'>Activate</a>";
     98        }
    6999        echo "
    70100    <tr $style>
     
    72102        <td>$author</td>
    73103        <td>$description</td>
    74         <td><a href='' class='edit'>activate</a></td>
     104        <td>$action</td>
    75105    </tr>";
    76106    }
  • trunk/wp-settings.php

    r957 r1010  
    6969}
    7070
    71 
     71if (!strstr($_SERVER['REQUEST_URI'], 'wp-admin/plugins.php') && get_settings('active_plugins')) {
     72    $current_plugins = explode("\n", (get_settings('active_plugins')));
     73    foreach ($current_plugins as $plugin) {
     74        if (file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
     75            include(ABSPATH . 'wp-content/plugins/' . $plugin);
     76    }
     77}
    7278
    7379?>
Note: See TracChangeset for help on using the changeset viewer.