Warning: This function has been deprecated. Use _x() instead.

_c() WordPress Function

The c() function is used to retrieve the value of a specific key from an array. The function takes two arguments: the array to search and the key to look for. If the key is found, the value associated with that key is returned. If the key is not found, an empty string is returned.

_c( string $text, string $domain = 'default' ) #

Retrieve translated string with vertical bar context


Description

Quite a few times, there will be collisions with similar translatable text found in more than two places but with different translated context.

In order to use the separate contexts, the _c() function is used and the translatable string uses a pipe (‘|’) which has the context the string is in.

When the translated string is returned, it is everything before the pipe, not including the pipe character. If there is no pipe in the translated text then everything is returned.

Top ↑

See also


Top ↑

Parameters

$text

(string)(Required)Text to translate.

$domain

(string)(Optional) Domain to retrieve the translated text.

Default value: 'default'


Top ↑

Return

(string) Translated context string without pipe.


Top ↑

Source

File: wp-includes/deprecated.php

function _c( $text, $domain = 'default' ) {
	_deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
	return before_last_bar( translate( $text, $domain ) );
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Use _x()
2.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More