__( 'Language switcher widget by Bogo plugin', 'bogo' ) ); $control_ops = array(); WP_Widget::__construct( 'bogo_language_switcher', __( 'Language Switcher', 'bogo' ), $widget_ops, $control_ops ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Language Switcher', 'bogo' ) : $instance['title'], $instance, $this->id_base ); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; echo bogo_language_switcher(); echo $after_widget; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); $title = strip_tags( $instance['title'] ); echo '
'; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); $instance['title'] = strip_tags( $new_instance['title'] ); return $instance; } } /* Locale Option */ add_filter( 'widget_display_callback', 'bogo_widget_display_callback', 10, 3 ); function bogo_widget_display_callback( $instance, $widget, $args ) { if ( isset( $instance['bogo_locales'] ) ) { $locale = get_locale(); if ( ! in_array( $locale, (array) $instance['bogo_locales'] ) ) $instance = false; } return $instance; } add_action( 'in_widget_form', 'bogo_in_widget_form', 10, 3 ); function bogo_in_widget_form( $widget, $return, $instance ) { $available_languages = bogo_available_languages( 'orderby=value' ); $selected_languages = ! isset( $instance['bogo_locales'] ) ? array_keys( $available_languages ) : (array) $instance['bogo_locales']; ?>