How to determine if the security page is accessible

CP Brute Force Login Protection

Version 2.0.1 released. Removes configuration page from Settings tab if Security page exists.

1 Like

Hopefully, they’re not assuming. They should be actually checking for the existence of a new feature before counting on it being there – this easily breaks backward compatibility otherwise and can leave unsuspecting users with a whitescreen.

Also, no need to notify this thread of plugin updates unless the URL changes. :wink:

1 Like

Point taken. Thought the ReadMe file saying it was for CP v1.1.0 and above would be enough.

Might change it to checking, and if not present, then add to Settings tab.

That will test my PHP skills :rofl:

1 Like

I split this off the other topic to follow-up on testing for the existence of the Security page.

In the function where you create the admin menu item with add_security_page(), you can wrap a check around it. The following should work:


function the_function_where_you_setup_your_menu() {
    if (!function_exists('add_security_page')) {
        // Add your item to the top-level admin menu.
        add_menu_page();
    } else {
        // Add your item to the Security menu.
        add_submenu_page()
    }
}
add_action('admin_menu', 'the_function_where_you_setup_your_menu');
4 Likes

Yes, I used the test example from the docs page to do just that. Am redoing 2.0.1 on GitHub at the moment.

4 Likes