• Resolved abazeed

    (@abazeed)


    I’m using the filter plugin_action_links to remove the Deactivate/Delete links of all the plugins to avoid deactivating/deleting any by mistake, and using the Bulk actions menu to perform such actions.

    function unset_critical_plugins_action_links( $actions ) {
        unset( $actions['deactivate'] );
        unset( $actions['delete'] );
    
        return $actions;
    }
    add_filter( 'plugin_action_links', 'unset_critical_plugins_action_links' );

    But you already use the filter plugin_action_links_{$plugin_file} to control the action links of your plugin, that’s why I keep getting this warning whenever I open the Plugins page:

    PHP Warning:  Undefined array key "deactivate" in ..../wp-content/plugins/nelio-content/admin/pages/class-nelio-content-plugin-list-page.php on line 60

    I tried to change my filter priority to make it run after yours, but it didn’t work.

    Could you please add one more condition to your code (line 57 in the same file) to avoid this warning? Something like && isset( $actions['deactivate'] ):

    if ( current_user_can( 'deactivate_plugin', nelio_content()->plugin_file ) && isset( $actions['deactivate'] ) ) {
        $actions['deactivate'] = sprintf(
            '<span class="nelio-content-deactivate-link"></span><noscript>%s</noscript>',
            $actions['deactivate']
        );
    }//end if

    I hope you consider this in your next release! ????

    Best Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author David Aguilera

    (@davilera)

    Well, if you click on our plugin’s Deactivate action, you’ll see it actually opens a popup asking what kind of deactivation you want to run. So, if your goal is to prevent deactivating/deleting a plugin by mistake, I’d say ours is already covered by this popup, isn’t it? That is, you can simply skip this step in our plugin.

    Now, if you’re wondering why we did that, it’s pretty simple: if you do want to delete the plugin, you might also want to remove all the data we have from our cloud (and perhaps even cancel your subscription) – the popup allows you to either do that or simply deactivate the plugin.

    Be it as it may, we’ll add the extra check you proposed as well in the future release.

    Thread Starter abazeed

    (@abazeed)

    Thank you @davilera for your kind and detailed response, and I appreciate your understanding!

    Thank you again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Undefined array key “deactivate”’ is closed to new replies.