mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 22:56:19 +01:00
register_activation_hook() and register_deactivation_hook(). Let's try these on.
git-svn-id: http://svn.automattic.com/wordpress/trunk@2697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
20ae785c4c
commit
cbce881c2b
@ -1072,10 +1072,6 @@ function get_admin_page_parent() {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function plugin_basename($file) {
|
|
||||||
return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') {
|
function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') {
|
||||||
global $menu, $admin_page_hooks;
|
global $menu, $admin_page_hooks;
|
||||||
|
|
||||||
|
@ -8,16 +8,17 @@ if ( isset($_GET['action']) ) {
|
|||||||
$current = get_settings('active_plugins');
|
$current = get_settings('active_plugins');
|
||||||
if (!in_array($_GET['plugin'], $current)) {
|
if (!in_array($_GET['plugin'], $current)) {
|
||||||
$current[] = trim( $_GET['plugin'] );
|
$current[] = trim( $_GET['plugin'] );
|
||||||
}
|
|
||||||
sort($current);
|
sort($current);
|
||||||
update_option('active_plugins', $current);
|
update_option('active_plugins', $current);
|
||||||
header('Location: plugins.php?activate=true');
|
include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
|
||||||
|
do_action('activate_' . trim( $_GET['plugin'] ));
|
||||||
}
|
}
|
||||||
|
header('Location: plugins.php?activate=true');
|
||||||
if ('deactivate' == $_GET['action']) {
|
} else if ('deactivate' == $_GET['action']) {
|
||||||
$current = get_settings('active_plugins');
|
$current = get_settings('active_plugins');
|
||||||
array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
|
array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
|
||||||
update_option('active_plugins', $current);
|
update_option('active_plugins', $current);
|
||||||
|
do_action('deactivate_' . trim( $_GET['plugin'] ));
|
||||||
header('Location: plugins.php?deactivate=true');
|
header('Location: plugins.php?deactivate=true');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1966,4 +1966,20 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
|
|||||||
$wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
|
$wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function register_activation_hook($file, $function) {
|
||||||
|
$file = plugin_basename($file);
|
||||||
|
|
||||||
|
add_action('activate_' . $file, $function);
|
||||||
|
}
|
||||||
|
|
||||||
|
function register_deactivation_hook($file, $function) {
|
||||||
|
$file = plugin_basename($file);
|
||||||
|
|
||||||
|
add_action('deactivate_' . $file, $function);
|
||||||
|
}
|
||||||
|
|
||||||
|
function plugin_basename($file) {
|
||||||
|
return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user