Skip to:

03/21/2021 02:17:21 PM (3 years ago)

Field Types can now declare supported features & field visibility

  • Edit the JavaScript file used by the xProfile Create field Administration screen to handle Field types requirements by showing/hiding screen metaboxes according to feature supports and to get ride of some jQuery deprecated methods.
  • Improve the xProfile Field API to take in account xProfile Field Types declared feature supports by adding two new methods to get (BP_XProfile_Field->get_field_type_supports()) & check (BP_XProfile_Field->field_type_supports( $feature_name )) the field type supported features.
  • The xProfile Create field Administration Screen Metaboxes displayed to set the field properties can now be disabled by the Field Type using the static variable $supported_features. See tests/phpunit/assets/bptest-xprofile-field-type.php for an example of use.
  • Improve the xProfile Field API to take in account the xProfile Field Types visibility property to use as default field visibility. NB: setting this Field Type visibility and its allow_custom_visibility feature support to false, a Field Type can now enforce the visibility to use for a field.
  • Introduce a new xProfile Fields loop argument $hide_field_types to avoid displaying fields according to an array of Field types. To customize this new argument you can use the bp_before_has_profile_parse_args filter for existing xProfile loop. For instance you can avoid to list xProfile fields according to their type from the WP-Admin/Extended profile screen checking the corresponding Administration Screen ID.
  • Add PHP unit tests to verify these improvements are working the right way.

Props DJPaul, Offereins, needle, netweb, vapvarun

See #7162

1 edited


  • trunk/src/bp-xprofile/classes/class-bp-xprofile-data-template.php

    r12426 r12868  
    106106     * @since 1.5.0
    107107     * @since 2.4.0 Introduced `$member_type` argument.
     108     * @since 8.0.0 Introduced `$hide_field_types` argument.
    108109     *
    109110     * @param array|string $args {
    121122     *     @type int|bool     $fetch_visibility_level  Fetch visibility levels.
    122123     *     @type int|bool     $update_meta_cache       Should metadata cache be updated.
     124     *     @type string[]     $hide_field_types        List of field types to hide form loop. Default: empty array.
    123125     * }
    124126     */
    157159            'exclude_groups'         => false,
    158160            'exclude_fields'         => false,
     161            'hide_field_types'       => array(),
    159162            'update_meta_cache'      => true
    160163        ) );
Note: See TracChangeset for help on using the changeset viewer.