Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/21/2021 02:17:21 PM (4 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-cssjs.php

    r12829 r12868  
    5252        // "please enter options for this field" section.
    5353        $strings = array(
    54             'do_settings_section_field_types' => array(),
    55             'do_autolink'                     => '',
    56             'text'                            => array(
     54            'do_settings_section_field_types'      => array(),
     55            'do_autolink'                          => '',
     56            'hide_do_autolink_metabox'             => array(),
     57            'hide_allow_custom_visibility_metabox' => array(),
     58            'hide_required_metabox'                => array(),
     59            'hide_member_types_metabox'            => array(),
     60            'text'                                 => array(
    5761                'defaultValue' => __( 'Default Value', 'buddypress' ),
    5862                'deleteLabel'  => __( 'Delete', 'buddypress' ),
     
    6468            if ( $field->do_settings_section() ) {
    6569                $strings['do_settings_section_field_types'][] = $field_type;
     70            }
     71
     72            if ( isset( $field::$supported_features ) && is_array( $field::$supported_features ) ) {
     73                foreach ( $field::$supported_features as $feature => $support ) {
     74                    if ( isset( $strings['hide_' . $feature . '_metabox'] ) && ! $support ) {
     75                        $strings['hide_' . $feature . '_metabox'][] = $field_type;
     76                    }
     77                }
    6678            }
    6779        }
Note: See TracChangeset for help on using the changeset viewer.