4
* The Yoast i18n module with a connection to WordPress.org.
6
class Yoast_I18n_WordPressOrg_v3 {
9
* The i18n object that presents the user with the notification.
16
* Constructs the i18n module for wordpress.org. Required fields are the 'textdomain', 'plugin_name' and 'hook'
18
* @param array $args The settings for the i18n module.
19
* @param bool $show_translation_box Whether the translation box should be shown.
21
public function __construct( $args, $show_translation_box = true ) {
22
$args = $this->set_defaults( $args );
24
$this->i18n = new Yoast_I18n_v3( $args, $show_translation_box );
25
$this->set_api_url( $args['textdomain'] );
29
* Returns the i18n_promo message from the i18n_module. Returns en empty string if the promo shouldn't be shown.
33
* @return string The i18n promo message.
35
public function get_promo_message() {
36
return $this->i18n->get_promo_message();
40
* Returns a button that can be used to dismiss the i18n-message.
46
public function get_dismiss_i18n_message_button() {
47
return $this->i18n->get_dismiss_i18n_message_button();
51
* Sets the default values for wordpress.org
53
* @param array $args The arguments to set defaults for.
55
* @return array The arguments with the arguments set.
57
private function set_defaults( $args ) {
59
if ( ! isset( $args['glotpress_logo'] ) ) {
60
$args['glotpress_logo'] = 'https://plugins.svn.wordpress.org/' . $args['textdomain'] . '/assets/icon-128x128.png';
63
if ( ! isset( $args['register_url'] ) ) {
64
$args['register_url'] = 'https://translate.wordpress.org/projects/wp-plugins/' . $args['textdomain'] . '/';
67
if ( ! isset( $args['glotpress_name'] ) ) {
68
$args['glotpress_name'] = 'Translating WordPress';
71
if ( ! isset( $args['project_slug'] ) ) {
72
$args['project_slug'] = $args['textdomain'];
79
* Set the API URL on the i18n object.
81
* @param string $textdomain The textdomain to use for the API URL.
83
private function set_api_url( $textdomain ) {
84
$this->i18n->set_api_url( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $textdomain . '/stable/' );