This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * ACF Google Map Field Class |
||
5 | * |
||
6 | * All the logic for this field type |
||
7 | * |
||
8 | * @class acf_field_google_map |
||
9 | * @extends acf_field |
||
10 | * @package ACF |
||
11 | * @subpackage Fields |
||
12 | */ |
||
13 | |||
14 | if( ! class_exists('acf_field_google_map') ) : |
||
15 | |||
16 | class acf_field_google_map extends acf_field { |
||
17 | |||
18 | |||
19 | /* |
||
20 | * __construct |
||
21 | * |
||
22 | * This function will setup the field type data |
||
23 | * |
||
24 | * @type function |
||
25 | * @date 5/03/2014 |
||
26 | * @since 5.0.0 |
||
27 | * |
||
28 | * @param n/a |
||
29 | * @return n/a |
||
30 | */ |
||
0 ignored issues
–
show
|
|||
31 | |||
32 | function __construct() { |
||
0 ignored issues
–
show
|
|||
33 | |||
34 | // vars |
||
35 | $this->name = 'google_map'; |
||
36 | $this->label = __("Google Map",'acf'); |
||
0 ignored issues
–
show
The property
label does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
37 | $this->category = 'jquery'; |
||
38 | $this->defaults = array( |
||
39 | 'height' => '', |
||
40 | 'center_lat' => '', |
||
41 | 'center_lng' => '', |
||
42 | 'zoom' => '' |
||
43 | ); |
||
44 | $this->default_values = array( |
||
0 ignored issues
–
show
The property
default_values does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
45 | 'height' => '400', |
||
46 | 'center_lat' => '-37.81411', |
||
47 | 'center_lng' => '144.96328', |
||
48 | 'zoom' => '14' |
||
49 | ); |
||
50 | $this->l10n = array( |
||
51 | 'locating' => __("Locating",'acf'), |
||
52 | 'browser_support' => __("Sorry, this browser does not support geolocation",'acf'), |
||
53 | ); |
||
54 | |||
55 | |||
56 | // do not delete! |
||
57 | parent::__construct(); |
||
58 | } |
||
59 | |||
60 | |||
61 | /* |
||
62 | * render_field() |
||
63 | * |
||
64 | * Create the HTML interface for your field |
||
65 | * |
||
66 | * @param $field - an array holding all the field's data |
||
67 | * |
||
68 | * @type action |
||
69 | * @since 3.6 |
||
70 | * @date 23/01/13 |
||
71 | */ |
||
72 | |||
73 | function render_field( $field ) { |
||
0 ignored issues
–
show
|
|||
74 | |||
75 | // validate value |
||
76 | if( empty($field['value']) ) { |
||
77 | |||
78 | $field['value'] = array(); |
||
79 | |||
80 | } |
||
81 | |||
82 | |||
83 | // value |
||
84 | $field['value'] = acf_parse_args($field['value'], array( |
||
85 | 'address' => '', |
||
86 | 'lat' => '', |
||
87 | 'lng' => '' |
||
88 | )); |
||
89 | |||
90 | |||
91 | // default options |
||
92 | foreach( $this->default_values as $k => $v ) { |
||
93 | |||
94 | if( empty($field[ $k ]) ) { |
||
95 | |||
96 | $field[ $k ] = $v; |
||
97 | |||
98 | } |
||
99 | |||
100 | } |
||
101 | |||
102 | |||
103 | // vars |
||
104 | $atts = array( |
||
105 | 'id' => $field['id'], |
||
106 | 'class' => "acf-google-map {$field['class']}", |
||
107 | 'data-id' => $field['id'] . '-' . uniqid(), |
||
108 | 'data-lat' => $field['center_lat'], |
||
109 | 'data-lng' => $field['center_lng'], |
||
110 | 'data-zoom' => $field['zoom'], |
||
111 | ); |
||
112 | |||
113 | |||
114 | // has value |
||
115 | if( $field['value']['address'] ) { |
||
116 | |||
117 | $atts['class'] .= ' -value'; |
||
118 | |||
119 | } |
||
120 | |||
121 | ?> |
||
122 | <div <?php acf_esc_attr_e($atts); ?>> |
||
123 | |||
124 | <div class="acf-hidden"> |
||
125 | <?php foreach( $field['value'] as $k => $v ): ?> |
||
126 | <input type="hidden" class="input-<?php echo $k; ?>" name="<?php echo esc_attr($field['name']); ?>[<?php echo $k; ?>]" value="<?php echo esc_attr( $v ); ?>" /> |
||
127 | <?php endforeach; ?> |
||
128 | </div> |
||
129 | |||
130 | <div class="title acf-soh"> |
||
131 | |||
132 | <div class="actions acf-soh-target"> |
||
133 | <a href="#" data-name="search" class="acf-icon -search grey" title="<?php _e("Search", 'acf'); ?>"></a> |
||
134 | <a href="#" data-name="clear" class="acf-icon -cancel grey" title="<?php _e("Clear location", 'acf'); ?>"></a> |
||
135 | <a href="#" data-name="locate" class="acf-icon -location grey" title="<?php _e("Find current location", 'acf'); ?>"></a> |
||
136 | </div> |
||
137 | |||
138 | <input class="search" type="text" placeholder="<?php _e("Search for address...",'acf'); ?>" value="<?php echo $field['value']['address']; ?>" /> |
||
139 | <i class="acf-loading"></i> |
||
140 | |||
141 | </div> |
||
142 | |||
143 | <div class="canvas" style="height: <?php echo $field['height']; ?>px"></div> |
||
144 | |||
145 | </div> |
||
146 | <?php |
||
147 | |||
148 | } |
||
149 | |||
150 | |||
151 | /* |
||
152 | * render_field_settings() |
||
153 | * |
||
154 | * Create extra options for your field. This is rendered when editing a field. |
||
155 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
||
156 | * |
||
157 | * @type action |
||
158 | * @since 3.6 |
||
159 | * @date 23/01/13 |
||
160 | * |
||
161 | * @param $field - an array holding all the field's data |
||
162 | */ |
||
163 | |||
164 | function render_field_settings( $field ) { |
||
0 ignored issues
–
show
|
|||
165 | |||
166 | // center_lat |
||
167 | acf_render_field_setting( $field, array( |
||
168 | 'label' => __('Center','acf'), |
||
169 | 'instructions' => __('Center the initial map','acf'), |
||
170 | 'type' => 'text', |
||
171 | 'name' => 'center_lat', |
||
172 | 'prepend' => 'lat', |
||
173 | 'placeholder' => $this->default_values['center_lat'] |
||
174 | )); |
||
175 | |||
176 | |||
177 | // center_lng |
||
178 | acf_render_field_setting( $field, array( |
||
179 | 'label' => __('Center','acf'), |
||
180 | 'instructions' => __('Center the initial map','acf'), |
||
181 | 'type' => 'text', |
||
182 | 'name' => 'center_lng', |
||
183 | 'prepend' => 'lng', |
||
184 | 'placeholder' => $this->default_values['center_lng'], |
||
185 | 'wrapper' => array( |
||
186 | 'data-append' => 'center_lat' |
||
187 | ) |
||
188 | )); |
||
189 | |||
190 | |||
191 | // zoom |
||
192 | acf_render_field_setting( $field, array( |
||
193 | 'label' => __('Zoom','acf'), |
||
194 | 'instructions' => __('Set the initial zoom level','acf'), |
||
195 | 'type' => 'text', |
||
196 | 'name' => 'zoom', |
||
197 | 'placeholder' => $this->default_values['zoom'] |
||
198 | )); |
||
199 | |||
200 | |||
201 | // allow_null |
||
202 | acf_render_field_setting( $field, array( |
||
203 | 'label' => __('Height','acf'), |
||
204 | 'instructions' => __('Customise the map height','acf'), |
||
205 | 'type' => 'text', |
||
206 | 'name' => 'height', |
||
207 | 'append' => 'px', |
||
208 | 'placeholder' => $this->default_values['height'] |
||
209 | )); |
||
210 | |||
211 | } |
||
212 | |||
213 | |||
214 | /* |
||
215 | * validate_value |
||
216 | * |
||
217 | * description |
||
218 | * |
||
219 | * @type function |
||
220 | * @date 11/02/2014 |
||
221 | * @since 5.0.0 |
||
222 | * |
||
223 | * @param $post_id (int) |
||
224 | * @return $post_id (int) |
||
225 | */ |
||
0 ignored issues
–
show
The doc-type
$post_id could not be parsed: Unknown type name "$post_id" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
226 | |||
227 | View Code Duplication | function validate_value( $valid, $value, $field, $input ){ |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
228 | |||
229 | // bail early if not required |
||
230 | if( ! $field['required'] ) { |
||
231 | |||
232 | return $valid; |
||
233 | |||
234 | } |
||
235 | |||
236 | |||
237 | if( empty($value) || empty($value['lat']) || empty($value['lng']) ) { |
||
238 | |||
239 | return false; |
||
240 | |||
241 | } |
||
242 | |||
243 | |||
244 | // return |
||
245 | return $valid; |
||
246 | |||
247 | } |
||
248 | |||
249 | |||
250 | /* |
||
251 | * update_value() |
||
252 | * |
||
253 | * This filter is appied to the $value before it is updated in the db |
||
254 | * |
||
255 | * @type filter |
||
256 | * @since 3.6 |
||
257 | * @date 23/01/13 |
||
258 | * |
||
259 | * @param $value - the value which will be saved in the database |
||
260 | * @param $post_id - the $post_id of which the value will be saved |
||
261 | * @param $field - the field array holding all the field options |
||
262 | * |
||
263 | * @return $value - the modified value |
||
264 | */ |
||
0 ignored issues
–
show
The doc-type
$value could not be parsed: Unknown type name "$value" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
265 | |||
266 | View Code Duplication | function update_value( $value, $post_id, $field ) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
267 | |||
268 | if( empty($value) || empty($value['lat']) || empty($value['lng']) ) { |
||
269 | |||
270 | return false; |
||
271 | |||
272 | } |
||
273 | |||
274 | |||
275 | // return |
||
276 | return $value; |
||
277 | } |
||
278 | } |
||
279 | |||
280 | new acf_field_google_map(); |
||
281 | |||
282 | endif; |
||
283 | |||
284 | ?> |
||
285 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.