WPSEO_Replace_Vars::safe_register_replacement()publicYoast 1.0

Register a new replacement variable if it has not been registered already.

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

Хуков нет.

Возвращает

true|false. true if the replace var has been registered, false if not.

Использование

$WPSEO_Replace_Vars = new WPSEO_Replace_Vars();
$WPSEO_Replace_Vars->safe_register_replacement( $var_to_replace, $replace_function, $type, $help_text );
$var_to_replace(строка) (обязательный)
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(строка)
Type of variable: 'basic' or 'advanced'.
По умолчанию: 'advanced'
$help_text(строка)
Help text to be added to the help tab for this variable.
По умолчанию: ''

Код WPSEO_Replace_Vars::safe_register_replacement() Yoast 22.4

public function safe_register_replacement( $var_to_replace, $replace_function, $type = 'advanced', $help_text = '' ) {
	if ( ! $this->has_been_registered( $var_to_replace ) ) {
		return self::register_replacement( $var_to_replace, $replace_function, $type, $help_text );
	}
	return false;
}