PluginProbe
wp-forecast / 2.6
wp-forecast v2.6
10.0 trunk 1.4 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3..5 3..8 3.0 3.1 3.2 3.3 3.4 3.6 All 86 releases
wp-forecast / class-wpf_widget.php

class-wpf_widget.php in wp-forecast 2.6, at class-wpf_widget.php

95 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( !class_exists('wpf_widget') )
4 {
5 class wpf_widget extends WP_Widget
6 {
7 function wpf_widget()
8 {
9 $widget_ops = array('classname' => 'wp_forecast_widget',
10 'description' => 'WP Forecast Widget');
11 $control_ops = array('width' => 300, 'height' => 150);
12 $this->WP_Widget('wp-forecast', 'WP Forecast',
13 $widget_ops, $control_ops);
14 }
15
16 function widget( $args, $instance )
17 {
18 pdebug(1,"Start of function wp_forecast_widget ()");
19
20 // get widget params from instance
21 $title = $instance['title'];
22 $wpfcid = $instance['wpfcid'];
23
24 if (trim($wpfcid) =="")
25 $wpfcid="A";
26
27 // pass title to show function
28 $args['title'] = $title;
29
30 $wpf_vars=get_wpf_opts($wpfcid);
31 if (!empty($language_override)) {
32 $wpf_vars['wpf_language']=$language_override;
33 }
34
35 show($wpfcid,$args,$wpf_vars);
36
37 pdebug(1,"End of function wp_forecast_widget ()");
38 }
39
40 function update( $new_instance, $old_instance )
41 {
42 pdebug(1,"Start of wpf_widget::update()");
43
44 return $new_instance;
45
46 pdebug(1,"End of wpf_widget::update()");
47 }
48
49 function form( $instance )
50 {
51 pdebug(1,"Start of wpf_widget::form()");
52
53 $count = get_option('wp-forecast-count');
54
55 // get translation
56 $locale = get_locale();
57 if ( empty($locale) )
58 $locale = 'en_US';
59 if(function_exists('load_textdomain'))
60 load_textdomain("wp-forecast_".$locale,ABSPATH .
61 "wp-content/plugins/wp-forecast/lang/".$locale.".mo");
62
63 $title = esc_attr($instance['title']);
64 $wpfcid = esc_attr($instance['wpfcid']);
65
66 // code for widget title form
67 $out = "";
68 $out .= '<p><label for="'. $this->get_field_id('title') . '" >';
69 $out .= __("Title:","wp-forecast_".$locale);
70 $out .= '<input class="widefat" id="'.
71 $this->get_field_id('title') . '" name="'.
72 $this->get_field_name('title') .
73 '" type="text" value="'. $title.'" /></label></p>';
74
75 // print out widget selector
76 $out .='<p><label for ="'. $this->get_field_id('wpfcid') . '" >';
77 $out .= __('Available widgets',"wp-forecast_".$locale);
78 $out .= "<select name='". $this->get_field_name("wpfcid") ."' size='1' >";
79 for ($i=0;$i<$count;$i++) {
80 $id = get_widget_id( $i );
81 $out .="<option value='".$id."' ";
82 if ( $wpfcid == $id )
83 $out .=" selected='selected' ";
84 $out .=">".$id."</option>";
85 }
86 $out .= "</select></label></p>";
87 echo $out;
88
89 pdebug(1,"End of wpf_widget::form()");
90 }
91 }
92
93 }
94 ?>
95