|
@@ -1,7 +1,7 @@ discard block |
|
|
block discarded – undo |
|
1
|
1
|
<?php |
|
2
|
2
|
|
|
3
|
3
|
/* Exit if accessed directly */ |
|
4
|
|
-if ( ! defined( 'ABSPATH' ) ) { exit; } |
|
|
4
|
+if ( ! defined('ABSPATH')) { exit; } |
|
5
|
5
|
|
|
6
|
6
|
/** |
|
7
|
7
|
* StreetAdvisor_Details class. |
|
@@ -20,9 +20,9 @@ discard block |
|
|
block discarded – undo |
|
20
|
20
|
|
|
21
|
21
|
parent::__construct( |
|
22
|
22
|
'streetadvisor-details', |
|
23
|
|
- __( 'Street Advisor - Location Details', 're-pro' ), |
|
|
23
|
+ __('Street Advisor - Location Details', 're-pro'), |
|
24
|
24
|
array( |
|
25
|
|
- 'description' => __( 'Street Advisor Location Details', 're-pro' ), |
|
|
25
|
+ 'description' => __('Street Advisor Location Details', 're-pro'), |
|
26
|
26
|
) |
|
27
|
27
|
); |
|
28
|
28
|
|
|
@@ -36,23 +36,23 @@ discard block |
|
|
block discarded – undo |
|
36
|
36
|
* @param mixed $instance |
|
37
|
37
|
* @return void |
|
38
|
38
|
*/ |
|
39
|
|
- public function widget( $args, $instance ) { |
|
|
39
|
+ public function widget($args, $instance) { |
|
40
|
40
|
|
|
41
|
41
|
// Retrieve an existing value from the database |
|
42
|
|
- $latitude = !empty( $instance['latitude'] ) ? $instance['latitude'] : ''; |
|
43
|
|
- $longitude = !empty( $instance['longitude'] ) ? $instance['longitude'] : ''; |
|
44
|
|
- $level = !empty( $instance['level'] ) ? $instance['level'] : ''; |
|
45
|
|
- $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
|
42
|
+ $latitude = ! empty($instance['latitude']) ? $instance['latitude'] : ''; |
|
|
43
|
+ $longitude = ! empty($instance['longitude']) ? $instance['longitude'] : ''; |
|
|
44
|
+ $level = ! empty($instance['level']) ? $instance['level'] : ''; |
|
|
45
|
+ $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
46
|
46
|
|
|
47
|
|
- $streetadvisor = new StreetAdvisorAPI( 'b08f6473-8dee-41c3-9a3e-b32f335e9d2d' ); |
|
|
47
|
+ $streetadvisor = new StreetAdvisorAPI('b08f6473-8dee-41c3-9a3e-b32f335e9d2d'); |
|
48
|
48
|
|
|
49
|
|
- $location = $streetadvisor->get_location_data( $latitude, $longitude, $level ); |
|
|
49
|
+ $location = $streetadvisor->get_location_data($latitude, $longitude, $level); |
|
50
|
50
|
|
|
51
|
51
|
$name = $location['Location']['Name']; |
|
52
|
52
|
$ranking_description = $location['Location']['RankingDescription']; |
|
53
|
53
|
$score = $location['Location']['Score']; |
|
54
|
|
- $photo_url = esc_url( apply_filters( 'jetpack_photon_url', $location['Location']['PhotoUrl'] ) ); |
|
55
|
|
- $streetadvisor_url = esc_url( $location['Location']['Url'] ); // Lets force HTTPS for this please ! |
|
|
54
|
+ $photo_url = esc_url(apply_filters('jetpack_photon_url', $location['Location']['PhotoUrl'])); |
|
|
55
|
+ $streetadvisor_url = esc_url($location['Location']['Url']); // Lets force HTTPS for this please ! |
|
56
|
56
|
|
|
57
|
57
|
$recommendations_greatfor = $location['Recommendations']['GreatFor']; |
|
58
|
58
|
$recommendations_notgreatfor = $location['Recommendations']['NotGreatFor']; |
|
@@ -61,20 +61,20 @@ discard block |
|
|
block discarded – undo |
|
61
|
61
|
|
|
62
|
62
|
echo $args['before_widget']; |
|
63
|
63
|
|
|
64
|
|
- echo $args['before_title'] . esc_attr( $title ) . $args['after_title']; |
|
|
64
|
+ echo $args['before_title'] . esc_attr($title) . $args['after_title']; |
|
65
|
65
|
|
|
66
|
66
|
echo '<style>.sa-column{width:100%;float:left;display:inline-block;}.streetadvisor-list{margin: 10px 0;}.streetadvisor-list li {list-style-type:circle !important;margin:0;padding:0;list-style-position: inside;}</style>'; |
|
67
|
67
|
|
|
68
|
|
- echo '<img id="" class="" src="'.$photo_url.'" srcset="" sizes="" alt="'. $name .'" height="" width="">'; |
|
|
68
|
+ echo '<img id="" class="" src="' . $photo_url . '" srcset="" sizes="" alt="' . $name . '" height="" width="">'; |
|
69
|
69
|
|
|
70
|
70
|
|
|
71
|
|
- echo '<p>' . $name . ' has a score of <strong>' . $score . ' out of 10</strong> on <a href="'. $streetadvisor_url .'" rel="nofollow">StreetAdvisor</a>. '. $ranking_description .'</p>'; |
|
|
71
|
+ echo '<p>' . $name . ' has a score of <strong>' . $score . ' out of 10</strong> on <a href="' . $streetadvisor_url . '" rel="nofollow">StreetAdvisor</a>. ' . $ranking_description . '</p>'; |
|
72
|
72
|
|
|
73
|
73
|
echo '<div class="sa-column">'; |
|
74
|
74
|
|
|
75
|
75
|
echo '<strong>Great For:</strong>'; |
|
76
|
76
|
echo '<ul class="re-pro streetadvisor-list streetadvisor-great-for">'; |
|
77
|
|
- foreach($recommendations_greatfor as $greatfor_item) { |
|
|
77
|
+ foreach ($recommendations_greatfor as $greatfor_item) { |
|
78
|
78
|
echo '<li>' . $greatfor_item . '</li>'; |
|
79
|
79
|
} |
|
80
|
80
|
echo '</ul>'; |
|
@@ -83,7 +83,7 @@ discard block |
|
|
block discarded – undo |
|
83
|
83
|
echo '<div class="sa-column">'; |
|
84
|
84
|
echo '<strong>Not Great For:</strong>'; |
|
85
|
85
|
echo '<ul class="re-pro streetadvisor-list streetadvisor-not-great-for">'; |
|
86
|
|
- foreach($recommendations_notgreatfor as $notgreatfor_item) { |
|
|
86
|
+ foreach ($recommendations_notgreatfor as $notgreatfor_item) { |
|
87
|
87
|
echo '<li>' . $notgreatfor_item . '</li>'; |
|
88
|
88
|
} |
|
89
|
89
|
echo '</ul>'; |
|
@@ -92,7 +92,7 @@ discard block |
|
|
block discarded – undo |
|
92
|
92
|
echo '<div class="sa-column">'; |
|
93
|
93
|
echo '<strong>Who Lives Here:</strong>'; |
|
94
|
94
|
echo '<ul class="re-pro streetadvisor-list streetadvisor-who-lives-here">'; |
|
95
|
|
- foreach($recommendations_wholiveshere as $wholiveshere_item) { |
|
|
95
|
+ foreach ($recommendations_wholiveshere as $wholiveshere_item) { |
|
96
|
96
|
echo '<li>' . $wholiveshere_item . '</li>'; |
|
97
|
97
|
} |
|
98
|
98
|
echo '</ul>'; |
|
@@ -109,45 +109,45 @@ discard block |
|
|
block discarded – undo |
|
109
|
109
|
* @param mixed $instance |
|
110
|
110
|
* @return void |
|
111
|
111
|
*/ |
|
112
|
|
- public function form( $instance ) { |
|
|
112
|
+ public function form($instance) { |
|
113
|
113
|
|
|
114
|
114
|
// Set default values |
|
115
|
|
- $instance = wp_parse_args( (array) $instance, array( |
|
|
115
|
+ $instance = wp_parse_args((array) $instance, array( |
|
116
|
116
|
'latitude' => '', |
|
117
|
117
|
'longitude' => '', |
|
118
|
118
|
'level' => '', |
|
119
|
119
|
'title' => '', |
|
120
|
|
- ) ); |
|
|
120
|
+ )); |
|
121
|
121
|
|
|
122
|
122
|
// Retrieve an existing value from the database |
|
123
|
|
- $latitude = !empty( $instance['latitude'] ) ? $instance['latitude'] : ''; |
|
124
|
|
- $longitude = !empty( $instance['longitude'] ) ? $instance['longitude'] : ''; |
|
125
|
|
- $level = !empty( $instance['level'] ) ? $instance['level'] : ''; |
|
126
|
|
- $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
|
123
|
+ $latitude = ! empty($instance['latitude']) ? $instance['latitude'] : ''; |
|
|
124
|
+ $longitude = ! empty($instance['longitude']) ? $instance['longitude'] : ''; |
|
|
125
|
+ $level = ! empty($instance['level']) ? $instance['level'] : ''; |
|
|
126
|
+ $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
127
|
127
|
|
|
128
|
128
|
// Form fields |
|
129
|
129
|
echo '<p>'; |
|
130
|
|
- echo ' <label for="' . $this->get_field_id( 'title' ) . '" class="title_label">' . __( 'Title', 're-pro' ) . '</label>'; |
|
131
|
|
- echo ' <input type="text" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" class="widefat" placeholder="' . esc_attr__( '', 're-pro' ) . '" value="' . esc_attr( $title ) . '">'; |
|
132
|
|
- echo ' <span class="description">' . __( 'Title', 're-pro' ) . '</span>'; |
|
|
130
|
+ echo ' <label for="' . $this->get_field_id('title') . '" class="title_label">' . __('Title', 're-pro') . '</label>'; |
|
|
131
|
+ echo ' <input type="text" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" class="widefat" placeholder="' . esc_attr__('', 're-pro') . '" value="' . esc_attr($title) . '">'; |
|
|
132
|
+ echo ' <span class="description">' . __('Title', 're-pro') . '</span>'; |
|
133
|
133
|
echo '</p>'; |
|
134
|
134
|
|
|
135
|
135
|
echo '<p>'; |
|
136
|
|
- echo ' <label for="' . $this->get_field_id( 'latitude' ) . '" class="latitude_label">' . __( 'Latitude', 're-pro' ) . '</label>'; |
|
137
|
|
- echo ' <input type="text" id="' . $this->get_field_id( 'latitude' ) . '" name="' . $this->get_field_name( 'latitude' ) . '" class="widefat" placeholder="' . esc_attr__( '', 're-pro' ) . '" value="' . esc_attr( $latitude ) . '">'; |
|
138
|
|
- echo ' <span class="description">' . __( 'Latitude', 're-pro' ) . '</span>'; |
|
|
136
|
+ echo ' <label for="' . $this->get_field_id('latitude') . '" class="latitude_label">' . __('Latitude', 're-pro') . '</label>'; |
|
|
137
|
+ echo ' <input type="text" id="' . $this->get_field_id('latitude') . '" name="' . $this->get_field_name('latitude') . '" class="widefat" placeholder="' . esc_attr__('', 're-pro') . '" value="' . esc_attr($latitude) . '">'; |
|
|
138
|
+ echo ' <span class="description">' . __('Latitude', 're-pro') . '</span>'; |
|
139
|
139
|
echo '</p>'; |
|
140
|
140
|
|
|
141
|
141
|
echo '<p>'; |
|
142
|
|
- echo ' <label for="' . $this->get_field_id( 'longitude' ) . '" class="longitude_label">' . __( 'Longitude', 're-pro' ) . '</label>'; |
|
143
|
|
- echo ' <input type="text" id="' . $this->get_field_id( 'longitude' ) . '" name="' . $this->get_field_name( 'longitude' ) . '" class="widefat" placeholder="' . esc_attr__( '', 're-pro' ) . '" value="' . esc_attr( $longitude ) . '">'; |
|
144
|
|
- echo ' <span class="description">' . __( 'Longitude', 're-pro' ) . '</span>'; |
|
|
142
|
+ echo ' <label for="' . $this->get_field_id('longitude') . '" class="longitude_label">' . __('Longitude', 're-pro') . '</label>'; |
|
|
143
|
+ echo ' <input type="text" id="' . $this->get_field_id('longitude') . '" name="' . $this->get_field_name('longitude') . '" class="widefat" placeholder="' . esc_attr__('', 're-pro') . '" value="' . esc_attr($longitude) . '">'; |
|
|
144
|
+ echo ' <span class="description">' . __('Longitude', 're-pro') . '</span>'; |
|
145
|
145
|
echo '</p>'; |
|
146
|
146
|
|
|
147
|
147
|
echo '<p>'; |
|
148
|
|
- echo ' <label for="' . $this->get_field_id( 'level' ) . '" class="level_label">' . __( 'Level', 're-pro' ) . '</label>'; |
|
149
|
|
- echo ' <input type="number" id="' . $this->get_field_id( 'level' ) . '" name="' . $this->get_field_name( 'level' ) . '" class="widefat" placeholder="' . esc_attr__( '', 're-pro' ) . '" value="' . esc_attr( $level ) . '" step="1" min="0" max="50">'; |
|
150
|
|
- echo ' <span class="description">' . __( 'Level', 're-pro' ) . '</span>'; |
|
|
148
|
+ echo ' <label for="' . $this->get_field_id('level') . '" class="level_label">' . __('Level', 're-pro') . '</label>'; |
|
|
149
|
+ echo ' <input type="number" id="' . $this->get_field_id('level') . '" name="' . $this->get_field_name('level') . '" class="widefat" placeholder="' . esc_attr__('', 're-pro') . '" value="' . esc_attr($level) . '" step="1" min="0" max="50">'; |
|
|
150
|
+ echo ' <span class="description">' . __('Level', 're-pro') . '</span>'; |
|
151
|
151
|
echo '</p>'; |
|
152
|
152
|
|
|
153
|
153
|
|
|
@@ -163,14 +163,14 @@ discard block |
|
|
block discarded – undo |
|
163
|
163
|
* @param mixed $old_instance |
|
164
|
164
|
* @return void |
|
165
|
165
|
*/ |
|
166
|
|
- public function update( $new_instance, $old_instance ) { |
|
|
166
|
+ public function update($new_instance, $old_instance) { |
|
167
|
167
|
|
|
168
|
168
|
$instance = $old_instance; |
|
169
|
169
|
|
|
170
|
|
- $instance['latitude'] = !empty( $new_instance['latitude'] ) ? strip_tags( $new_instance['latitude'] ) : ''; |
|
171
|
|
- $instance['longitude'] = !empty( $new_instance['longitude'] ) ? strip_tags( $new_instance['longitude'] ) : ''; |
|
172
|
|
- $instance['level'] = !empty( $new_instance['level'] ) ? strip_tags( $new_instance['level'] ) : ''; |
|
173
|
|
- $instance['title'] = !empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; |
|
|
170
|
+ $instance['latitude'] = ! empty($new_instance['latitude']) ? strip_tags($new_instance['latitude']) : ''; |
|
|
171
|
+ $instance['longitude'] = ! empty($new_instance['longitude']) ? strip_tags($new_instance['longitude']) : ''; |
|
|
172
|
+ $instance['level'] = ! empty($new_instance['level']) ? strip_tags($new_instance['level']) : ''; |
|
|
173
|
+ $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
174
|
174
|
|
|
175
|
175
|
return $instance; |
|
176
|
176
|
|
|
@@ -185,6 +185,6 @@ discard block |
|
|
block discarded – undo |
|
185
|
185
|
* @return void |
|
186
|
186
|
*/ |
|
187
|
187
|
function register_widgets() { |
|
188
|
|
- register_widget( 'StreetAdvisor_Details' ); |
|
|
188
|
+ register_widget('StreetAdvisor_Details'); |
|
189
|
189
|
} |
|
190
|
|
-add_action( 'widgets_init', 'register_widgets' ); |
|
|
190
|
+add_action('widgets_init', 'register_widgets'); |