Ticket #20241: 20241.diff
File 20241.diff, 7.3 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/plugin.php
541 541 542 542 if ( ! $silent ) { 543 543 /** 544 * Fires before a plugin is activated in activate_plugin() when the $silent parameter is false. 544 * Fires before a plugin is activated in activate_plugin(). 545 * 546 * Does not fire when a plugin is "silently" activated, such as during updates. 545 547 * 546 548 * @since 2.9.0 547 549 * 548 550 * @param string $plugin Plugin path to main plugin file with plugin data. 549 * @param bool $network_wide Whether t o enable the pluginfor all sites in the network551 * @param bool $network_wide Whether the plugin is being enabled for all sites in the network 550 552 * or just the current site. Multisite only. Default is false. 551 553 */ 552 554 do_action( 'activate_plugin', $plugin, $network_wide ); 553 555 554 556 /** 555 * Fires before a plugin is activated in activate_plugin() when the $silent parameter is false. 557 * Fires as a plugin is being activated in activate_plugin(). 558 * 559 * Does not fire when a plugin is "silently" activated, such as during updates. 556 560 * 561 * This is the hook used by register_activation_hook(). 562 * 557 563 * The action concatenates the 'activate_' prefix with the $plugin value passed to 558 564 * activate_plugin() to create a dynamically-named action. 559 565 * 560 566 * @since 2.0.0 561 567 * 562 * @param bool $network_wide Whether t o enable the pluginfor all sites in the network568 * @param bool $network_wide Whether the plugin is being enabled for all sites in the network 563 569 * or just the current site. Multisite only. Default is false. 564 570 */ 565 571 do_action( 'activate_' . $plugin, $network_wide ); … … 566 572 } 567 573 568 574 if ( $network_wide ) { 575 // Refresh this in case a plugin performed any (de)activations. 576 $current = get_site_option( 'active_sitewide_plugins', array() ); 569 577 $current[$plugin] = time(); 570 578 update_site_option( 'active_sitewide_plugins', $current ); 571 579 } else { 580 // Refresh this in case a plugin performed any (de)activations. 581 $current = get_option( 'active_plugins', array() ); 572 582 $current[] = $plugin; 573 583 sort($current); 574 584 update_option('active_plugins', $current); … … 576 586 577 587 if ( ! $silent ) { 578 588 /** 579 * Fires after a plugin has been activated in activate_plugin() when the $silent parameter is false. 589 * Fires after a plugin has been activated in activate_plugin(). 590 * 591 * Does not fire when a plugin is "silently" activated, such as during updates. 580 592 * 581 593 * @since 2.9.0 582 594 * 583 595 * @param string $plugin Plugin path to main plugin file with plugin data. 584 * @param bool $network_wide Whether to enable the pluginfor all sites in the network585 * 596 * @param bool $network_wide Whether the plugin was enabled for all sites in the network 597 * or just the current site. Multisite only. Default is false. 586 598 */ 587 599 do_action( 'activated_plugin', $plugin, $network_wide ); 588 600 } … … 611 623 * A value of null (the default) will deactivate plugins for both the site and the network. 612 624 */ 613 625 function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { 614 if ( is_multisite() )615 $network_current = get_site_option( 'active_sitewide_plugins', array() );616 626 $current = get_option( 'active_plugins', array() ); 617 $do_blog = $do_network = false;627 $do_blog = $do_network = array(); 618 628 619 629 foreach ( (array) $plugins as $plugin ) { 620 630 $plugin = plugin_basename( trim( $plugin ) ); … … 623 633 624 634 $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); 625 635 626 if ( ! $silent ) 636 if ( ! $silent ) { 627 637 /** 628 * Fires for each plugin being deactivated in deactivate_plugins(), before deactivation 629 * and when the $silent parameter is false. 638 * Fires for each plugin being deactivated in deactivate_plugins(). 639 * 640 * Does not fire when a plugin is "silently" deactivated, such as during updates. 630 641 * 631 642 * @since 2.9.0 632 643 * 633 644 * @param string $plugin Plugin path to main plugin file with plugin data. 634 * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network645 * @param bool $network_deactivating Whether the plugin is being deactivated for all sites in the network 635 646 * or just the current site. Multisite only. Default is false. 636 647 */ 637 648 do_action( 'deactivate_plugin', $plugin, $network_deactivating ); 649 } 638 650 639 651 if ( false !== $network_wide ) { 640 652 if ( is_plugin_active_for_network( $plugin ) ) { 641 $do_network = true; 642 unset( $network_current[ $plugin ] ); 653 $do_network[ $plugin ] = true; 643 654 } elseif ( $network_wide ) { 644 655 continue; 645 656 } … … 648 659 if ( true !== $network_wide ) { 649 660 $key = array_search( $plugin, $current ); 650 661 if ( false !== $key ) { 651 $do_blog = true; 652 unset( $current[ $key ] ); 662 $do_blog[ $key ] = true; 653 663 } 654 664 } 655 665 656 666 if ( ! $silent ) { 657 667 /** 658 * Fires for each plugin being deactivated in deactivate_plugins(), after deactivation 659 * and when the $silent parameter is false. 668 * Fires for each plugin being deactivated in deactivate_plugins(). 669 * 670 * Does not fire when a plugin is "silently" deactivated, such as during updates. 660 671 * 672 * This is the hook used by register_deactivation_hook(). 673 * 661 674 * The action concatenates the 'deactivate_' prefix with the plugin's basename 662 675 * to create a dynamically-named action. 663 676 * 664 677 * @since 2.0.0 665 678 * 666 * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network679 * @param bool $network_deactivating Whether the plugin is being deactivated for all sites in the network 667 680 * or just the current site. Multisite only. Default is false. 668 681 */ 669 682 do_action( 'deactivate_' . $plugin, $network_deactivating ); 670 683 671 684 /** 672 * Fires for each plugin being deactivated in deactivate_plugins(), after deactivation 673 * and when the $silent parameter is false. 685 * Fires for each plugin being deactivated in deactivate_plugins() 674 686 * 675 687 * @since 2.9.0 676 688 * 677 689 * @param string $plugin Plugin path to main plugin file with plugin data. 678 * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network690 * @param bool $network_deactivating Whether the plugin was deactivated for all sites in the network 679 691 * or just the current site. Multisite only. Default is false. 680 692 */ 681 693 do_action( 'deactivated_plugin', $plugin, $network_deactivating ); … … 682 694 } 683 695 } 684 696 685 if ( $do_blog ) 697 if ( $do_blog ) { 698 $current = get_option( 'active_plugins', array() ); 699 $current = array_diff_key( $current, $do_blog ); 686 700 update_option('active_plugins', $current); 687 if ( $do_network ) 701 } 702 if ( $do_network ) { 703 $network_current = get_site_option( 'active_sitewide_plugins', array() ); 704 $network_current = array_diff_key( $network_current, $do_network ); 688 705 update_site_option( 'active_sitewide_plugins', $network_current ); 706 } 689 707 } 690 708 691 709 /**