WordPress at a glance
function is not described

before_last_bar() WP 2.8.0

Remove last item on a pipe-delimited string.

Meant for removing the last item in a string, such as 'Role name|User role'. The original string will be returned if no pipe '|' characters are found in the string.

No Hooks.


String. Either $string or everything before the last pipe.


before_last_bar( $string );
$string(string) (required)
A pipe-delimited string.

Code of before last bar: wp-includes/l10n.php WP 5.2.2

function before_last_bar( $string ) {
	$last_bar = strrpos( $string, '|' );
	if ( false === $last_bar ) {
		return $string;
	} else {
		return substr( $string, 0, $last_bar );