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

7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
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.