wpseo_wpml_config

WPML plugin support: Set titles for custom types / taxonomies as translatable.

Description

(array) wpseo_wpml_config( (array) $config ); 

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/

Returns (array)

Parameters (1)

0. $config (array)
WPML configuration data to filter.

Usage

  1. if ( !function_exists( 'wpseo_wpml_config' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/inc/wpseo-functions.php'; 
  3.  
  4. // WPML configuration data to filter. 
  5. $config = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpseo_wpml_config($config); 
  9.  

Defined (1)

The function is defined in the following location(s).

/inc/wpseo-functions.php  
  1. function wpseo_wpml_config( $config ) { 
  2. global $sitepress; 
  3.  
  4. 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'] !== array() ) ) { 
  5. $admin_texts = $config['wpml-config']['admin-texts']['key']; 
  6. foreach ( $admin_texts as $k => $val ) { 
  7. if ( $val['attr']['name'] === 'wpseo_titles' ) { 
  8. $translate_cp = array_keys( $sitepress->get_translatable_documents() ); 
  9. if ( is_array( $translate_cp ) && $translate_cp !== array() ) { 
  10. foreach ( $translate_cp as $post_type ) { 
  11. $admin_texts[ $k ]['key'][]['attr']['name'] = 'title-' . $post_type; 
  12. $admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-' . $post_type; 
  13. $admin_texts[ $k ]['key'][]['attr']['name'] = 'metakey-' . $post_type; 
  14. $admin_texts[ $k ]['key'][]['attr']['name'] = 'title-ptarchive-' . $post_type; 
  15. $admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-ptarchive-' . $post_type; 
  16. $admin_texts[ $k ]['key'][]['attr']['name'] = 'metakey-ptarchive-' . $post_type; 
  17.  
  18. $translate_tax = $sitepress->get_translatable_taxonomies( false, $post_type ); 
  19. if ( is_array( $translate_tax ) && $translate_tax !== array() ) { 
  20. foreach ( $translate_tax as $taxonomy ) { 
  21. $admin_texts[ $k ]['key'][]['attr']['name'] = 'title-tax-' . $taxonomy; 
  22. $admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-tax-' . $taxonomy; 
  23. $admin_texts[ $k ]['key'][]['attr']['name'] = 'metakey-tax-' . $taxonomy; 
  24. break; 
  25. $config['wpml-config']['admin-texts']['key'] = $admin_texts; 
  26.  
  27. return $config;