Skip to:
Content

BuddyPress.org

Changeset 13494


Ignore:
Timestamp:
06/01/2023 01:12:15 AM (3 years ago)
Author:
imath
Message:

Make new profile field/group description default to an empty string

Doing so prevents a PHP8.1 deprecation notice

Fixes #8862
Closes https://github.com/buddypress/buddypress/pull/111

Location:
trunk/src/bp-xprofile/classes
Files:
2 edited

Legend:

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

    r13484 r13494  
    15141514         */
    15151515        private function name_and_description() {
     1516                // Set default values.
     1517                $description = '';
     1518                $name        = '';
     1519
     1520                if ( $this->description ) {
     1521                        $description = $this->description;
     1522                }
     1523
     1524                if ( $this->name ) {
     1525                        $name = $this->name;
     1526                }
    15161527        ?>
    15171528
     
    15191530                        <div class="titlewrap">
    15201531                                <label id="title-prompt-text" for="title"><?php echo esc_html_x( 'Name (required)', 'XProfile admin edit field', 'buddypress' ); ?></label>
    1521                                 <input type="text" name="title" id="title" value="<?php echo esc_attr( $this->name ); ?>" autocomplete="off" />
     1532                                <input type="text" name="title" id="title" value="<?php echo esc_attr( $name ); ?>" autocomplete="off" />
    15221533                        </div>
    15231534                </div>
     
    15261537                        <h2><?php echo esc_html_x( 'Description', 'XProfile admin edit field', 'buddypress' ); ?></h2>
    15271538                        <div class="inside">
    1528                                 <label for="description" class="screen-reader-text"><?php
     1539                                <label for="description" class="screen-reader-text">
     1540                                        <?php
    15291541                                        /* translators: accessibility text */
    15301542                                        esc_html_e( 'Add description', 'buddypress' );
    1531                                 ?></label>
    1532                                 <textarea name="description" id="description" rows="8" cols="60"><?php echo esc_textarea( $this->description ); ?></textarea>
     1543                                        ?>
     1544                                </label>
     1545                                <textarea name="description" id="description" rows="8" cols="60"><?php echo esc_textarea( $description ); ?></textarea>
    15331546                        </div>
    15341547                </div>
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php

    r13475 r13494  
    466466         * @since 5.0.0
    467467         * @since 11.0.0 `$profile_group_id` accepts an array of profile group ids.
    468          * 
     468         *
    469469         * @global wpdb $wpdb WordPress database object.
    470470         *
     
    525525         *
    526526         * @since 5.0.0
    527          * 
     527         *
    528528         * @global wpdb $wpdb WordPress database object.
    529529         *
     
    619619         *
    620620         * @since 2.0.0
    621          * 
     621         *
    622622         * @global wpdb $wpdb WordPress database object.
    623623         *
     
    791791         *
    792792         * @since 1.6.0
    793          * 
     793         *
    794794         * @global wpdb $wpdb WordPress database object.
    795795         *
     
    850850                // New field group.
    851851                if ( empty( $this->id ) ) {
    852                         $title  = __( 'Add New Field Group', 'buddypress' );
    853                         $button = __( 'Save',                'buddypress' );
    854                         $action = add_query_arg( array(
    855                                 'page' => 'bp-profile-setup',
    856                                 'mode' => 'add_group',
    857                         ), $users_url );
     852                        $title       = __( 'Add New Field Group', 'buddypress' );
     853                        $button      = __( 'Save',                'buddypress' );
     854                        $action      = add_query_arg(
     855                                array(
     856                                        'page' => 'bp-profile-setup',
     857                                        'mode' => 'add_group',
     858                                ),
     859                                $users_url
     860                        );
     861                        $description = '';
    858862
    859863                // Existing field group.
    860864                } else {
    861                         $title  = __( 'Edit Field Group', 'buddypress' );
    862                         $button = __( 'Update',           'buddypress' );
    863                         $action = add_query_arg( array(
    864                                 'page'     => 'bp-profile-setup',
    865                                 'mode'     => 'edit_group',
    866                                 'group_id' => (int) $this->id,
    867                         ), $users_url );
     865                        $title       = __( 'Edit Field Group', 'buddypress' );
     866                        $button      = __( 'Update',           'buddypress' );
     867                        $action      = add_query_arg(
     868                                array(
     869                                        'page'     => 'bp-profile-setup',
     870                                        'mode'     => 'edit_group',
     871                                        'group_id' => (int) $this->id,
     872                                ),
     873                                $users_url
     874                        );
     875                        $description = $this->description;
    868876
    869877                        if ( $this->can_delete ) {
     
    903911                                                                <h2><?php esc_html_e( 'Field Group Description', 'buddypress' ); ?></h2>
    904912                                                                <div class="inside">
    905                                                                         <label for="group_description" class="screen-reader-text"><?php
     913                                                                        <label for="group_description" class="screen-reader-text">
     914                                                                                <?php
    906915                                                                                /* translators: accessibility text */
    907916                                                                                esc_html_e( 'Add description', 'buddypress' );
    908                                                                         ?></label>
    909                                                                         <textarea name="group_description" id="group_description" rows="8" cols="60"><?php echo esc_textarea( $this->description ); ?></textarea>
     917                                                                                ?>
     918                                                                        </label>
     919                                                                        <textarea name="group_description" id="group_description" rows="8" cols="60"><?php echo esc_textarea( $description ); ?></textarea>
    910920                                                                </div>
    911921                                                        </div>
Note: See TracChangeset for help on using the changeset viewer.