Make WordPress Core

Changeset 2697


Ignore:
Timestamp:
07/04/2005 09:53:26 PM (20 years ago)
Author:
ryan
Message:

register_activation_hook() and register_deactivation_hook(). Let's try these on.

Location:
trunk
Files:
3 edited

Legend:

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

    r2695 r2697  
    10731073}
    10741074
    1075 function plugin_basename($file) {
    1076     return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
    1077 }
    1078 
    10791075function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') {
    10801076    global $menu, $admin_page_hooks;
  • trunk/wp-admin/plugins.php

    r2594 r2697  
    44if ( isset($_GET['action']) ) {
    55    check_admin_referer();
    6 
     6   
    77    if ('activate' == $_GET['action']) {
    88        $current = get_settings('active_plugins');
    99        if (!in_array($_GET['plugin'], $current)) {
    1010            $current[] = trim( $_GET['plugin'] );
     11            sort($current);
     12            update_option('active_plugins', $current);
     13            include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
     14            do_action('activate_' . trim( $_GET['plugin'] ));
    1115        }
    12         sort($current);
    13         update_option('active_plugins', $current);
    1416        header('Location: plugins.php?activate=true');
    15     }
    16    
    17     if ('deactivate' == $_GET['action']) {
     17    } else if ('deactivate' == $_GET['action']) {
    1818        $current = get_settings('active_plugins');
    1919        array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
    2020        update_option('active_plugins', $current);
     21        do_action('deactivate_' . trim( $_GET['plugin'] ));
    2122        header('Location: plugins.php?deactivate=true');
    2223    }
  • trunk/wp-includes/functions.php

    r2671 r2697  
    19671967}
    19681968
     1969function register_activation_hook($file, $function) {
     1970    $file = plugin_basename($file);
     1971   
     1972    add_action('activate_' . $file, $function);
     1973}
     1974
     1975function register_deactivation_hook($file, $function) {
     1976    $file = plugin_basename($file);
     1977   
     1978    add_action('deactivate_' . $file, $function);
     1979}
     1980
     1981function plugin_basename($file) {
     1982    return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
     1983}
     1984
    19691985?>
Note: See TracChangeset for help on using the changeset viewer.