PluginProbe
Bogo / 3.0
Bogo v3.0
3.9.3 trunk 1.0 1.1 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.6 2.6.1 2.7 2.8 2.8.1 2.9 3.0 3.0.1 All 52 releases
bogo / admin / includes / widgets.php

widgets.php in Bogo 3.0, at admin/includes/widgets.php

45 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 add_action( 'in_widget_form', 'bogo_in_widget_form', 10, 3 );
4
5 function bogo_in_widget_form( $widget, $return, $instance ) {
6 $available_languages = bogo_available_languages( array(
7 'exclude_enus_if_inactive' => true,
8 'orderby' => 'value' ) );
9
10 if ( empty( $available_languages ) ) {
11 return;
12 }
13
14 $return = null;
15
16 $selected_languages = isset( $instance['bogo_locales'] )
17 ? (array) $instance['bogo_locales']
18 : array_keys( $available_languages );
19
20 ?>
21 <fieldset class="bogo-locale-options">
22 <legend><?php echo esc_html( __( 'Displayed on pages in', 'bogo' ) ); ?></legend>
23 <?php foreach ( $available_languages as $locale => $language ) :
24 $checked = in_array( $locale, $selected_languages );
25 $id_attr = $widget->get_field_id( 'bogo_locales' ) . '-' . $locale;
26 ?>
27 <label class="bogo-locale-option<?php echo $checked ? ' checked' : ''; ?>" for="<?php echo $id_attr; ?>">
28 <input type="checkbox" id="<?php echo $id_attr; ?>" name="<?php echo $widget->get_field_name( 'bogo_locales' ); ?>[]" value="<?php echo esc_attr( $locale ); ?>"<?php echo $checked ? ' checked="checked"' : ''; ?> /><?php echo esc_html( $language ); ?>
29 </label>
30 <?php endforeach; ?>
31 </fieldset>
32 <?php
33 }
34
35 add_filter( 'widget_update_callback', 'bogo_widget_update_callback', 10, 4 );
36
37 function bogo_widget_update_callback( $instance, $new_instance, $old_instance, $widget ) {
38 if ( isset( $new_instance['bogo_locales'] ) && is_array( $new_instance['bogo_locales'] ) )
39 $instance['bogo_locales'] = $new_instance['bogo_locales'];
40 else
41 $instance['bogo_locales'] = array();
42
43 return $instance;
44 }
45