Skip to:
Content

BuddyPress.org

Ticket #6789: 6789.02.diff

File 6789.02.diff, 3.5 KB (added by Offereins, 2 years ago)

.01 + bp_xprofile_field_supports_multiple_values

  • src/bp-xprofile/bp-xprofile-functions.php

    diff --git a/src/bp-xprofile/bp-xprofile-functions.php b/src/bp-xprofile/bp-xprofile-functions.php
    index 21ffe7b..555eee4 100644
    a b function bp_xprofile_is_richtext_enabled_for_field( $field_id = null ) { 
    11301130}
    11311131
    11321132/**
     1133 * Does this profile field support multiple values?
     1134 *
     1135 * @since 2.9.0
     1136 *
     1137 * @param int|null $field_id Optional. Default current field ID.
     1138 * @return bool              Whether the field supports multiple values
     1139 */
     1140function bp_xprofile_field_supports_multiple_values( $field_id = null ) {
     1141        if ( ! $field_id ) {
     1142                $field_id = bp_get_the_profile_field_id();
     1143        }
     1144
     1145        $field = xprofile_get_field( $field_id, null, false );
     1146
     1147        $supports = false;
     1148        if ( $field instanceof BP_XProfile_Field ) {
     1149                $supports = (bool) $field->type_obj->supports_multiple_values;
     1150        }
     1151
     1152        /**
     1153         * Filters whether the given field supports multiple values.
     1154         *
     1155         * @since 2.9.0
     1156         *
     1157         * @param bool $supports True if the field supports multiple values, otherwise false.
     1158         * @param int  $field_id ID of the field.
     1159         */
     1160        return (bool) apply_filters( 'bp_xprofile_field_supports_multiple_values', $supports, $field_id );
     1161}
     1162
     1163/**
    11331164 * Get visibility levels out of the $bp global.
    11341165 *
    11351166 * @since 1.6.0
  • src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php

    diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php
    index 7267ad9..a4a2167 100644
    a b class BP_XProfile_Field_Type_Checkbox extends BP_XProfile_Field_Type { 
    2828                $this->category = _x( 'Multi Fields', 'xprofile field type category', 'buddypress' );
    2929                $this->name     = _x( 'Checkboxes', 'xprofile field type', 'buddypress' );
    3030
     31                $this->supports_multiple_values   = true;
    3132                $this->supports_multiple_defaults = true;
    3233                $this->accepts_null_value         = true;
    3334                $this->supports_options           = true;
  • src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php

    diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php
    index 5ecaa10..af92d00 100644
    a b class BP_XProfile_Field_Type_Multiselectbox extends BP_XProfile_Field_Type { 
    2828                $this->category = _x( 'Multi Fields', 'xprofile field type category', 'buddypress' );
    2929                $this->name     = _x( 'Multi Select Box', 'xprofile field type', 'buddypress' );
    3030
     31                $this->supports_multiple_values   = true;
    3132                $this->supports_multiple_defaults = true;
    3233                $this->accepts_null_value         = true;
    3334                $this->supports_options           = true;
  • src/bp-xprofile/classes/class-bp-xprofile-field-type.php

    diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type.php
    index f282a82..75035dd 100644
    a b abstract class BP_XProfile_Field_Type { 
    6666        public $supports_options = false;
    6767
    6868        /**
     69         * If allowed to store multiple values.
     70         *
     71         * @since 2.9.0
     72         * @var bool Does this field support multiple values? e.g. multiselectbox, checkbox.
     73         */
     74        public $supports_multiple_values = false;
     75
     76        /**
    6977         * If allowed to support multiple options as default.
    7078         *
    7179         * @since 2.0.0