| @@ -32,14 +32,18 @@ | ||
| 32 | 32 | * @since 0.1 |
| 33 | 33 | * |
| 34 | 34 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 35 | 35 | * @param array $instance The settings for the particular instance of the widget |
| 36 | + * @return void | |
| 36 | 37 | */ |
| 37 | 38 | public function widget( $args, $instance ) { |
| 38 | 39 | // Sets a unique id for dropdown. |
| 39 | - $instance['dropdown'] = empty( $instance['dropdown'] ) ? 0 : $args['widget_id']; | |
| 40 | + $instance['dropdown'] = empty( $instance['dropdown'] ) ? 0 : $this->id; | |
| 41 | + $instance['echo'] = 0; | |
| 42 | + $instance['raw'] = 0; | |
| 43 | + $list = pll_the_languages( $instance ); | |
| 40 | 44 | |
| 41 | - if ( $list = pll_the_languages( array_merge( $instance, array( 'echo' => 0 ) ) ) ) { | |
| 45 | + if ( $list ) { | |
| 42 | 46 | $title = empty( $instance['title'] ) ? '' : $instance['title']; |
| 43 | 47 | |
| 44 | 48 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 45 | 49 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
| @@ -65,9 +69,9 @@ | ||
| 65 | 69 | /** This filter is documented in wp-includes/widgets/class-wp-nav-menu-widget.php */ |
| 66 | 70 | $format = apply_filters( 'navigation_widgets_format', $format ); |
| 67 | 71 | |
| 68 | 72 | if ( 'html5' === $format ) { |
| 69 | - echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; | |
| 73 | + echo '<nav aria-label="' . esc_attr( $aria_label ) . '">'; | |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | 76 | echo "<ul>\n" . $list . "</ul>\n"; // phpcs:ignore WordPress.Security.EscapeOutput |
| 73 | 77 | |
| @@ -98,13 +102,14 @@ | ||
| 98 | 102 | return $instance; |
| 99 | 103 | } |
| 100 | 104 | |
| 101 | 105 | /** |
| 102 | - * Displays the widget form | |
| 106 | + * Displays the widget form. | |
| 103 | 107 | * |
| 104 | 108 | * @since 0.4 |
| 105 | 109 | * |
| 106 | - * @param array $instance Current settings | |
| 110 | + * @param array $instance Current settings. | |
| 111 | + * @return string | |
| 107 | 112 | */ |
| 108 | 113 | public function form( $instance ) { |
| 109 | 114 | // Default values |
| 110 | 115 | $instance = wp_parse_args( (array) $instance, array_merge( array( 'title' => '' ), PLL_Switcher::get_switcher_options( 'widget', 'default' ) ) ); |
| @@ -129,6 +134,8 @@ | ||
| 129 | 134 | ( ! empty( $instance['dropdown'] ) && in_array( $key, array( 'show_names', 'show_flags', 'hide_current' ) ) ? ' style="display:none;"' : '' ), |
| 130 | 135 | esc_attr( 'pll-' . $key ) |
| 131 | 136 | ); |
| 132 | 137 | } |
| 138 | + | |
| 139 | + return ''; // Because the parent class returns a string, however not used. | |
| 133 | 140 | } |
| 134 | 141 | } |