Yoast_I18n_WordPressOrg_v2

The Yoast i18n module with a connection to WordPress.org.

Defined (1)

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

/vendor/yoast/i18n-module/src/i18n-module-wordpressorg.php  
  1. class Yoast_I18n_WordPressOrg_v2 { 
  2.  
  3. /** 
  4. * The i18n object that presents the user with the notification. 
  5. * @var yoast_i18n_v2 
  6. */ 
  7. protected $i18n; 
  8.  
  9. /** 
  10. * Constructs the i18n module for wordpress.org. Required fields are the 'textdomain', 'plugin_name' and 'hook' 
  11. * @param array $args The settings for the i18n module. 
  12. */ 
  13. public function __construct( $args ) { 
  14. $args = $this->set_defaults( $args ); 
  15.  
  16. $this->i18n = new Yoast_I18n_v2( $args ); 
  17. $this->set_api_url( $args['textdomain'] ); 
  18.  
  19. /** 
  20. * Sets the default values for wordpress.org 
  21. * @param array $args The arguments to set defaults for. 
  22. * @return array The arguments with the arguments set. 
  23. */ 
  24. private function set_defaults( $args ) { 
  25.  
  26. if ( ! isset( $args['glotpress_logo'] ) ) { 
  27. $args['glotpress_logo'] = 'https://plugins.svn.wordpress.org/' . $args['textdomain'] . '/assets/icon-128x128.png'; 
  28.  
  29. if ( ! isset( $args['register_url'] ) ) { 
  30. $args['register_url'] = 'https://translate.wordpress.org/projects/wp-plugins/' . $args['textdomain'] . '/'; 
  31.  
  32. if ( ! isset( $args['glotpress_name'] ) ) { 
  33. $args['glotpress_name'] = 'Translating WordPress'; 
  34.  
  35. if ( ! isset( $args['project_slug'] ) ) { 
  36. $args['project_slug'] = $args['textdomain']; 
  37.  
  38. return $args; 
  39.  
  40. /** 
  41. * Set the API URL on the i18n object. 
  42. * @param string $textdomain The textdomain to use for the API URL. 
  43. */ 
  44. private function set_api_url( $textdomain ) { 
  45. $this->i18n->set_api_url( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $textdomain . '/stable/' );