Changeset 13302
- Timestamp:
- 07/22/2022 11:44:14 AM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/deprecated/11.0.php
r13301 r13302 34 34 return array(); 35 35 } 36 37 /** 38 * Catch the arguments for buttons 39 * 40 * @since 3.0.0 41 * @deprecated 11.0.0 42 * 43 * @param array $button The arguments of the button that BuddyPress is about to create. 44 * 45 * @return array An empty array to stop the button creation process. 46 */ 47 function bp_nouveau_groups_catch_button_args( $button = array() ) { 48 _deprecated_function( __FUNCTION__, '11.0.0' ); 49 50 /** 51 * Globalize the arguments so that we can use it 52 * in bp_nouveau_get_groups_buttons(). 53 */ 54 bp_nouveau()->groups->button_args = $button; 55 56 // return an empty array to stop the button creation process 57 return array(); 58 } -
trunk/src/bp-groups/bp-groups-template.php
r13296 r13302 3564 3564 echo bp_get_group_join_button( $group ); 3565 3565 } 3566 /** 3567 * Return button to join a group.3568 * 3569 * @since 1.0.03570 * 3571 * @param object|bool $group Single group object.3572 * @ return false|string3573 * /3574 function bp_get_group_join_button( $group = false ) {3575 global $groups_template;3576 3577 // Set group to current loop group if none passed. 3578 if ( empty( $group ) ) {3579 $group =& $groups_template->group;3566 3567 /** 3568 * Get the arguments for the Join button group 3569 * 3570 * @since 11.0.0 3571 * 3572 * @param BP_Groups_Group $group The group object. 3573 * @return Array The arguments for the Join button group 3574 */ 3575 function bp_groups_get_group_join_button_args( $group = null ) { 3576 $button_args = array(); 3577 3578 if ( empty( $group->id ) ) { 3579 return $button_args; 3580 3580 } 3581 3581 3582 3582 // Don't show button if not logged in or previously banned. 3583 3583 if ( ! is_user_logged_in() || bp_group_is_user_banned( $group ) ) { 3584 return false;3584 return $button_args; 3585 3585 } 3586 3586 3587 3587 // Group creation was not completed or status is unknown. 3588 3588 if ( empty( $group->status ) ) { 3589 return false;3589 return $button_args; 3590 3590 } 3591 3591 … … 3596 3596 $group_admins = groups_get_group_admins( $group->id ); 3597 3597 if ( ( 1 == count( $group_admins ) ) && ( bp_loggedin_user_id() === (int) $group_admins[0]->user_id ) ) { 3598 return false;3598 return $button_args; 3599 3599 } 3600 3600 3601 3601 // Setup button attributes. 3602 $button = array(3602 $button_args = array( 3603 3603 'id' => 'leave_group', 3604 3604 'component' => 'groups', … … 3609 3609 'link_href' => wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'leave-group' ), 'groups_leave_group' ), 3610 3610 'link_text' => __( 'Leave Group', 'buddypress' ), 3611 'link_title' => __( 'Leave Group', 'buddypress' ), 3611 3612 'link_class' => 'group-button leave-group', 3612 3613 ); … … 3618 3619 switch ( $group->status ) { 3619 3620 case 'hidden' : 3620 return false;3621 return $button_args; 3621 3622 3622 3623 case 'public': 3623 $button = array(3624 $button_args = array( 3624 3625 'id' => 'join_group', 3625 3626 'component' => 'groups', … … 3630 3631 'link_href' => wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'join' ), 'groups_join_group' ), 3631 3632 'link_text' => __( 'Join Group', 'buddypress' ), 3633 'link_title' => __( 'Join Group', 'buddypress' ), 3632 3634 'link_class' => 'group-button join-group', 3633 3635 ); … … 3639 3641 // show an "Accept Invitation" button. 3640 3642 if ( $group->is_invited ) { 3641 $button = array(3643 $button_args = array( 3642 3644 'id' => 'accept_invite', 3643 3645 'component' => 'groups', … … 3648 3650 'link_href' => add_query_arg( 'redirect_to', bp_get_group_permalink( $group ), bp_get_group_accept_invite_link( $group ) ), 3649 3651 'link_text' => __( 'Accept Invitation', 'buddypress' ), 3652 'link_title' => __( 'Accept Invitation', 'buddypress' ), 3650 3653 'link_class' => 'group-button accept-invite', 3651 3654 ); … … 3654 3657 // show a "Request Sent" button. 3655 3658 } elseif ( $group->is_pending ) { 3656 $button = array(3659 $button_args = array( 3657 3660 'id' => 'membership_requested', 3658 3661 'component' => 'groups', … … 3663 3666 'link_href' => bp_get_group_permalink( $group ), 3664 3667 'link_text' => __( 'Request Sent', 'buddypress' ), 3668 'link_title' => __( 'Request Sent', 'buddypress' ), 3665 3669 'link_class' => 'group-button pending membership-requested', 3666 3670 ); … … 3669 3673 // show a "Request Membership" button. 3670 3674 } else { 3671 $button = array(3675 $button_args = array( 3672 3676 'id' => 'request_membership', 3673 3677 'component' => 'groups', … … 3678 3682 'link_href' => wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'request-membership' ), 'groups_request_membership' ), 3679 3683 'link_text' => __( 'Request Membership', 'buddypress' ), 3684 'link_title' => __( 'Request Membership', 'buddypress' ), 3680 3685 'link_class' => 'group-button request-membership', 3681 3686 ); … … 3687 3692 3688 3693 /** 3689 * Filters the HTMLbutton for joining a group.3694 * Filters the arguments of the button for joining a group. 3690 3695 * 3691 3696 * @since 1.2.6 3692 3697 * @since 2.4.0 Added $group parameter to filter args. 3693 3698 * 3694 * @param string $button HTML button for joining a group. 3695 * @param object $group BuddyPress group object 3696 */ 3697 return bp_get_button( apply_filters( 'bp_get_group_join_button', $button, $group ) ); 3699 * @param array $button_args The arguments for the button. 3700 * @param object $group BuddyPress group object 3701 */ 3702 return apply_filters( 'bp_get_group_join_button', $button_args, $group ); 3703 } 3704 /** 3705 * Return button to join a group. 3706 * 3707 * @since 1.0.0 3708 * @since 11.0.0 uses `bp_groups_get_group_join_button_args()`. 3709 * 3710 * @param object|bool $group Single group object. 3711 * @return false|string 3712 */ 3713 function bp_get_group_join_button( $group = false ) { 3714 global $groups_template; 3715 3716 // Set group to current loop group if none passed. 3717 if ( empty( $group ) ) { 3718 $group =& $groups_template->group; 3719 } 3720 3721 $button_args = bp_groups_get_group_join_button_args( $group ); 3722 3723 if ( ! array_filter( $button_args ) ) { 3724 return false; 3725 } 3726 3727 return bp_get_button( $button_args ); 3698 3728 } 3699 3729 -
trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php
r13192 r13302 661 661 662 662 /** 663 * Catch the arguments for buttons664 *665 * @since 3.0.0666 *667 * @param array $button The arguments of the button that BuddyPress is about to create.668 *669 * @return array An empty array to stop the button creation process.670 */671 function bp_nouveau_groups_catch_button_args( $button = array() ) {672 /**673 * Globalize the arguments so that we can use it674 * in bp_nouveau_get_groups_buttons().675 */676 bp_nouveau()->groups->button_args = $button;677 678 // return an empty array to stop the button creation process679 return array();680 }681 682 /**683 663 * Catch the content hooked to the 'bp_group_header_meta' action 684 664 * -
trunk/src/bp-templates/bp-nouveau/includes/groups/template-tags.php
r13193 r13302 997 997 // Membership button on groups loop or single group's header 998 998 } else { 999 /* 1000 * This filter workaround is waiting for a core adaptation 1001 * so that we can directly get the groups button arguments 1002 * instead of the button. 1003 * 1004 * See https://buddypress.trac.wordpress.org/ticket/7126 1005 */ 1006 add_filter( 'bp_get_group_join_button', 'bp_nouveau_groups_catch_button_args', 100, 1 ); 1007 1008 bp_get_group_join_button( $group ); 1009 1010 remove_filter( 'bp_get_group_join_button', 'bp_nouveau_groups_catch_button_args', 100, 1 ); 1011 1012 if ( isset( bp_nouveau()->groups->button_args ) && bp_nouveau()->groups->button_args ) { 1013 $button_args = bp_nouveau()->groups->button_args; 1014 1015 // If we pass through parent classes merge those into the existing ones 1016 if ( $parent_class ) { 1017 $parent_class .= ' ' . $button_args['wrapper_class']; 1018 } 1019 1020 // The join or leave group header button should default to 'button' 1021 // Reverse the earler button var to set default as 'button' not 'a' 1022 if ( empty( $args['button_element'] ) ) { 1023 $button_element = 'button'; 1024 } 1025 1026 $buttons['group_membership'] = array( 1027 'id' => 'group_membership', 1028 'position' => 5, 1029 'component' => $button_args['component'], 1030 'must_be_logged_in' => $button_args['must_be_logged_in'], 1031 'block_self' => $button_args['block_self'], 1032 'parent_element' => $parent_element, 1033 'button_element' => $button_element, 1034 'link_text' => $button_args['link_text'], 1035 'parent_attr' => array( 1036 'id' => $button_args['wrapper_id'], 1037 'class' => $parent_class, 1038 ), 1039 'button_attr' => array( 1040 'id' => ! empty( $button_args['link_id'] ) ? $button_args['link_id'] : '', 1041 'class' => $button_args['link_class'] . ' button', 1042 'rel' => ! empty( $button_args['link_rel'] ) ? $button_args['link_rel'] : '', 1043 'title' => '', 1044 ), 1045 ); 999 $button_args = bp_groups_get_group_join_button_args( $group ); 1000 1001 // If we pass through parent classes merge those into the existing ones 1002 if ( $parent_class ) { 1003 $parent_class .= ' ' . $button_args['wrapper_class']; 1004 } 1005 1006 // The join or leave group header button should default to 'button' 1007 // Reverse the earler button var to set default as 'button' not 'a' 1008 if ( empty( $args['button_element'] ) ) { 1009 $button_element = 'button'; 1010 } 1011 1012 $buttons['group_membership'] = array( 1013 'id' => 'group_membership', 1014 'position' => 5, 1015 'component' => $button_args['component'], 1016 'must_be_logged_in' => $button_args['must_be_logged_in'], 1017 'block_self' => $button_args['block_self'], 1018 'parent_element' => $parent_element, 1019 'button_element' => $button_element, 1020 'link_text' => $button_args['link_text'], 1021 'link_title' => $button_args['link_title'], 1022 'parent_attr' => array( 1023 'id' => $button_args['wrapper_id'], 1024 'class' => $parent_class, 1025 ), 1026 'button_attr' => array( 1027 'id' => ! empty( $button_args['link_id'] ) ? $button_args['link_id'] : '', 1028 'class' => $button_args['link_class'] . ' button', 1029 'rel' => ! empty( $button_args['link_rel'] ) ? $button_args['link_rel'] : '', 1030 'title' => '', 1031 ), 1032 ); 1046 1033 1047 1034 // If button element set add nonce 'href' link to data-attr attr. … … 1051 1038 // Else this is an anchor so use an 'href' attr. 1052 1039 $buttons['group_membership']['button_attr']['href'] = $button_args['link_href']; 1053 }1054 1055 unset( bp_nouveau()->groups->button_args );1056 1040 } 1057 1041 }
Note: See TracChangeset
for help on using the changeset viewer.