Skip to:
Content

bbPress.org

Changeset 6481


Ignore:
Timestamp:
06/04/2017 09:34:59 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Tools: Introduce bbp_get_unique_array_values() helper function.

Use this when parsing private/hidden forum IDs for saving.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6445 r6481  
    123123
    124124/** Misc **********************************************************************/
     125
     126/**
     127 * Return the unique non-empty values of an array.
     128 *
     129 * @since 2.6.0 bbPress (r6481)
     130 *
     131 * @param array $array Array to get values of
     132 *
     133 * @return array
     134 */
     135function bbp_get_unique_array_values( $array = array() ) {
     136    return array_unique( array_filter( array_values( $array ) ) );
     137}
    125138
    126139/**
  • trunk/src/includes/forums/functions.php

    r6480 r6481  
    871871
    872872        // Update private forums minus this one
    873         update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
     873        update_option( '_bbp_private_forums', bbp_get_unique_array_values( $private ) );
    874874    }
    875875
     
    886886
    887887        // Update hidden forums minus this one
    888         update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
     888        update_option( '_bbp_hidden_forums', bbp_get_unique_array_values( $hidden ) );
    889889    }
    890890
     
    932932
    933933            // Update hidden forums minus this one
    934             update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
     934            update_option( '_bbp_hidden_forums', bbp_get_unique_array_values( $hidden ) );
    935935        }
    936936
     
    938938        $private   = bbp_get_private_forum_ids();
    939939        $private[] = $forum_id;
    940         update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
     940        update_option( '_bbp_private_forums', bbp_get_unique_array_values( $private ) );
    941941
    942942        // Update forums visibility setting
     
    982982
    983983            // Update private forums minus this one
    984             update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
     984            update_option( '_bbp_private_forums', bbp_get_unique_array_values( $private ) );
    985985        }
    986986
     
    988988        $hidden   = bbp_get_hidden_forum_ids();
    989989        $hidden[] = $forum_id;
    990         update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
     990        update_option( '_bbp_hidden_forums', bbp_get_unique_array_values( $hidden ) );
    991991
    992992        // Update forums visibility setting
Note: See TracChangeset for help on using the changeset viewer.