[wp-trac] [WordPress Trac] #27188: deactivated_plugin behaves improperly (was: deactived_plugin behaves improperly)

WordPress Trac noreply at wordpress.org
Mon Feb 24 21:08:20 UTC 2014


#27188: deactivated_plugin behaves improperly
--------------------------+------------------
 Reporter:  wpsmith       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.9
Component:  Plugins       |     Version:  2.9
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------
Changes (by SergeyBiryukov):

 * version:  trunk => 2.9


Old description:

> Currently, if someone were to hook into `deactivated_plugin`, one should
> expect that the `$plugin` actually be deactivated.
>
> So if, for example, I hook into it with the following code, deactivating
> Addthis, I don't get the expected behavior.
> {{{
> add_action( 'deactivated_plugin', 'dtat_deactivate_self', 10, 2 );
> /**
>  *  Deactivate ourself if Premise is deactivated.
>  */
> function dtat_deactivate_self( $plugin, $network_deactivating ) {
>         if ( 'addthis/addthis_social_widget.php' == $plugin ) {
>                 die( 'Addthis: ' . print_r( is_plugin_active( $plugin ),
> 1 ) );
>         }
> }
> }}}
>
> The plugin still shows that it is active. So if I hook in here to check
> if plugin has been deactivated, then it fails. Instead, the
> `deactived_plugin` hook should appear after the `update_option` call,
> which is where the plugin is actually deactivated.
>
> OR, the docs are wrong and should be updated.
>
> Attached is a sample addthis plugin extension that deactivates after
> Addthis is deactived by being forced to use
> `update_option_active_plugins` and
> `update_option_active_sitewide_plugins`.
>
> See [https://gist.github.com/wpsmith/26c2e07370ee8b4c3e3f Github Gist
> sample plugin] for [http://wordpress.org/plugins/addthis/ Addthis].

New description:

 Currently, if someone were to hook into `deactivated_plugin`, one should
 expect that the `$plugin` actually be deactivated.

 So if, for example, I hook into it with the following code, deactivating
 Addthis, I don't get the expected behavior.
 {{{
 add_action( 'deactivated_plugin', 'dtat_deactivate_self', 10, 2 );
 /**
  *  Deactivate ourself if Premise is deactivated.
  */
 function dtat_deactivate_self( $plugin, $network_deactivating ) {
         if ( 'addthis/addthis_social_widget.php' == $plugin ) {
                 die( 'Addthis: ' . print_r( is_plugin_active( $plugin ), 1
 ) );
         }
 }
 }}}

 The plugin still shows that it is active. So if I hook in here to check if
 plugin has been deactivated, then it fails. Instead, the
 `deactivated_plugin` hook should appear after the `update_option` call,
 which is where the plugin is actually deactivated.

 OR, the docs are wrong and should be updated.

 Attached is a sample addthis plugin extension that deactivates after
 Addthis is deactivated by being forced to use
 `update_option_active_plugins` and
 `update_option_active_sitewide_plugins`.

 See [https://gist.github.com/wpsmith/26c2e07370ee8b4c3e3f Github Gist
 sample plugin] for [http://wordpress.org/plugins/addthis/ Addthis].

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27188#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list