Skip to:
Content

BuddyPress.org

Changeset 13983


Ignore:
Timestamp:
07/27/2024 06:44:41 PM (11 months ago)
Author:
espellcaste
Message:

Require singular and plural names for BuddyPress custom types.

When creating a member or group type, require that both singular and plural names are provided. This ensures that the type can be properly registered and used throughout BuddyPress.

Props 1naveengiri, imath, imranmd.

Fixes #9092
Closes https://github.com/buddypress/buddypress/pull/335/

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-types.php

    r13890 r13983  
    4545 *     @type string $taxonomy   The Type's taxonomy. Required.
    4646 *     @type string $bp_type_id Unique string identifier for the member type. Required.
     47 *     @type string $bp_type_singular_name Singular name for the member type. Required.
     48 *     @type string $bp_type_name Plural name for the member type. Required.
    4749 *     @see keys of the array returned by bp_get_type_metadata_schema() for the other arguments.
    4850 * }
    49  * @return integer|WP_Error The Type's term ID on success. A WP_Error object otherwise.
     51 * @return int|WP_Error The Type's term ID on success. A WP_Error object otherwise.
    5052 */
    5153function bp_core_admin_insert_type( $args = array() ) {
     
    5355        'taxonomy'   => '',
    5456        'bp_type_id' => '',
     57        'bp_type_singular_name' => '',
     58        'bp_type_name' => '',
    5559    );
    5660
     
    6771            __( 'The Type ID value is missing', 'buddypress' ),
    6872            array( 'message' => 1 )
     73        );
     74    }
     75
     76    if ( ! $args['bp_type_singular_name'] ) {
     77        return new WP_Error(
     78            'empty_field_singular',
     79            __( 'The Singular Name value is missing', 'buddypress' ),
     80            array(
     81                'message' => 11,
     82            )
     83        );
     84    }
     85
     86    if ( ! $args['bp_type_name'] ) {
     87        return new WP_Error(
     88            'empty_field_plural',
     89            __( 'The Plural Name value is missing', 'buddypress' ),
     90            array(
     91                'message' => 12,
     92            )
    6993        );
    7094    }
     
    117141    }
    118142
     143    $type_term_id = reset( $type_term_id );
     144
    119145    /**
    120146     * Hook here to add code once the type has been inserted.
  • trunk/src/bp-core/bp-core-functions.php

    r13974 r13983  
    33813381function bp_get_taxonomy_common_labels() {
    33823382    return array(
    3383         'bp_type_name'           => _x( 'Plural Name', 'BP Type name label', 'buddypress' ),
    3384         'bp_type_singular_name'  => _x( 'Singular name', 'BP Type singular name label', 'buddypress' ),
     3383        'bp_type_name'           => _x( 'Plural Name (required)', 'BP Type name label', 'buddypress' ),
     3384        'bp_type_singular_name'  => _x( 'Singular Name (required)', 'BP Type singular name label', 'buddypress' ),
    33853385        'bp_type_has_directory'  => _x( 'Has Directory View', 'BP Type has directory checkbox label', 'buddypress' ),
    33863386        'bp_type_directory_slug' => _x( 'Custom type directory slug', 'BP Type slug label', 'buddypress' ),
  • trunk/src/bp-groups/bp-groups-admin.php

    r13974 r13983  
    15131513        9  => __( 'Group type successfully deleted.', 'buddypress' ),
    15141514        10 => __( 'Group type could not be updated due to missing required information.', 'buddypress' ),
     1515        11 => __( 'Please define the Group Type Singular Name field.', 'buddypress' ),
     1516        12 => __( 'Please define the Group Type Plural Name field.', 'buddypress' ),
    15151517    );
    15161518
  • trunk/src/bp-groups/bp-groups-functions.php

    r13890 r13983  
    28402840
    28412841            // Specific to BuddyPress.
    2842             'bp_type_id_label'              => _x( 'Group Type ID', 'BP Member type ID label', 'buddypress' ),
     2842            'bp_type_id_label'              => _x( 'Group Type ID (required)', 'BP Member type ID label', 'buddypress' ),
    28432843            'bp_type_id_description'        => _x( 'Lower-case string, no spaces or special characters. Used to identify the group type.', 'BP Group type ID description', 'buddypress' ),
    28442844            'bp_type_show_in_create_screen' => _x( 'Show on Group Creation', 'BP Group type show in create screen', 'buddypress' ),
  • trunk/src/bp-members/bp-members-admin.php

    r13799 r13983  
    108108        9  => __( 'Member type successfully deleted.', 'buddypress' ),
    109109        10 => __( 'Member type could not be updated due to missing required information.', 'buddypress' ),
     110        11 => __( 'Please define the Member Type Singular Name field.', 'buddypress' ),
     111        12 => __( 'Please define the Member Type Plural Name field.', 'buddypress' ),
    110112    );
    111113
  • trunk/src/bp-members/bp-members-functions.php

    r13982 r13983  
    27672767
    27682768            // Specific to BuddyPress.
    2769             'bp_type_id_label'           => _x( 'Member Type ID', 'BP Member type ID label', 'buddypress' ),
     2769            'bp_type_id_label'           => _x( 'Member Type ID (required)', 'BP Member type ID label', 'buddypress' ),
    27702770            'bp_type_id_description'     => _x( 'Enter a lower-case string without spaces or special characters (used internally to identify the member type).', 'BP Member type ID description', 'buddypress' ),
    27712771            'bp_type_show_in_list'       => _x( 'Show on Member', 'BP Member type show in list', 'buddypress' ),
Note: See TracChangeset for help on using the changeset viewer.