1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
class WosmPL_GeoCat_Widget extends WP_Widget {
function __construct() {
$widget_ops = array(
'description' => 'Displays geo cat.',
);
// Instantiate the parent object
parent::__construct( false, 'WosmPL Geocat.', $widget_ops);
}
function widget( $args, $instance ) {
// Widget output
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
}
$with_map_link = TRUE;
echo wosmpl_get_categories_ul('widget-list',$with_map_link);
echo $args['after_widget'];
}
function update( $new_instance, $old_instance ) {
// Save widget options
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
function form( $instance ) {
// Output admin widget options form
$title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Title', 'wosmpl' );
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
<?php esc_attr_e( 'Title:', 'wosmpl' ); ?>
</label>
<input
class="widefat"
id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
type="text"
value="<?php echo esc_attr( $title ); ?>">
</p>
<?php
}
}