WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта с помощью браузерных PUSH уведомлений
функция не описана

wpseo_register_var_replacement() Yoast 1.5.4

Register a new variable replacement.

This function is for use by other plugins/themes to easily add their own additional variables to replace. This function should be called from a function on the 'wpseo_register_extra_replacements' action hook. The use of this function is preferred over the older 'wpseo_replacements' filter as a way to add new replacements. The 'wpseo_replacements' filter should still be used to adjust standard WPSEO replacement values. The function can not be used to replace standard WPSEO replacement value functions and will thrown a warning if you accidently try. To avoid conflicts with variables registered by WPSEO and other themes/plugins, try and make the name of your variable unique. Variable names also can not start with "%%cf_" or "%%ct_" as these are reserved for the standard WPSEO variable variables 'cf_<custom-field-name>', 'ct_<custom-tax-name>' and 'ct_desc_<custom-tax-name>'. The replacement function will be passed the undelimited name (i.e. stripped of the %%) of the variable to replace in case you need it.

Example code:

<?php
function retrieve_var1_replacement( $var1 ) {
	   return 'your replacement value';
}

function register_my_plugin_extra_replacements() {
	   wpseo_register_var_replacement( '%%myvar1%%', 'retrieve_var1_replacement', 'advanced', 'this is a help text for myvar1' );
	   wpseo_register_var_replacement( 'myvar2', array( 'class', 'method_name' ), 'basic', 'this is a help text for myvar2' );
}
add_action( 'wpseo_register_extra_replacements', 'register_my_plugin_extra_replacements' );
?>

Хуков нет.

Возвращает

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

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

wpseo_register_var_replacement( $var, $replace_function, $type, $help_text );
$var(строка) (обязательный)
The name of the variable to replace, i.e. '%%var%%'. Note: the surrounding %% are optional, name can only contain [A-Za-z0-9_-].
$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.

Список изменений

С версии 1.5.4 Введена.

Код wpseo_register_var_replacement() Yoast 16.2

<?php
function wpseo_register_var_replacement( $var, $replace_function, $type = 'advanced', $help_text = '' ) {
	return WPSEO_Replace_Vars::register_replacement( $var, $replace_function, $type, $help_text );
}