Skip to:
Content

BuddyPress.org

Ticket #8410: 8410.2.diff

File 8410.2.diff, 979 bytes (added by Jean-David, 4 years ago)
  • src/bp-core/admin/bp-core-admin-types.php

    diff --git src/bp-core/admin/bp-core-admin-types.php src/bp-core/admin/bp-core-admin-types.php
    index 6b8db3f7a..7ad849ca5 100644
    function bp_core_admin_insert_type( $args = array() ) { 
    6363                'admin_insert_type'
    6464        );
    6565
    66         if ( ! $args['bp_type_id'] || ! $args['taxonomy'] ) {
     66        if ( ( ! $args['bp_type_id'] && ! $args['bp_type_singular_name'] ) || ! $args['taxonomy'] ) {
    6767                 return new WP_Error(
    6868                         'invalid_type_taxonomy',
    69                          __( 'The Type ID value is missing', 'buddypress' ),
     69                         __( 'The Type ID or singular name value is missing', 'buddypress' ),
    7070                         array(
    7171                                'message' => 1,
    7272                         )
    7373                );
    7474        }
    7575
     76        if ( ! $args['bp_type_id'] && $args['bp_type_singular_name'] ) {
     77                $args['bp_type_id'] = sanitize_title( $args['bp_type_singular_name'] );
     78        }
     79
    7680        $type_id       = sanitize_title( $args['bp_type_id'] );
    7781        $type_taxonomy = sanitize_key( $args['taxonomy'] );
    7882