Skip to:
Content

BuddyPress.org

Changeset 13587


Ignore:
Timestamp:
09/29/2023 02:07:48 AM (18 months ago)
Author:
imath
Message:

Admin: improve code indentation of bp_get_ prefixed functions

Props plugindevs

Fixes #8998
Closes https://github.com/buddypress/buddypress/pull/169

Location:
trunk/src
Files:
2 edited

Legend:

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

    r13533 r13587  
    453453    echo bp_get_form_option( $option, $default, $slug );
    454454}
     455
     456/**
     457 * Return settings API option
     458 *
     459 * @since 1.6.0
     460 *
     461 *
     462 * @param string $option  Form option to return.
     463 * @param string $default Form option default.
     464 * @param bool   $slug    Form option slug.
     465 * @return string
     466 */
     467function bp_get_form_option( $option, $default = '', $slug = false ) {
     468
     469    // Get the option and sanitize it.
     470    $value = bp_get_option( $option, $default );
     471
     472    // Slug?
     473    if ( true === $slug ) {
     474
     475        /**
     476         * Filters the slug value in the form field.
     477         *
     478         * @since 1.6.0
     479         *
     480         * @param string $value Value being returned for the requested option.
     481         */
     482        $value = esc_attr( apply_filters( 'editable_slug', $value ) );
     483    } else { // Not a slug.
     484        $value = esc_attr( $value );
     485    }
     486
     487    // Fallback to default.
     488    if ( empty( $value ) ) {
     489        $value = $default;
     490    }
     491
    455492    /**
    456      * Return settings API option
     493     * Filters the settings API option.
    457494     *
    458495     * @since 1.6.0
    459496     *
    460      *
    461      * @param string $option  Form option to return.
    462      * @param string $default Form option default.
    463      * @param bool   $slug    Form option slug.
    464      * @return string
     497     * @param string $value  Value being returned for the requested option.
     498     * @param string $option Option whose value is being requested.
    465499     */
    466     function bp_get_form_option( $option, $default = '', $slug = false ) {
    467 
    468         // Get the option and sanitize it.
    469         $value = bp_get_option( $option, $default );
    470 
    471         // Slug?
    472         if ( true === $slug ) {
    473 
    474             /**
    475              * Filters the slug value in the form field.
    476              *
    477              * @since 1.6.0
    478              *
    479              * @param string $value Value being returned for the requested option.
    480              */
    481             $value = esc_attr( apply_filters( 'editable_slug', $value ) );
    482         } else { // Not a slug.
    483             $value = esc_attr( $value );
    484         }
    485 
    486         // Fallback to default.
    487         if ( empty( $value ) )
    488             $value = $default;
    489 
    490         /**
    491          * Filters the settings API option.
    492          *
    493          * @since 1.6.0
    494          *
    495          * @param string $value  Value being returned for the requested option.
    496          * @param string $option Option whose value is being requested.
    497          */
    498         return apply_filters( 'bp_get_form_option', $value, $option );
    499     }
     500    return apply_filters( 'bp_get_form_option', $value, $option );
     501}
  • trunk/src/bp-settings/bp-settings-template.php

    r13503 r13587  
    1919    echo bp_get_settings_slug();
    2020}
     21
     22/**
     23 * Return the settings component slug.
     24 *
     25 * @since 1.5.0
     26 *
     27 * @return string
     28 */
     29function bp_get_settings_slug() {
     30
    2131    /**
    22      * Return the settings component slug.
     32     * Filters the Settings component slug.
    2333     *
    2434     * @since 1.5.0
    2535     *
    26      * @return string
     36     * @param string $slug Settings component slug.
    2737     */
    28     function bp_get_settings_slug() {
    29 
    30         /**
    31          * Filters the Settings component slug.
    32          *
    33          * @since 1.5.0
    34          *
    35          * @param string $slug Settings component slug.
    36          */
    37         return apply_filters( 'bp_get_settings_slug', buddypress()->settings->slug );
    38     }
     38    return apply_filters( 'bp_get_settings_slug', buddypress()->settings->slug );
     39}
    3940
    4041/**
     
    4647    echo bp_get_settings_root_slug();
    4748}
     49
     50/**
     51 * Return the settings component root slug.
     52 *
     53 * @since 1.5.0
     54 *
     55 * @return string
     56 */
     57function bp_get_settings_root_slug() {
     58
    4859    /**
    49      * Return the settings component root slug.
     60     * Filters the Settings component root slug.
    5061     *
    5162     * @since 1.5.0
    5263     *
    53      * @return string
     64     * @param string $root_slug Settings component root slug.
    5465     */
    55     function bp_get_settings_root_slug() {
    56 
    57         /**
    58          * Filters the Settings component root slug.
    59          *
    60          * @since 1.5.0
    61          *
    62          * @param string $root_slug Settings component root slug.
    63          */
    64         return apply_filters( 'bp_get_settings_root_slug', buddypress()->settings->root_slug );
    65     }
     66    return apply_filters( 'bp_get_settings_root_slug', buddypress()->settings->root_slug );
     67}
    6668
    6769/**
Note: See TracChangeset for help on using the changeset viewer.