Skip to content

Commit

Permalink
Move openlab_group_admin_tabs() markup into theme template.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Jul 11, 2024
1 parent 5e744fa commit a560d60
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 65 deletions.
2 changes: 1 addition & 1 deletion buddypress/groups/single/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<div class="submenu-text pull-left bold"><?php esc_html_e( 'Settings:', 'commons-in-a-box' ); ?></div>
<ul class="nav nav-inline">
<?php openlab_group_admin_tabs(); ?>
<?php bp_get_template_part( 'groups/single/nav/admin' ); ?>
</ul>
<?php endif; ?>
</div><!-- .submenu -->
Expand Down
68 changes: 68 additions & 0 deletions buddypress/groups/single/nav/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* 'Admin' nav markup.
*
* @since 1.6.0 Moved to this file from openlab_group_admin_tabs().
*/

$group = groups_get_current_group();

$current_tab = bp_action_variable( 0 );

$group_type = cboxol_get_group_group_type( $group->id );

// Portfolio tabs look different from other groups
?>
<?php if ( cboxol_is_portfolio() ) : ?>
<?php if ( bp_is_item_admin() || bp_is_item_mod() ) { ?>
<li class="<?php ( 'edit-details' === $current_tab || empty( $current_tab ) ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'edit-details' ], 'manage' ) ) ); ?>"><?php echo esc_html( $group_type->get_label( 'group_details' ) ); ?></a></li>
<?php } ?>

<li class="<?php echo 'site-details' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'site-details' ], 'manage' ) ) ); ?>"><?php echo esc_html_x( 'Site', 'Group admin nav item', 'commons-in-a-box' ); ?></a></li>

<li class="<?php echo 'group-settings' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'group-settings' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Settings', 'commons-in-a-box' ); ?></a></li>

<li class="delete-button <?php echo 'delete-group' === $current_tab ? 'current-menu-item' : ''; ?>"><span class="fa fa-minus-circle"></span><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'delete-group' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Delete Portfolio', 'commons-in-a-box' ); ?></a></li>

<?php else : ?>

<?php if ( bp_is_item_admin() || bp_is_item_mod() ) { ?>
<li class="<?php ( 'edit-details' === $current_tab || empty( $current_tab ) ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'edit-details' ], 'manage' ) ) ); ?>"><?php echo esc_html( $group_type->get_label( 'group_details' ) ); ?></a></li>
<?php } ?>

<?php
if ( ! bp_is_item_admin() ) {
return false;
}
?>

<li class="<?php echo 'site-details' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'site-details' ], 'manage' ) ) ); ?>"><?php echo esc_html_x( 'Site', 'Group admin nav item', 'commons-in-a-box' ); ?></a></li>

<li class="<?php echo 'group-settings' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'group-settings' ], 'manage' ) ) ); ?>"><?php esc_attr_e( 'Settings', 'commons-in-a-box' ); ?></a></li>

<?php if ( $group_type->get_can_be_cloned() ) : ?>
<?php
$clone_link = add_query_arg(
array(
'group_type' => $group_type->get_slug(),
'clone' => bp_get_current_group_id(),
),
bp_get_groups_directory_permalink() . 'create/step/group-details/'
);
?>

<li class="clone-button <?php 'clone-group' === $current_tab ? 'current-menu-item' : ''; ?>"><span class="fa fa-plus-circle"></span><a href="<?php echo esc_url( $clone_link ); ?>"><?php esc_html_e( 'Clone', 'commons-in-a-box' ); ?></a></li>
<?php endif ?>

<li class="delete-button last-item <?php echo 'delete-group' === $current_tab ? 'current-menu-item' : ''; ?>"><span class="fa fa-minus-circle"></span><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'delete-group' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Delete', 'commons-in-a-box' ); ?></a></li>

<?php if ( $group_type->get_is_portfolio() ) : ?>
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<li class="portfolio-displayname pull-right"><span class="highlight"><?php echo bp_core_get_userlink( openlab_get_user_id_from_portfolio_group_id( bp_get_group_id() ) ); ?></span></li>
<?php else : ?>
<?php // translators: last active timestamp ?>
<li class="info-line pull-right"><span class="timestamp info-line-timestamp visible-lg"><span class="fa fa-undo"></span> <?php echo esc_html( sprintf( __( 'active %s', 'commons-in-a-box' ), bp_get_group_last_active() ) ); ?></span></li>
<?php endif; ?>

