Allow editor to manage wp rocket

/**
 * Allow editor wp rocket capabilities
 */
function puddinq_rocket_add_purge_posts_to_author()
{
    // check if acces has been granted
    if (get_option('puddinq_editor_rocket_cap') != 'granted') {

        // gets the author role object
        $role = get_role('editor');

        // add a new capability
        // WP Rocket
        $role->add_cap('rocket_purge_cache');
        $role->add_cap('rocket_purge_posts');
        $role->add_cap('rocket_purge_terms');
        $role->add_cap('rocket_purge_opcache');
        $role->add_cap('rocket_purge_cloudflare_cache');
        $role->add_cap('rocket_purge_sucuri_cache');
        $role->add_cap('rocket_purge_users');

        // set option acces hase been granted
        update_option('puddinq_editor_rocket_cap', 'granted');
    }
}

add_action('init', 'puddinq_rocket_add_purge_posts_to_author', 12);