Skip to content

Commit e9b7d54

Browse files
committed
Widgets: Reorganize Contact info widget
Add correct textdomain Add context when needed Move main widget file one directory up so it can be picked up and used
1 parent 3628422 commit e9b7d54

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

modules/widgets/contact-info/contact-info.php modules/widgets/contact-info.php

+22-17
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ function contact_info_widget_init() {
1515
*/
1616
class Contact_Info_Widget extends WP_Widget {
1717

18-
public $text_domain = "contact-info";
19-
2018
public $defaults = array(
21-
'title' => 'Hours & Info',
22-
'address' => "3999 Mission Boulevard,\nSan Diego CA 92109",
23-
'phone' => '1-202-555-1212',
24-
'hours' => "Lunch: 11am - 2pm \nDinner: M-Th 5pm - 11pm, Fri-Sat:5pm - 1am",
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' ),
2523
'showmap' => 1,
2624
'lat' => null,
2725
'lon' => null
@@ -33,8 +31,15 @@ class Contact_Info_Widget extends WP_Widget {
3331
* @return void
3432
**/
3533
function __construct() {
36-
$widget_ops = array( 'classname' => 'widget_contact_info', 'description' => __( 'Display your location, hours, and contact information.', $this->text_domain ) );
37-
parent::__construct( 'widget_contact_info', __( 'Contact Info', $this->text_domain ), $widget_ops );
34+
$widget_ops = array(
35+
'classname' => 'widget_contact_info',
36+
'description' => __( 'Display your location, hours, and contact information.', 'jetpack' )
37+
);
38+
parent::__construct(
39+
'widget_contact_info',
40+
apply_filters( 'jetpack_widget_name', __( 'Contact Info', 'jetpack' ) ),
41+
$widget_ops
42+
);
3843
$this->alt_option_name = 'widget_contact_info';
3944
}
4045

@@ -132,7 +137,7 @@ function update( $new_instance, $old_instance ) {
132137

133138
if ( ! $json ) {
134139
// The read failed :(
135-
esc_html_e( "There was a problem getting the data to display this address on a map. Please refresh your browser and try again.", $this->text_domain );
140+
esc_html_e( "There was a problem getting the data to display this address on a map. Please refresh your browser and try again.", 'jetpack' );
136141
die();
137142
}
138143

@@ -174,30 +179,30 @@ function form( $instance ) {
174179

175180
$disabled = !$this->has_good_map( $instance );
176181
?>
177-
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', $this->text_domain ); ?></label>
182+
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
178183

179184
<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>
180185

181-
<p><label for="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>"><?php esc_html_e( 'Address:', $this->text_domain ); ?></label>
186+
<p><label for="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>"><?php esc_html_e( 'Address:', 'jetpack' ); ?></label>
182187
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address' ) ); ?>"><?php echo esc_textarea( $address ); ?></textarea>
183188
<?php
184189
if ( $this->has_good_map( $instance ) ) {
185190
?>
186191
<input class="" id="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'showmap' ) ); ?>" value="1" type="checkbox" <?php checked( $showmap , 1); ?> />
187-
<label for="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>"><?php esc_html_e( 'Show map', $this->text_domain ); ?></label></p>
192+
<label for="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>"><?php esc_html_e( 'Show map', 'jetpack' ); ?></label></p>
188193
<?php
189194
} else {
190195
?>
191-
<span class="error-message"><?php _e("Sorry. We can not plot this address. a map will not be displayed. Is the address formatted correctly?"); ?></span></p>
196+
<span class="error-message"><?php _e( 'Sorry. We can not plot this address. A map will not be displayed. Is the address formatted correctly?', 'jetpack' ); ?></span></p>
192197
<input id="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'showmap' ) ); ?>" value="<?php echo( intval( $instance['showmap'] ) ); ?>" type="hidden" />
193198
<?php
194199
}
195200
?>
196201

197-
<p><label for="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>"><?php esc_html_e( 'Phone:', $this->text_domain ); ?></label>
202+
<p><label for="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>"><?php esc_html_e( 'Phone:', 'jetpack' ); ?></label>
198203
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone' ) ); ?>" type="text" value="<?php echo esc_attr( $phone ); ?>" /></p>
199204

200-
<p><label for="<?php echo esc_attr( $this->get_field_id( 'hours' ) ); ?>"><?php esc_html_e( 'Hours:', $this->text_domain ); ?></label>
205+
<p><label for="<?php echo esc_attr( $this->get_field_id( 'hours' ) ); ?>"><?php esc_html_e( 'Hours:', 'jetpack' ); ?></label>
201206

202207
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'hours' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hours' ) ); ?>"><?php echo esc_textarea( $hours ); ?></textarea></p>
203208

@@ -215,8 +220,8 @@ function build_map( $lat, $lon ) {
215220

216221
wp_enqueue_script( "jquery" );
217222
wp_enqueue_script( "google-maps", "https://maps.googleapis.com/maps/api/js?sensor=false" );
218-
wp_enqueue_script( "contact-info-map-js", plugins_url( 'contact-info-map.js', __FILE__ ), array( 'jquery', 'google-maps' ), 20150127 );
219-
wp_enqueue_style( "contact-info-map-css", plugins_url( 'contact-info-map.css', __FILE__ ), null, 20150127 );
223+
wp_enqueue_script( "contact-info-map-js", plugins_url( 'contact-info/contact-info-map.js', __FILE__ ), array( 'jquery', 'google-maps' ), 20150127 );
224+
wp_enqueue_style( "contact-info-map-css", plugins_url( 'contact-info/contact-info-map.css', __FILE__ ), null, 20150127 );
220225

221226
$lat = esc_attr( $lat );
222227
$lon = esc_attr( $lon );

0 commit comments

Comments
 (0)