-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwidgets.php
65 lines (48 loc) · 1.9 KB
/
widgets.php
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
55
56
57
58
59
60
61
62
63
64
65
<?php
class Global_Site_Search_Widget extends WP_Widget {
public function __construct() {
$widget_options = array(
'classname' => 'global-site-search',
'description' => __( 'Netzwerksuche Widget', 'globalsitesearch' ),
);
$control_options = array(
'id_base' => 'global-site-search-widget',
);
parent::__construct( 'global-site-search-widget', __( 'Netzwerksuche Widget', 'globalsitesearch' ), $widget_options, $control_options );
}
function widget( $args, $instance ) {
global $global_site_search, $wp_query;
extract( $args );
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
$title = apply_filters( 'widget_title', $instance['title'] );
if ( !empty( $title ) ) {
echo $before_title . $title . $after_title;
}
global_site_search_form();
/* After widget (defined by themes). */
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags for title and name to remove HTML (important for text inputs). */
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array)$instance, array(
'title' => __( 'Netzwerksuche', 'globalsitesearch' ),
) );
?><p>
<label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _e( 'Titel', 'globalsitesearch' ) ?>:</label>
<input type="text" id="<?php echo $this->get_field_id( 'title' ) ?>" name="<?php echo $this->get_field_name( 'title' ) ?>" value="<?php echo esc_attr( $instance['title'] ) ?>" class="widefat">
</p><?php
}
}
add_action( 'widgets_init', 'global_site_search_load_widgets' );
function global_site_search_load_widgets() {
if ( in_array( get_current_blog_id(), global_site_search_get_allowed_blogs() ) ) {
register_widget( 'Global_Site_Search_Widget' );
}
}