Skip to content

Commit

Permalink
Introduce flag for adding noindex tag to inactive group profile pages.
Browse files Browse the repository at this point in the history
See #3400.
  • Loading branch information
boonebgorges committed Jun 26, 2024
1 parent c206862 commit b4d344f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions wp-content/themes/openlab/lib/group-funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2505,3 +2505,34 @@ function( $blog_id, $activity ) {
10,
2
);

/**
* Determines whether a group should have the noindex meta tag added to its pages.
*
* @param int $group_id ID of the group.
* @return bool
*/
function openlab_should_noindex_group_profile( $group_id ) {
$should_noindex = groups_get_groupmeta( $group_id, 'openlab_noindex_group_profile', true );

return (bool) $should_noindex;
}

/**
* Adds the noindex meta tag to a group profile.
*/
function openlab_add_noindex_to_group_profile() {
if ( ! bp_is_group() ) {
return;
}

$group_id = bp_get_current_group_id();
if ( ! $group_id ) {
return;
}

if ( openlab_should_noindex_group_profile( $group_id ) ) {
echo '<meta name="robots" content="noindex" />' . "\n";
}
}
add_action( 'wp_head', 'openlab_add_noindex_to_group_profile', 0 );

0 comments on commit b4d344f

Please sign in to comment.