settings = $settings; $this->links = $links; foreach ( $this->links->model->languages->get_list() as $language ) { $this->elements[ $language->slug ] = $this->get_element( $language ); } } /** * Returns the markup of the switcher. * * @since 3.9 * * @return string */ abstract public function get(): string; /** * Returns the switcher's data. * * @since 3.9 * * @return Abstract_Element[] * * @phpstan-return array */ public function get_elements(): array { $out = array(); $is_first = true; foreach ( $this->elements as $element ) { if ( $this->settings->hide_current && $element->is_current ) { // Hide current item. continue; } if ( $this->settings->hide_if_empty && $element->is_empty ) { // Hide empty item. continue; } if ( $this->settings->hide_if_no_translation && ! $element->has_translations ) { // Hide item with no translations. continue; } if ( empty( $element->url ) ) { // Failed to get a URL. continue; } if ( $is_first && ! in_array( 'lang-item-first', $element->item_classes, true ) ) { // This is the first element of the list, for example the first `
  • ` in the `