| @@ -1,10 +1,5 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | - | |
| 3 | -// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. | |
| 4 | - | |
| 5 | -use Automattic\Jetpack\Assets; | |
| 6 | - | |
| 7 | 2 | /** |
| 8 | 3 | * Plugin Name: Google Translate Widget for WordPress.com |
| 9 | 4 | * Plugin URI: https://automattic.com |
| 10 | 5 | * Description: Add a widget for automatic translation |
| @@ -12,10 +7,15 @@ | ||
| 12 | 7 | * Version: 0.1 |
| 13 | 8 | * Author URI: https://automattic.com |
| 14 | 9 | * Text Domain: jetpack |
| 15 | 10 | */ |
| 11 | + | |
| 12 | +// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. | |
| 13 | + | |
| 14 | +use Automattic\Jetpack\Assets; | |
| 15 | + | |
| 16 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | - exit; | |
| 17 | + exit( 0 ); | |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Jetpack_Google_Translate_Widget main class. |
| @@ -148,9 +148,9 @@ | ||
| 148 | 148 | 'google-translate-init', |
| 149 | 149 | '_wp_google_translate_widget', |
| 150 | 150 | array( |
| 151 | 151 | 'lang' => get_locale(), |
| 152 | - 'layout' => (int) $button_layout, | |
| 152 | + 'layout' => $button_layout, | |
| 153 | 153 | ) |
| 154 | 154 | ); |
| 155 | 155 | wp_enqueue_script( 'google-translate-init' ); |
| 156 | 156 | wp_enqueue_script( 'google-translate' ); |
| @@ -181,11 +181,12 @@ | ||
| 181 | 181 | * |
| 182 | 182 | * @see WP_Widget::form() |
| 183 | 183 | * |
| 184 | 184 | * @param array $instance Previously saved values from database. |
| 185 | + * @return string|void | |
| 185 | 186 | */ |
| 186 | 187 | public function form( $instance ) { |
| 187 | - $title = isset( $instance['title'] ) ? $instance['title'] : false; | |
| 188 | + $title = $instance['title'] ?? false; | |
| 188 | 189 | if ( false === $title ) { |
| 189 | 190 | $title = $this->default_title; |
| 190 | 191 | } |
| 191 | 192 | ?> |
| @@ -213,9 +214,8 @@ | ||
| 213 | 214 | $instance['title'] = false; // Store as false in case of language change. |
| 214 | 215 | } |
| 215 | 216 | return $instance; |
| 216 | 217 | } |
| 217 | - | |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * Register the widget for use in Appearance -> Widgets. |