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

Plugin action links are not removed on WP 4.3 #458

Closed
wesm87 opened this issue Aug 19, 2015 · 4 comments
Closed

Plugin action links are not removed on WP 4.3 #458

wesm87 opened this issue Aug 19, 2015 · 4 comments

Comments

@wesm87
Copy link

wesm87 commented Aug 19, 2015

I just upgraded to 4.3 on my dev server and afterward I noticed that the action links (activate, deactivate, etc.) are not being removed any more. I know there are some filters that are supposed to run automatically to take care of this but it looks like something is preventing them from working properly. I'm currently relying on this functionality in a number of WordPress themes that I've developed to prevent clients from accidentally disabling an essential plugin. The following fixed the issue for me:

$required_plugins = [
    // required plugins
];
add_filter( 'plugin_action_links', 'custom_filter_plugin_links', 10, 4 );
function custom_filter_plugin_links( $actions = array(), $plugin_file = '', $plugin_data = array(), $context = '' ) {
    // Return if the current plugin doesn't have a slug
    $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : '';
    if ( empty( $plugin_slug ) ) {
        return $actions;
    }

    // Loop through our required / recommended plugins and compare to the current plugin
    foreach ( $required_plugins as $config ) {
        $slug = isset( $config['slug'] ) ? $config['slug'] : '';
        $required = isset( $config['required'] ) ? $config['required'] : false;

        // Disable the deactivate link if the slugs match and the plugin is required
        if ( $slug == $plugin_slug && $required ) {
            unset( $actions['deactivate'] );
        }
    }

    return $actions;
}

@jrfnl
Copy link
Contributor

jrfnl commented Aug 19, 2015

Actually, TGMPA never did that, so not something which stopped working. The only action link we manipulate similar to what you suggest is for plugins which are 'force activated'.

All the same, I did a quick check and found that that hook in wasn't done in the right place, PR #459 should fix that.

Other than that, this is an enhancement request.

@wesm87
Copy link
Author

wesm87 commented Aug 19, 2015

Sorry for the confusion, I actually was referring to the "force_activation" method that you mentioned. I always set "force_activation" to true for required plugins so targeting either option would have the same effect for my configuration. Thanks for resolving this so quickly.

@jrfnl
Copy link
Contributor

jrfnl commented Aug 19, 2015

No problem. Ok to close this issue now ?

@wesm87
Copy link
Author

wesm87 commented Aug 20, 2015

Yes, the issue is resolved so go ahead and close it 👍

@jrfnl jrfnl closed this as completed Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants