summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/widgets/google-translate.php')
-rw-r--r--plugins/jetpack/modules/widgets/google-translate.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/plugins/jetpack/modules/widgets/google-translate.php b/plugins/jetpack/modules/widgets/google-translate.php
index bba613d5..a5787112 100644
--- a/plugins/jetpack/modules/widgets/google-translate.php
+++ b/plugins/jetpack/modules/widgets/google-translate.php
@@ -66,7 +66,40 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
'title' => $this->default_title,
) );
- wp_localize_script( 'google-translate-init', '_wp_google_translate_widget', array( 'lang' => get_locale() ) );
+ /**
+ * Filter the layout of the Google Translate Widget.
+ *
+ * 3 different integers are accepted.
+ * 0 for the vertical layout.
+ * 1 for the horizontal layout.
+ * 2 for the dropdown only.
+ *
+ * @see https://translate.google.com/manager/website/
+ *
+ * @module widgets
+ *
+ * @since 5.5.0
+ *
+ * @param string $layout layout of the Google Translate Widget.
+ */
+ $button_layout = apply_filters( 'jetpack_google_translate_widget_layout', 2 );
+
+ if (
+ ! is_int( $button_layout )
+ || 0 > $button_layout
+ || 2 < $button_layout
+ ) {
+ $button_layout = 2;
+ }
+
+ wp_localize_script(
+ 'google-translate-init',
+ '_wp_google_translate_widget',
+ array(
+ 'lang' => get_locale(),
+ 'layout' => intval( $button_layout ),
+ )
+ );
wp_enqueue_script( 'google-translate-init' );
wp_enqueue_script( 'google-translate' );