Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/21/2021 02:17:21 PM (2 years ago)
Author:
imath
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r12768 r12868  
    1515 *
    1616 * @since 1.0.0
     17 * @since 2.4.0 Introduced `$member_type` argument.
     18 * @since 8.0.0 Introduced `$hide_field_types` argument.
    1719 *
    1820 * @global object $profile_template
     
    3234 *     @type bool         $fetch_visibility_level Defaults to true when an admin is viewing a profile, or when a user is
    3335 *                                                viewing her own profile, or during registration. Otherwise false.
    34  *     @type int|bool     $exclude_groups         Default: false.
    35  *     @type int|bool     $exclude_fields         Default: false
     36 *     @type int[]|bool   $exclude_groups         Default: false.
     37 *     @type int[]|bool   $exclude_fields         Default: false.
     38 *     @type string[]     $hide_field_types       Default: empty array.
    3639 *     @type bool         $update_meta_cache      Default: true.
    3740 * }
     
    6568        'exclude_groups'         => false, // Comma-separated list of profile field group IDs to exclude.
    6669        'exclude_fields'         => false, // Comma-separated list of profile field IDs to exclude.
     70        'hide_field_types'       => array(), // List of field types to hide from profile fields loop.
    6771        'update_meta_cache'      => true,
    6872    ), 'has_profile' );
Note: See TracChangeset for help on using the changeset viewer.