Skip to content

Commit

Permalink
Some work toward removing calls to bp_get_root_domain().
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Jul 10, 2024
1 parent 99b4745 commit 957e1e8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
8 changes: 5 additions & 3 deletions buddypress/groups/groups-loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ function ( $type ) {
}

// Exclude private groups if not current user's profile or don't have moderate access.
$private_groups = openlab_get_user_private_memberships( $user_id );
if ( ! bp_is_my_profile() && ! current_user_can( 'bp_moderate' ) ) {
$group_args['exclude'] = $private_groups;
if ( bp_is_user() ) {
$private_groups = openlab_get_user_private_memberships( bp_displayed_user_id() );
if ( ! bp_is_my_profile() && ! current_user_can( 'bp_moderate' ) ) {
$group_args['exclude'] = $private_groups;
}
}

?>
Expand Down
10 changes: 8 additions & 2 deletions buddypress/groups/index-directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Redirect to the home page if we're not on a valid group directory page.
if ( is_wp_error( $type_object ) ) {
bp_core_redirect( bp_get_root_domain() );
bp_core_redirect( bp_get_root_url() );
}

get_header();
Expand All @@ -19,7 +19,13 @@
}

$create_text = $type_object->get_can_be_cloned() ? __( 'Create / Clone', 'commons-in-a-box' ) : __( 'Create New', 'commons-in-a-box' );
$create_link = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-details/?group_type=' . $type_object->get_slug() . '&new=true';
$create_link = add_query_arg(
[
'group_type' => $type_object->get_slug(),
'new' => 'true',
],
bp_groups_get_create_url( [ 'group-details' ] )
);
?>

<div id="content" class="hfeed row">
Expand Down
2 changes: 1 addition & 1 deletion lib/course-clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function openlab_group_clone_details( $group_id ) {

$retval['site_id'] = cboxol_get_group_site_id( $group_id );
$retval['site_url'] = get_blog_option( $retval['site_id'], 'home' );
$retval['site_path'] = str_replace( bp_get_root_domain(), '', $retval['site_url'] );
$retval['site_path'] = str_replace( bp_get_root_url(), '', $retval['site_url'] );

$retval['term'] = openlab_get_group_term( $group_id );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/group-funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ function openlab_group_url_markup() {

<div class="group-url-fields">
<span class="group-url-domain">
<?php bp_root_domain(); ?>/<?php echo esc_html( bp_get_groups_root_slug() ); ?>/
<?php echo esc_html( trailingslashit( bp_get_groups_directory_url() ) ); ?>
</span>

<div class="group-url-path">
Expand Down
18 changes: 10 additions & 8 deletions lib/menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -1169,28 +1169,28 @@ function openlab_group_membership_tabs( $group = false ) {

$current_tab = bp_action_variable( 0 );

$group_type = groups_get_groupmeta( $bp->groups->current_group->id, 'wds_group_type' );
?>

<?php if ( bp_is_item_admin() ) : ?>
<li class="<?php echo 'manage-members' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/admin/manage-members"><?php esc_html_e( 'Membership', 'commons-in-a-box' ); ?></a></li>
<li class="<?php echo 'manage-members' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'manage-members' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Membership', 'commons-in-a-box' ); ?></a></li>

<?php if ( 'private' === $group->status ) : ?>
<li class="<?php echo 'membership-requests' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/admin/membership-requests"><?php esc_html_e( 'Member Requests', 'commons-in-a-box' ); ?></a></li>
<li class="<?php echo 'membership-requests' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'membership-requests' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Member Requests', 'commons-in-a-box' ); ?></a></li>
<?php endif; ?>
<?php else : ?>
<li class="<?php echo bp_is_current_action( 'members' ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/members"><?php esc_html_e( 'Membership', 'commons-in-a-box' ); ?></a></li>
<li class="<?php echo bp_is_current_action( 'members' ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_url( $group, bp_groups_get_path_chunks( [ 'members' ] ) ) ); ?>"><?php esc_html_e( 'Membership', 'commons-in-a-box' ); ?></a></li>
<?php endif; ?>

<?php if ( bp_group_is_member() && invite_anyone_access_test() && openlab_is_admin_truly_member() ) : ?>
<li class="<?php echo bp_is_current_action( 'invite-anyone' ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/invite-anyone"><?php esc_html_e( 'Invite New Members', 'commons-in-a-box' ); ?></a></li>
<li class="<?php echo bp_is_current_action( 'invite-anyone' ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_url( $group, bp_groups_get_path_chunks( [ 'invite-anyone' ] ) ) ); ?>"><?php esc_html_e( 'Invite New Members', 'commons-in-a-box' ); ?></a></li>
<?php endif; ?>

<?php if ( bp_is_item_admin() ) : ?>
<li class="<?php echo 'notifications' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/admin/notifications"><?php esc_html_e( 'Email Members', 'commons-in-a-box' ); ?></a></li>
<li class="<?php echo 'notifications' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'notifications' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Email Members', 'commons-in-a-box' ); ?></a></li>
<?php endif; ?>

<?php if ( bp_group_is_member() && openlab_is_admin_truly_member() ) : ?>
<li class="<?php echo bp_is_current_action( 'notifications' ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/notifications"><?php esc_html_e( 'Your Email Options', 'commons-in-a-box' ); ?></a></li>
<li class="<?php echo bp_is_current_action( 'notifications' ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_url( $group, bp_groups_get_path_chunks( [ 'notifications' ] ) ) ); ?>"><?php esc_html_e( 'Your Email Options', 'commons-in-a-box' ); ?></a></li>
<?php endif; ?>

<?php
Expand Down Expand Up @@ -1253,9 +1253,11 @@ function openlab_forum_tabs() {
while ( bbp_topics() ) {
bbp_the_topic();
}

$group_forum_permalink = bp_get_group_url( $group->id, bp_groups_get_path_chunks( [ 'forum' ] ) );
?>

<li <?php echo ( ! bp_action_variable() ? 'class="current-menu-item"' : '' ); ?> ><a href="<?php echo esc_attr( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug ); ?>/forum/"><?php esc_html_e( 'Discussion', 'commons-in-a-box' ); ?></a></li><!--
<li <?php echo ( ! bp_action_variable() ? 'class="current-menu-item"' : '' ); ?> ><a href="<?php echo esc_attr( $group_forum_permalink ); ?>"><?php esc_html_e( 'Discussion', 'commons-in-a-box' ); ?></a></li><!--
<?php if ( bp_is_action_variable( 'topic' ) ) : ?>
--><li class="current-menu-item hyphenate"><span><?php bbp_topic_title(); ?></span></li><!--
<?php endif; ?>
Expand Down

0 comments on commit 957e1e8

Please sign in to comment.