<?php endif; ?>
74 changes: 10 additions & 64 deletions lib/menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,74 +1101,19 @@ function openlab_group_submenu_nav() {
add_action( 'bp_screens', 'openlab_group_submenu_nav', 1 );

/**
* Markup for group admin tabs
* Markup for group admin tabs.
*
* @since 1.6.0 Markup was moved into theme template file.
*
* @param BP_Groups_Group $group Optional. Group object. Deprecated.
* @return void
*/
function openlab_group_admin_tabs( $group = false ) {
global $bp, $groups_template;

if ( ! $group ) {
$group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group;
if ( false !== $group ) {
_deprecated_argument( __FUNCTION__, '1.6.0', 'The $group parameter is no longer used.' );
}

$current_tab = bp_action_variable( 0 );

$group_type = cboxol_get_group_group_type( $group->id );

// Portfolio tabs look different from other groups
?>
<?php if ( cboxol_is_portfolio() ) : ?>
<?php if ( bp_is_item_admin() || bp_is_item_mod() ) { ?>
<li class="<?php ( 'edit-details' === $current_tab || empty( $current_tab ) ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'edit-details' ], 'manage' ) ) ); ?>"><?php echo esc_html( $group_type->get_label( 'group_details' ) ); ?></a></li>
<?php } ?>

<li class="<?php echo 'site-details' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'site-details' ], 'manage' ) ) ); ?>"><?php echo esc_html_x( 'Site', 'Group admin nav item', 'commons-in-a-box' ); ?></a></li>

<li class="<?php echo 'group-settings' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'group-settings' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Settings', 'commons-in-a-box' ); ?></a></li>

<li class="delete-button <?php echo 'delete-group' === $current_tab ? 'current-menu-item' : ''; ?>"><span class="fa fa-minus-circle"></span><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'delete-group' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Delete Portfolio', 'commons-in-a-box' ); ?></a></li>

<?php else : ?>

<?php if ( bp_is_item_admin() || bp_is_item_mod() ) { ?>
<li class="<?php ( 'edit-details' === $current_tab || empty( $current_tab ) ) ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'edit-details' ], 'manage' ) ) ); ?>"><?php echo esc_html( $group_type->get_label( 'group_details' ) ); ?></a></li>
<?php } ?>

<?php
if ( ! bp_is_item_admin() ) {
return false;
}
?>

<li class="<?php echo 'site-details' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'site-details' ], 'manage' ) ) ); ?>"><?php echo esc_html_x( 'Site', 'Group admin nav item', 'commons-in-a-box' ); ?></a></li>

<li class="<?php echo 'group-settings' === $current_tab ? 'current-menu-item' : ''; ?>"><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'group-settings' ], 'manage' ) ) ); ?>"><?php esc_attr_e( 'Settings', 'commons-in-a-box' ); ?></a></li>

<?php if ( $group_type->get_can_be_cloned() ) : ?>
<?php
$clone_link = add_query_arg(
array(
'group_type' => $group_type->get_slug(),
'clone' => bp_get_current_group_id(),
),
bp_get_groups_directory_permalink() . 'create/step/group-details/'
);
?>

<li class="clone-button <?php 'clone-group' === $current_tab ? 'current-menu-item' : ''; ?>"><span class="fa fa-plus-circle"></span><a href="<?php echo esc_url( $clone_link ); ?>"><?php esc_html_e( 'Clone', 'commons-in-a-box' ); ?></a></li>
<?php endif ?>

<li class="delete-button last-item <?php echo 'delete-group' === $current_tab ? 'current-menu-item' : ''; ?>"><span class="fa fa-minus-circle"></span><a href="<?php echo esc_attr( bp_get_group_manage_url( $group, bp_groups_get_path_chunks( [ 'delete-group' ], 'manage' ) ) ); ?>"><?php esc_html_e( 'Delete', 'commons-in-a-box' ); ?></a></li>

<?php if ( $group_type->get_is_portfolio() ) : ?>
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<li class="portfolio-displayname pull-right"><span class="highlight"><?php echo bp_core_get_userlink( openlab_get_user_id_from_portfolio_group_id( bp_get_group_id() ) ); ?></span></li>
<?php else : ?>
<?php // translators: last active timestamp ?>
<li class="info-line pull-right"><span class="timestamp info-line-timestamp visible-lg"><span class="fa fa-undo"></span> <?php echo esc_html( sprintf( __( 'active %s', 'commons-in-a-box' ), bp_get_group_last_active() ) ); ?></span></li>
<?php endif; ?>

<?php endif; ?>
<?php
bp_get_template_part( 'groups/single/nav/admin' );
}

/**
Expand All @@ -1177,6 +1122,7 @@ function openlab_group_admin_tabs( $group = false ) {
* @since 1.6.0 Markup was moved into theme template file.
*
* @param BP_Groups_Group $group Optional. Group object. Deprecated.
* @return void
*/
function openlab_group_membership_tabs( $group = false ) {
if ( false !== $group ) {
Expand Down

0 comments on commit a560d60

Please sign in to comment.