Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Sep 18, 2013

Conversation

kucrut
Copy link
Contributor

@kucrut kucrut commented Sep 17, 2013

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.

@ghost ghost assigned kucrut Sep 17, 2013
@westonruter
Copy link
Contributor Author

@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()

@ghost ghost assigned westonruter Sep 18, 2013
else {
$activate_pna_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $pna_plugin_file, 'activate-plugin_' . $pna_plugin_file );
$links['activate'] = '<a href="' . $activate_pna_url . '" title="' . esc_attr__('Activate Proper Network Activation plugin') . '" class="edit">' . __('Activate PNA') . '</a>';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kucrut very well done! 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, haha! I just realized that this is not going to actually do anything! This function is not going to get a chance to filter network_admin_plugin_action_links because this plugin is not even activated yet 😄

plugins__network_admin__wordpress

So I guess the alternative we'll have to resort to is add a warning in the description?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. Silly me. It was working because the plugin was already activated in the main site 😄

@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Dependency Minification
Description: Concatenates and minifies scripts and stylesheets.
Description: Concatenates and minifies scripts and stylesheets. Please install and activate <a href="http://scribu.net">scribu</a>'s <a href="http://wordpress.org/plugins/proper-network-activation/">Proper Network Activation</a> plugin <em>before</em> activating this plugin <em>network-wide</em>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kucrut beauty!

westonruter added a commit that referenced this pull request Sep 18, 2013
Improve network activation and deactivation

* Flush rewrite rules network-wide when network-activated
* Prompt for installing @scribu's Proper Network Activation plugin
@westonruter westonruter merged commit 2770b80 into develop Sep 18, 2013
@westonruter westonruter deleted the issue-37 branch September 18, 2013 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants