Make WordPress Core

Ticket #23746: 23746.3.diff

File 23746.3.diff, 1.7 KB (added by MikeHansenMe, 10 years ago)
  • src/wp-includes/capabilities-functions.php

     
    442442function wp_roles() {
    443443        global $wp_roles;
    444444
     445
     446
    445447        if ( ! isset( $wp_roles ) ) {
    446448                $wp_roles = new WP_Roles();
    447449        }
     
    471473 * @return WP_Role|null WP_Role object if role is added, null if already exists.
    472474 */
    473475function add_role( $role, $display_name, $capabilities = array() ) {
     476
     477        if ( empty( $role ) ) {
     478                return;
     479        }
     480
    474481        return wp_roles()->add_role( $role, $display_name, $capabilities );
    475482}
    476483
  • src/wp-includes/class-wp-roles.php

     
    172172         * @return WP_Role|void WP_Role object, if role is added.
    173173         */
    174174        public function add_role( $role, $display_name, $capabilities = array() ) {
    175                 if ( isset( $this->roles[$role] ) )
     175
     176                if ( empty( $role ) || isset( $this->roles[$role] ) ) {
    176177                        return;
     178                }
    177179
    178180                $this->roles[$role] = array(
    179181                        'name' => $display_name,
  • src/wp-includes/class-wp-user.php

     
    436436         * @param string $role Role name.
    437437         */
    438438        public function add_role( $role ) {
     439
     440                if ( empty( $role ) ) {
     441                        return;
     442                }
     443
    439444                $this->caps[$role] = true;
    440445                update_user_meta( $this->ID, $this->cap_key, $this->caps );
    441446                $this->get_role_caps();