Make WordPress Core

Ticket #31304: 31304.diff

File 31304.diff, 724 bytes (added by hlashbrooke, 12 years ago)

Adds role_exists() function that returns boolean true/false

  • wp-includes/capabilities.php

     
    15171517}
    15181518
    15191519/**
     1520 * Check if role exists.
     1521 *
     1522 * @see get_role() Uses function to retrieve role object.
     1523 * @since 4.2.0
     1524 *
     1525 * @param string $role Role name.
     1526 * @return boolean True if role exists, false if it does not or no role name is supplied.
     1527 */
     1528function role_exists( $role = '' ) {
     1529
     1530        if( $role ) {
     1531
     1532                $role_object = get_role( $role );
     1533
     1534                if( ! is_null( $role_object ) ) {
     1535                        return true;
     1536                }
     1537
     1538        }
     1539
     1540        return false;
     1541}
     1542
     1543/**
    15201544 * Retrieve a list of super admins.
    15211545 *
    15221546 * @since 3.0.0