@@ -15,16 +15,6 @@ function contact_info_widget_init() {
15
15
*/
16
16
class Contact_Info_Widget extends WP_Widget {
17
17
18
- public $ defaults = array (
19
- 'title ' => __ ( 'Hours & Info ' , 'jetpack ' ),
20
- 'address ' => __ ( "3999 Mission Boulevard, \nSan Diego CA 92109 " , 'jetpack ' ),
21
- 'phone ' => _x ( '1-202-555-1212 ' , 'Example of a phone number ' , 'jetpack ' ),
22
- 'hours ' => __ ( "Lunch: 11am - 2pm \nDinner: M-Th 5pm - 11pm, Fri-Sat:5pm - 1am " , 'jetpack ' ),
23
- 'showmap ' => 1 ,
24
- 'lat ' => null ,
25
- 'lon ' => null
26
- );
27
-
28
18
/**
29
19
* Constructor
30
20
*
@@ -44,6 +34,24 @@ function __construct() {
44
34
}
45
35
46
36
37
+ /**
38
+ * Return an associative array of default values
39
+ *
40
+ * These values are used in new widgets.
41
+ *
42
+ * @return array Array of default values for the Widget's options
43
+ */
44
+ public function defaults () {
45
+ return array (
46
+ 'title ' => __ ( 'Hours & Info ' , 'jetpack ' ),
47
+ 'address ' => __ ( "3999 Mission Boulevard, \nSan Diego CA 92109 " , 'jetpack ' ),
48
+ 'phone ' => _x ( '1-202-555-1212 ' , 'Example of a phone number ' , 'jetpack ' ),
49
+ 'hours ' => __ ( "Lunch: 11am - 2pm \nDinner: M-Th 5pm - 11pm, Fri-Sat:5pm - 1am " , 'jetpack ' ),
50
+ 'showmap ' => 1 ,
51
+ 'lat ' => null ,
52
+ 'lon ' => null
53
+ );
54
+ }
47
55
/**
48
56
* Outputs the HTML for this widget.
49
57
*
@@ -52,7 +60,7 @@ function __construct() {
52
60
* @return void Echoes it's output
53
61
**/
54
62
function widget ( $ args , $ instance ) {
55
- $ instance = wp_parse_args ( $ instance , $ this ->defaults );
63
+ $ instance = wp_parse_args ( $ instance , $ this ->defaults () );
56
64
57
65
extract ( $ args , EXTR_SKIP );
58
66
@@ -174,7 +182,7 @@ function update( $new_instance, $old_instance ) {
174
182
* Displays the form for this widget on the Widgets page of the WP Admin area.
175
183
**/
176
184
function form ( $ instance ) {
177
- $ instance = wp_parse_args ( $ instance , $ this ->defaults );
185
+ $ instance = wp_parse_args ( $ instance , $ this ->defaults () );
178
186
extract ( $ instance );
179
187
180
188
$ disabled = !$ this ->has_good_map ( $ instance );
0 commit comments