wpseo_wpml_config()
WPML plugin support: Set titles for custom types / taxonomies as translatable.
It adds new keys to a wpml-config.xml file for a custom post type title, metadesc, title-ptarchive and metadesc-ptarchive fields translation. Documentation: http://wpml.org/documentation/support/language-configuration-files/
Хуков нет.
Возвращает
Массив.
Использование
wpseo_wpml_config( $config );
- $config(массив) (обязательный)
- WPML configuration data to filter.
Заметки
- Global.
$sitepress
Код wpseo_wpml_config() wpseo wpml config Yoast 27.3
function wpseo_wpml_config( $config ) {
global $sitepress;
if ( ( is_array( $config ) && isset( $config['wpml-config']['admin-texts']['key'] ) ) && ( is_array( $config['wpml-config']['admin-texts']['key'] ) && $config['wpml-config']['admin-texts']['key'] !== [] ) ) {
$admin_texts = $config['wpml-config']['admin-texts']['key'];
foreach ( $admin_texts as $k => $val ) {
if ( $val['attr']['name'] === 'wpseo_titles' ) {
$translate_cp = array_keys( $sitepress->get_translatable_documents() );
if ( is_array( $translate_cp ) && $translate_cp !== [] ) {
foreach ( $translate_cp as $post_type ) {
$admin_texts[ $k ]['key'][]['attr']['name'] = 'title-' . $post_type;
$admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-' . $post_type;
$admin_texts[ $k ]['key'][]['attr']['name'] = 'title-ptarchive-' . $post_type;
$admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-ptarchive-' . $post_type;
$translate_tax = $sitepress->get_translatable_taxonomies( false, $post_type );
if ( is_array( $translate_tax ) && $translate_tax !== [] ) {
foreach ( $translate_tax as $taxonomy ) {
$admin_texts[ $k ]['key'][]['attr']['name'] = 'title-tax-' . $taxonomy;
$admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-tax-' . $taxonomy;
}
}
}
}
break;
}
}
$config['wpml-config']['admin-texts']['key'] = $admin_texts;
}
return $config;
}