Skip to:
Content

BuddyPress.org

Ticket #5501: bp-xprofile.patch

File bp-xprofile.patch, 3.9 KB (added by williamsba1, 7 years ago)
  • bp-xprofile/bp-xprofile-functions.php

     
    7272                'datebox'        => 'BP_XProfile_Field_Type_Datebox',
    7373                'multiselectbox' => 'BP_XProfile_Field_Type_Multiselectbox',
    7474                'number'         => 'BP_XProfile_Field_Type_Number',
     75                'url'            => 'BP_XProfile_Field_Type_URL',
    7576                'radio'          => 'BP_XProfile_Field_Type_Radiobutton',
    7677                'selectbox'      => 'BP_XProfile_Field_Type_Selectbox',
    7778                'textarea'       => 'BP_XProfile_Field_Type_Textarea',
  • bp-xprofile/bp-xprofile-classes.php

     
    24962496        public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {}
    24972497}
    24982498
     2499
    24992500/**
     2501 * URL xprofile field type.
     2502 *
     2503 * @since BuddyPress (2.1.0)
     2504 */
     2505class BP_XProfile_Field_Type_URL extends BP_XProfile_Field_Type {
     2506
     2507        /**
     2508         * Constructor for the URL field type
     2509         *
     2510         * @since BuddyPress (2.1.0)
     2511         */
     2512        public function __construct() {
     2513                parent::__construct();
     2514
     2515                $this->category = _x( 'Single Fields', 'xprofile field type category', 'buddypress' );
     2516                $this->name     = _x( 'URL', 'xprofile field type', 'buddypress' );
     2517
     2518                $this->set_format( '/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/', 'replace' );
     2519                do_action( 'bp_xprofile_field_type_url', $this );
     2520        }
     2521
     2522        /**
     2523         * Output the edit field HTML for this field type.
     2524         *
     2525         * Must be used inside the {@link bp_profile_fields()} template loop.
     2526         *
     2527         * @param array $raw_properties Optional key/value array of {@link http://dev.w3.org/html5/markup/input.number.html permitted attributes} that you want to add.
     2528         * @since BuddyPress (2.1.0)
     2529         */
     2530        public function edit_field_html( array $raw_properties = array() ) {
     2531
     2532                // user_id is a special optional parameter that certain other fields types pass to {@link bp_the_profile_field_options()}.
     2533                if ( isset( $raw_properties['user_id'] ) ) {
     2534                        unset( $raw_properties['user_id'] );
     2535                }
     2536
     2537                $html = $this->get_edit_field_html_elements( array_merge(
     2538                        array(
     2539                                'type'  => 'url',
     2540                                'value' =>  esc_url( bp_get_the_profile_field_edit_value() ),
     2541                        ),
     2542                        $raw_properties
     2543                ) );
     2544        ?>
     2545                <label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php esc_html_e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
     2546                <input <?php echo $html; ?>>
     2547        <?php
     2548        }
     2549
     2550        /**
     2551         * Output HTML for this field type on the wp-admin Profile Fields screen.
     2552         *
     2553         * Must be used inside the {@link bp_profile_fields()} template loop.
     2554         *
     2555         * @param array $raw_properties Optional key/value array of permitted attributes that you want to add.
     2556         * @since BuddyPress (2.1.0)
     2557         */
     2558        public function admin_field_html( array $raw_properties = array() ) {
     2559                $html = $this->get_edit_field_html_elements( array_merge(
     2560                        array( 'type' => 'url' ),
     2561                        $raw_properties
     2562                ) );
     2563        ?>
     2564                <input <?php echo $html; ?>>
     2565        <?php
     2566        }
     2567
     2568        /**
     2569         * This method usually outputs HTML for this field type's children options on the wp-admin Profile Fields
     2570         * "Add Field" and "Edit Field" screens, but for this field type, we don't want it, so it's stubbed out.
     2571         *
     2572         * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen.
     2573         * @param string $control_type Optional. HTML input type used to render the current field's child options.
     2574         * @since BuddyPress (2.1.0)
     2575         */
     2576        public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {}
     2577}
     2578
     2579/**
    25002580 * Represents a type of XProfile field and holds meta information about the type of value that it accepts.
    25012581 *
    25022582 * @since BuddyPress (2.0.0)