Ticket #14170: 14170.diff

File 14170.diff, 2.9 KB (added by scribu, 3 years ago)

pass $network_wide to callbacks

Line 
1Index: wp-includes/plugin.php
2===================================================================
3--- wp-includes/plugin.php      (revision 16009)
4+++ wp-includes/plugin.php      (working copy)
5@@ -605,7 +605,7 @@
6  */
7 function register_activation_hook($file, $function) {
8        $file = plugin_basename($file);
9-       add_action('activate_' . $file, $function);
10+       add_action('activate_' . $file, $function, 10, 2);
11 }
12 
13 /**
14@@ -630,7 +630,7 @@
15  */
16 function register_deactivation_hook($file, $function) {
17        $file = plugin_basename($file);
18-       add_action('deactivate_' . $file, $function);
19+       add_action('deactivate_' . $file, $function, 10, 2);
20 }
21 
22 /**
23Index: wp-admin/includes/plugin.php
24===================================================================
25--- wp-admin/includes/plugin.php        (revision 16009)
26+++ wp-admin/includes/plugin.php        (working copy)
27@@ -482,8 +482,8 @@
28                        wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
29                ob_start();
30                include(WP_PLUGIN_DIR . '/' . $plugin);
31-               do_action( 'activate_plugin', trim( $plugin) );
32-               do_action( 'activate_' . trim( $plugin ) );
33+               do_action( 'activate_plugin', trim( $plugin), $network_wide );
34+               do_action( 'activate_' . trim( $plugin ), $network_wide );
35                if ( $network_wide ) {
36                        $current[$plugin] = time();
37                        update_site_option( 'active_sitewide_plugins', $current );
38@@ -492,7 +492,7 @@
39                        sort($current);
40                        update_option('active_plugins', $current);
41                }
42-               do_action( 'activated_plugin', trim( $plugin) );
43+               do_action( 'activated_plugin', trim( $plugin), $network_wide );
44                if ( ob_get_length() > 0 ) {
45                        $output = ob_get_clean();
46                        return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
47@@ -524,15 +524,16 @@
48                $plugin = plugin_basename($plugin);
49                if ( ! is_plugin_active($plugin) )
50                        continue;
51+
52+               $network_wide = is_plugin_active_for_network( $plugin );
53+
54                if ( ! $silent )
55-                       do_action( 'deactivate_plugin', trim( $plugin ) );
56+                       do_action( 'deactivate_plugin', trim( $plugin ), $network_wide );
57 
58-               if ( is_plugin_active_for_network($plugin) ) {
59-                       // Deactivate network wide
60+               if ( $network_wide ) {
61                        $do_network = true;
62                        unset( $network_current[ $plugin ] );
63                } else {
64-                       // Deactivate for this blog only
65                        $key = array_search( $plugin, (array) $current );
66                        if ( false !== $key ) {
67                                $do_blog = true;
68@@ -540,10 +541,9 @@
69                        }
70                }
71 
72-               //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output.
73                if ( ! $silent ) {
74-                       do_action( 'deactivate_' . trim( $plugin ) );
75-                       do_action( 'deactivated_plugin', trim( $plugin ) );
76+                       do_action( 'deactivate_' . trim( $plugin ), $network_wide );
77+                       do_action( 'deactivated_plugin', trim( $plugin ), $network_wide );
78                }
79        }
80