WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WPSEO_Replace_Vars::register_replacement() public Yoast 1.0

Register new replacement %%variables%%. For use by other plugins/themes to register extra variables.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

{} Это метод класса: WPSEO_Replace_Vars{}

Хуков нет.


true|false. Whether the replacement function was succesfully registered.


$result = WPSEO_Replace_Vars::register_replacement( $var, $replace_function, $type, $help_text );
$var(строка) (обязательный)
The name of the variable to replace, i.e. '%%var%%'. Note: the surrounding %% are optional.
$replace_function(разное) (обязательный)
Function or method to call to retrieve the replacement value for the variable. Uses the same format as add_filter/add_action function parameter and should return the replacement value. DON'T echo it.
Type of variable: 'basic' or 'advanced'.
По умолчанию: 'advanced'
Help text to be added to the help tab for this variable.
По умолчанию: ''


Код WPSEO_Replace_Vars::register_replacement() Yoast 17.4

public static function register_replacement( $var, $replace_function, $type = 'advanced', $help_text = '' ) {
	$success = false;

	if ( is_string( $var ) && $var !== '' ) {
		$var = self::remove_var_delimiter( $var );

		if ( preg_match( '`^[A-Z0-9_-]+$`i', $var ) === false ) {
			trigger_error( esc_html__( 'A replacement variable can only contain alphanumeric characters, an underscore or a dash. Try renaming your variable.', 'wordpress-seo' ), E_USER_WARNING );
		elseif ( strpos( $var, 'cf_' ) === 0 || strpos( $var, 'ct_' ) === 0 ) {
			trigger_error( esc_html__( 'A replacement variable can not start with "%%cf_" or "%%ct_" as these are reserved for the WPSEO standard variable variables for custom fields and custom taxonomies. Try making your variable name unique.', 'wordpress-seo' ), E_USER_WARNING );
		elseif ( ! method_exists( __CLASS__, 'retrieve_' . $var ) ) {
			if ( $var !== '' && ! isset( self::$external_replacements[ $var ] ) ) {
				self::$external_replacements[ $var ] = $replace_function;
				$replacement_variable                = new WPSEO_Replacement_Variable( $var, $var, $help_text );
				self::register_help_text( $type, $replacement_variable );
				$success = true;
			else {
				trigger_error( esc_html__( 'A replacement variable with the same name has already been registered. Try making your variable name unique.', 'wordpress-seo' ), E_USER_WARNING );
		else {
			trigger_error( esc_html__( 'You cannot overrule a WPSEO standard variable replacement by registering a variable with the same name. Use the "wpseo_replacements" filter instead to adjust the replacement value.', 'wordpress-seo' ), E_USER_WARNING );

	return $success;