current_language = $current_language; } public function add_hooks() { add_filter( 'widget_display_callback', array( $this, 'display' ), -PHP_INT_MAX, 1 ); } /** * @param array|bool $instance * * @return array|bool */ public function display( $instance ) { if ( (bool) $instance && $this->it_must_display( $instance ) ) { return $instance; } return false; } /** * @param array $instance * * @return bool */ private function it_must_display( $instance ) { return ! array_key_exists( 'wpml_language', $instance ) || $instance['wpml_language'] === $this->current_language || 'all' === $instance['wpml_language']; } }