Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/01/2015 04:18:13 AM (10 years ago)
Author:
tw2113
Message:

First pass of documentation cleanup for the XProfile Component.

See #6406.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type.php

    r10142 r10163  
    11<?php
    22/**
    3  * BuddyPress XProfile Classes
     3 * BuddyPress XProfile Classes.
    44 *
    55 * @package BuddyPress
     
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    1818
    1919    /**
    20      * @since 2.0.0
    21      * @var array Field type validation regexes
     20     * Validation regex rules for field type.
     21
     22     * @since 2.0.0
     23     * @var array Field type validation regexes.
    2224     */
    2325    protected $validation_regex = array();
    2426
    2527    /**
    26      * @since 2.0.0
    27      * @var array Field type whitelisted values
     28     * Whitelisted values for field type.
     29     *
     30     * @since 2.0.0
     31     * @var array Field type whitelisted values.
    2832     */
    2933    protected $validation_whitelist = array();
    3034
    3135    /**
    32      * @since 2.0.0
    33      * @var string The name of this field type
     36     * Name for field type.
     37     *
     38     * @since 2.0.0
     39     * @var string The name of this field type.
    3440     */
    3541    public $name = '';
     
    4450
    4551    /**
     52     * If allowed to store null/empty values.
     53     *
    4654     * @since 2.0.0
    4755     * @var bool If this is set, allow BP to store null/empty values for this field type.
     
    5866
    5967    /**
     68     * If allowed to support multiple options as default.
     69     *
    6070     * @since 2.0.0
    6171     * @var bool Does this field type support multiple options being set as default values? e.g. multiselectbox, checkbox.
     
    6474
    6575    /**
    66      * @since 2.0.0
    67      * @var BP_XProfile_Field If this object is created by instantiating a {@link BP_XProfile_Field}, this is a reference back to that object.
     76     * If object is created by an BP_XProfile_Field object.
     77     *
     78     * @since 2.0.0
     79     * @var BP_XProfile_Field If this object is created by instantiating a {@link BP_XProfile_Field},
     80     *                        this is a reference back to that object.
    6881     */
    6982    public $field_obj = null;
    7083
    7184    /**
    72      * Constructor
     85     * Constructor.
    7386     *
    7487     * @since 2.0.0
     
    93106     * it's successful as long as the new value matches any one of the registered formats.
    94107     *
    95      * @param string $format Regex string
    96      * @param string $replace_format Optional; if 'replace', replaces the format instead of adding to it. Defaults to 'add'.
     108     * @since 2.0.0
     109     *
     110     * @param string $format         Regex string.
     111     * @param string $replace_format Optional; if 'replace', replaces the format instead of adding to it.
     112     *                               Defaults to 'add'.
     113     *
    97114     * @return BP_XProfile_Field_Type
    98      * @since 2.0.0
    99115     */
    100116    public function set_format( $format, $replace_format = 'add' ) {
     
    127143     * it's successful as long as the new value matches any one of the registered formats.
    128144     *
    129      * @param string|array $values
     145     * @since 2.0.0
     146     *
     147     * @param string|array $values Whitelisted values.
     148     *
    130149     * @return BP_XProfile_Field_Type
    131      * @since 2.0.0
    132150     */
    133151    public function set_whitelist_values( $values ) {
     
    154172     * This method doesn't support chaining.
    155173     *
    156      * @param string|array $values Value to check against the registered formats
     174     * @since 2.0.0
     175     *
     176     * @param string|array $values Value to check against the registered formats.
     177     *
    157178     * @return bool True if the value validates
    158      * @since 2.0.0
    159179     */
    160180    public function is_valid( $values ) {
    161181        $validated = false;
    162182
    163         // Some types of field (e.g. multi-selectbox) may have multiple values to check
     183        // Some types of field (e.g. multi-selectbox) may have multiple values to check.
    164184        foreach ( (array) $values as $value ) {
    165185
     
    176196        }
    177197
    178         // Handle field types with accepts_null_value set if $values is an empty array
     198        // Handle field types with accepts_null_value set if $values is an empty array.
    179199        if ( ( false === $validated ) && is_array( $values ) && empty( $values ) && $this->accepts_null_value ) {
    180200            $validated = true;
     
    205225     * Must be used inside the {@link bp_profile_fields()} template loop.
    206226     *
     227     * @since 2.0.0
     228     *
    207229     * @param array $raw_properties Optional key/value array of permitted attributes that you want to add.
    208      * @since 2.0.0
    209230     */
    210231    abstract public function edit_field_html( array $raw_properties = array() );
     232
     233    /**
     234     * Output HTML for this field type on the wp-admin Profile Fields screen.
     235     *
     236     * Must be used inside the {@link bp_profile_fields()} template loop.
     237     *
     238     * @param array $raw_properties Optional key/value array of permitted attributes that you want to add.
     239     * @since 2.0.0
     240     */
     241    abstract public function admin_field_html( array $raw_properties = array() );
    211242
    212243    /**
     
    222253     * Must be used inside the {@link bp_profile_fields()} template loop.
    223254     *
     255     * @since 2.0.0
     256     *
    224257     * @param array $args Optional. The arguments passed to {@link bp_the_profile_field_options()}.
    225      * @since 2.0.0
    226258     */
    227259    public function edit_field_options_html( array $args = array() ) {}
    228 
    229     /**
    230      * Output HTML for this field type on the wp-admin Profile Fields screen.
    231      *
    232      * Must be used inside the {@link bp_profile_fields()} template loop.
    233      *
    234      * @param array $raw_properties Optional key/value array of permitted attributes that you want to add.
    235      * @since 2.0.0
    236      */
    237     abstract public function admin_field_html( array $raw_properties = array() );
    238260
    239261    /**
     
    246268     * Must be used inside the {@link bp_profile_fields()} template loop.
    247269     *
     270     * @since 2.0.0
     271     *
    248272     * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen.
    249      * @param string $control_type Optional. HTML input type used to render the current field's child options.
    250      * @since 2.0.0
     273     * @param string            $control_type  Optional. HTML input type used to render the current
     274     *                          field's child options.
    251275     */
    252276    public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {
     
    295319                        }
    296320
    297                         // Grab the values from $_POST to use as the form's options
     321                        // Grab the values from $_POST to use as the form's options.
    298322                        $options[] = (object) array(
    299323                            'id'                => -1,
     
    315339                }
    316340
    317                 // Render the markup for the children options
     341                // Render the markup for the children options.
    318342                if ( ! empty( $options ) ) {
    319343                    $default_name = '';
     
    385409     * @since 2.1.0
    386410     *
    387      * @param mixed $submitted_value Submitted value.
     411     * @param mixed $field_value Submitted field value.
     412     *
    388413     * @return mixed
    389414     */
     
    402427     *
    403428     * @param mixed $field_value Field value.
     429     *
    404430     * @return mixed
    405431     */
     
    416442     * This method was intended to be static but couldn't be because php.net/lsb/ requires PHP >= 5.3.
    417443     *
     444     * @since 2.0.0
     445     *
    418446     * @param array $properties Optional key/value array of attributes for this edit field.
     447     *
    419448     * @return string
    420      * @since 2.0.0
    421449     */
    422450    protected function get_edit_field_html_elements( array $properties = array() ) {
     
    431459        }
    432460
    433         $html = '';
    434 
    435461        /**
    436462         * Filters the edit html elements and attributes.
Note: See TracChangeset for help on using the changeset viewer.