Skip to:
Content

BuddyPress.org

Changeset 10179


Ignore:
Timestamp:
10/04/2015 02:27:22 AM (9 years ago)
Author:
dcavins
Message:

Introduce bp_the_profile_field_required_label().

Introduce a new template function,
bp_the_profile_field_required_label(), that
allows for translation and filtration of
‘required’ label for use with extended profile
fields.

Fixes #6521 and #6575.

Location:
trunk/src/bp-xprofile
Files:
11 edited

Legend:

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

    r10163 r10179  
    522522
    523523                <?php if ( empty( $field->can_delete )                                    ) : ?><?php esc_html_e( '(Primary)',  'buddypress' ); endif; ?>
    524                 <?php if ( bp_get_the_profile_field_is_required()                         ) : ?><?php esc_html_e( '(Required)', 'buddypress' ); endif; ?>
     524                <?php bp_the_profile_field_required_label(); ?>
    525525                <?php if ( bp_xprofile_get_meta( $field->id, 'field', 'signup_position' ) ) : ?><?php esc_html_e( '(Sign-up)',  'buddypress' ); endif; ?>
    526526                <?php if ( bp_get_member_types() ) : echo $field->get_member_type_label(); endif; ?>
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r10163 r10179  
    13301330        return apply_filters( 'bp_profile_settings_visibility_select', $retval, $r, $args );
    13311331    }
     1332
     1333/**
     1334 * Output the 'required' markup in extended profile field labels.
     1335 *
     1336 * @since 2.4.0
     1337 *
     1338 * @return string HTML for the required label.
     1339 */
     1340function bp_the_profile_field_required_label() {
     1341    echo bp_get_the_profile_field_required_label();
     1342}
     1343
     1344    /**
     1345     * Return the 'required' markup in extended profile field labels.
     1346     *
     1347     * @since 2.4.0
     1348     *
     1349     * @return string HTML for the required label.
     1350     */
     1351    function bp_get_the_profile_field_required_label() {
     1352        $retval = '';
     1353
     1354        if ( bp_get_the_profile_field_is_required() ) {
     1355            $translated_string = __( ' (required)', 'buddypress' );
     1356
     1357            $retval = '<span class="bp-required-field-label">';
     1358            $retval .= apply_filters( 'bp_get_the_profile_field_required_label', $translated_string, bp_get_the_profile_field_id() );
     1359            $retval .= '</span>';
     1360
     1361        }
     1362
     1363        return $retval;
     1364    }
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php

    r10163 r10179  
    7070            <label for="<?php bp_the_profile_field_input_name(); ?>">
    7171                <?php bp_the_profile_field_name(); ?>
    72                 <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    73                     <?php esc_html_e( '(required)', 'buddypress' ); ?>
    74                 <?php endif; ?>
     72                <?php bp_the_profile_field_required_label(); ?>
    7573            </label>
    7674
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php

    r10163 r10179  
    8080        <div class="datebox">
    8181
    82             <label for="<?php bp_the_profile_field_input_name(); ?>_day"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php esc_html_e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
     82            <label for="<?php bp_the_profile_field_input_name(); ?>_day">
     83                <?php bp_the_profile_field_name(); ?>
     84                <?php bp_the_profile_field_required_label(); ?>
     85            </label>
     86
    8387            <?php
    8488
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php

    r10163 r10179  
    7373        ) ); ?>
    7474
    75         <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 _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
     75        <label for="<?php bp_the_profile_field_input_name(); ?>[]">
     76            <?php bp_the_profile_field_name(); ?>
     77            <?php bp_the_profile_field_required_label(); ?>
     78        </label>
    7679
    7780        <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-number.php

    r10163 r10179  
    6767        <label for="<?php bp_the_profile_field_input_name(); ?>">
    6868            <?php bp_the_profile_field_name(); ?>
    69             <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    70                 <?php esc_html_e( '(required)', 'buddypress' ); ?>
    71             <?php endif; ?>
     69            <?php bp_the_profile_field_required_label(); ?>
    7270        </label>
    7371
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-radiobutton.php

    r10163 r10179  
    6969            <label for="<?php bp_the_profile_field_input_name(); ?>">
    7070                <?php bp_the_profile_field_name(); ?>
    71                 <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    72                     <?php esc_html_e( '(required)', 'buddypress' ); ?>
    73                 <?php endif; ?>
     71                <?php bp_the_profile_field_required_label(); ?>
    7472            </label>
    7573
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.php

    r10163 r10179  
    6767        <label for="<?php bp_the_profile_field_input_name(); ?>">
    6868            <?php bp_the_profile_field_name(); ?>
    69             <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    70                 <?php esc_html_e( '(required)', 'buddypress' ); ?>
    71             <?php endif; ?>
     69            <?php bp_the_profile_field_required_label(); ?>
    7270        </label>
    7371
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php

    r10163 r10179  
    6767        <label for="<?php bp_the_profile_field_input_name(); ?>">
    6868            <?php bp_the_profile_field_name(); ?>
    69             <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    70                 <?php esc_html_e( '(required)', 'buddypress' ); ?>
    71             <?php endif; ?>
     69            <?php bp_the_profile_field_required_label(); ?>
    7270        </label>
    7371
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-textbox.php

    r10163 r10179  
    6666        <label for="<?php bp_the_profile_field_input_name(); ?>">
    6767            <?php bp_the_profile_field_name(); ?>
    68             <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    69                 <?php esc_html_e( '(required)', 'buddypress' ); ?>
    70             <?php endif; ?>
     68            <?php bp_the_profile_field_required_label(); ?>
    7169        </label>
    7270
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-url.php

    r10163 r10179  
    6868        <label for="<?php bp_the_profile_field_input_name(); ?>">
    6969            <?php bp_the_profile_field_name(); ?>
    70             <?php if ( bp_get_the_profile_field_is_required() ) : ?>
    71                 <?php esc_html_e( '(required)', 'buddypress' ); ?>
    72             <?php endif; ?>
     70            <?php bp_the_profile_field_required_label(); ?>
    7371        </label>
    7472
Note: See TracChangeset for help on using the changeset viewer.