Skip to content

Commit 0f71669

Browse files
committed
Widgets: Contact form - place default values in function
Adding translation functions in global variable caused errors
1 parent e9b7d54 commit 0f71669

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

modules/widgets/contact-info.php

+20-12
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ function contact_info_widget_init() {
1515
*/
1616
class Contact_Info_Widget extends WP_Widget {
1717

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-
2818
/**
2919
* Constructor
3020
*
@@ -44,6 +34,24 @@ function __construct() {
4434
}
4535

4636

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+
}
4755
/**
4856
* Outputs the HTML for this widget.
4957
*
@@ -52,7 +60,7 @@ function __construct() {
5260
* @return void Echoes it's output
5361
**/
5462
function widget( $args, $instance ) {
55-
$instance = wp_parse_args( $instance, $this->defaults );
63+
$instance = wp_parse_args( $instance, $this->defaults() );
5664

5765
extract( $args, EXTR_SKIP );
5866

@@ -174,7 +182,7 @@ function update( $new_instance, $old_instance ) {
174182
* Displays the form for this widget on the Widgets page of the WP Admin area.
175183
**/
176184
function form( $instance ) {
177-
$instance = wp_parse_args( $instance, $this->defaults );
185+
$instance = wp_parse_args( $instance, $this->defaults() );
178186
extract( $instance );
179187

180188
$disabled = !$this->has_good_map( $instance );

0 commit comments

Comments
 (0)