__( 'Displays a language switcher', 'falang' ), 'customize_selective_refresh' => true, ) ); //set up default options $this->defaults = array( 'title' => '', 'display_name' => 1, 'display_flags' => 0, 'positioning' => 'h', // vertical|horizontal 'display_type' => 'list', // types: list: vertical or horizontal list, select: selectbox 'hide_current' => 1 ); } /** * Displays the widget * * @since 0.1 * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ function widget( $args, $instance ) { //TODO display message if language switcher not activated (see sublanguage) extract( $args ); $fswicher = new \Falang\Core\Language_Switcher($instance); /** Merge with defaults */ $this->instance = wp_parse_args( (array) $instance, $this->defaults ); $title = empty( $instance['title'] ) ? '' : $instance['title']; /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } echo $fswicher->display_switcher(); echo $args['after_widget']; } /** * Displays the widget form * * @since 1.0 * @update 1.3.35 change the initialisation of the default value * * @param array $instance Current settings */ function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults ); $title = strip_tags( $instance['title'] ); ?>

>

> />

> />

/>

admin_print_script(); } /** * Updates the widget options * * @since 1.0 * * @param array $new_instance New settings for this instance as input by the user via form() * @param array $old_instance Old settings for this instance * @return array Settings to save or bool false to cancel saving */ function update( $new_instance, $old_instance ) { $new_instance['title'] = strip_tags( $new_instance['title'] ); $new_instance['positioning'] = strip_tags( $new_instance['positioning'] ); $new_instance['display_name'] = strip_tags( $new_instance['display_name'] ); $new_instance['display_flags'] = strip_tags( $new_instance['display_flags'] ); $new_instance['display_type'] = strip_tags( $new_instance['display_type'] ); $new_instance['hide_current'] = strip_tags( $new_instance['hide_current'] ); return $new_instance; } /** * Add javascript to control the switcher widget options * * @since 1.0 */ public function admin_print_script() { static $done = false; if ( $done ) { return; } $done = true; ?>