xwp / wp-dependency-minification

Dependency Minification plugin for WordPress
http://wordpress.org/plugins/dependency-minification/
52 stars 10 forks source link

Flush rewrite rules network-wide when network-activated #37

Closed westonruter closed 10 years ago

westonruter commented 10 years ago

On a multisite network, I also noticed that when the plugin network-activated, it does not flush the rewrite rules across all sites on the network, which will result in broken CSS and JS until someone visits the Permalinks page for each site in the network. This is not acceptable.

westonruter commented 10 years ago

@kucrut you mentioned on Skype the proper-network-activation plugin. Great find! The plugin README should get updated to note that this plugin should be installed and network-activated before attempting to network-activate Dependency Minification. Also as we discussed, it would be awesome to filter the plugin_action_links to even remove the "Network Activate" option if the Proper Network Activate plugin is not activated, or at least there should be a notice appearing there along with the plugin about needing to ensure proper network activation is done.

Your proposed solution (via Otto) to remove the rewrite rule upon deactivation is great:

    static function deactivate() {
        $regex = sprintf( '^%s/%s', self::$options['endpoint'], self::FILENAME_PATTERN );
        global $wp_rewrite;
        unset( $wp_rewrite->extra_rules_top[ $regex ] );
        flush_rewrite_rules();
    }

Just refactor the assignment of the $regex to another function which can be re-used for add_rewrite_rule()