Skip to:
Content

BuddyPress.org

Changeset 9941


Ignore:
Timestamp:
06/12/2015 02:55:33 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Groups: Add $step parameter to bp_is_last_group_creation_step() & bp_is_first_group_creation_step() to allow comparing any step to first & last. Retains default behavior if no step is passed.

This change improves group creation step calculations by enabling simpler comparisons in circumstances where the creation step in question may not be the current one.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-template.php

    r9940 r9941  
    47784778 * @since BuddyPress (1.1.0)
    47794779 *
    4780  * @return bool True if yes, False if no
    4781  */
    4782 function bp_is_last_group_creation_step() {
     4780 * @param  string $step Step to compare
     4781 * @return bool         True if yes, False if no
     4782 */
     4783function bp_is_last_group_creation_step( $step = '' ) {
     4784
     4785    // Use current step, if no step passed
     4786    if ( empty( $step ) ) {
     4787        $step = bp_get_groups_current_create_step();
     4788    }
     4789
     4790    // Get the last step
    47834791    $bp     = buddypress();
    47844792    $steps  = array_keys( $bp->groups->group_creation_steps );
    4785     $step   = array_pop( $steps );
    4786     $retval = ( $step === bp_get_groups_current_create_step() );
     4793    $l_step = array_pop( $steps );
     4794
     4795    // Compare last step to step
     4796    $retval = ( $l_step === $step );
    47874797
    47884798    return (bool) apply_filters( 'bp_is_last_group_creation_step', $retval, $steps, $step );
     
    47944804 * @since BuddyPress (1.1.0)
    47954805 *
    4796  * @return bool True if yes, False if no
    4797  */
    4798 function bp_is_first_group_creation_step() {
     4806 * @param  string $step Step to compare
     4807 * @return bool         True if yes, False if no
     4808 */
     4809function bp_is_first_group_creation_step( $step = '' ) {
     4810
     4811    // Use current step, if no step passed
     4812    if ( empty( $step ) ) {
     4813        $step = bp_get_groups_current_create_step();
     4814    }
     4815
     4816    // Get the first step
    47994817    $bp     = buddypress();
    48004818    $steps  = array_keys( $bp->groups->group_creation_steps );
    4801     $step   = array_shift( $steps );
    4802     $retval = ( $step === bp_get_groups_current_create_step() );
     4819    $f_step = array_shift( $steps );
     4820
     4821    // Compare first step to step
     4822    $retval = ( $f_step === $step );
    48034823
    48044824    return (bool) apply_filters( 'bp_is_first_group_creation_step', $retval, $steps, $step );
     
    48664886         *
    48674887         * @param array $items Array of friends.
    4868          */     
     4888         */
    48694889        $invitable_friends = apply_filters( 'bp_get_new_group_invite_friend_list', $items, $r, $args );
    48704890
Note: See TracChangeset for help on using the changeset viewer.