bp_get_article_prefix( string $string )

Return string with the article prefix “a/an”.

Description

Parameters

$string

(Required) Text string for adding the article prefix.

Return

(string)

Source

File: bp-groups/bp-groups-template.php

function bp_get_article_prefix( $string ) {
	if ( empty( $string ) ) {
		return $string;
	}

	$supported_languages = array(
		'en_US',
		'en_NZ',
		'en_ZA',
		'en_AU',
		'en_GB',
		'en_CA',
	);

	if ( ! in_array( get_locale(), $supported_languages ) ) {
		return apply_filters( 'bp_get_article_prefix', __( 'a', 'buddyboss' ) . ' ' . $string, $string );
	}

	$vowel_array = array( 'a', 'e', 'i', 'o', 'u' );  // array of vowel
	$prefix      = in_array( strtolower( substr( $string, 0, 1 ) ), $vowel_array ) ? __( 'an', 'buddyboss' ) : __( 'a', 'buddyboss' );

	return apply_filters( 'bp_get_article_prefix', $prefix . ' ' . $string, $string );

}

Changelog

Changelog
Version Description
BuddyBoss 1.2.8 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.