| @@ -191,18 +191,28 @@ | ||
| 191 | 191 | CBXGooglemapHelper::enqueue_js_css(); |
| 192 | 192 | |
| 193 | 193 | $general_settings = get_option( 'cbxgooglemap_general', [] ); |
| 194 | 194 | |
| 195 | - $hide_leaflet = intval( $settings->get_field( 'hide_leaflet', 'cbxgooglemap_general', 0 ) ); | |
| 195 | + $hide_leaflet = absint( $settings->get_field( 'hide_leaflet', 'cbxgooglemap_general', 0 ) ); | |
| 196 | 196 | $api_key = esc_attr( $settings->get_field( 'apikey', 'cbxgooglemap_general', '' ) ); |
| 197 | - $map_source = intval( $settings->get_field( 'mapsource', 'cbxgooglemap_general', 1 ) ); | |
| 197 | + $map_source = absint( $settings->get_field( 'mapsource', 'cbxgooglemap_general', 1 ) ); | |
| 198 | 198 | |
| 199 | 199 | //if google map and api key is not present |
| 200 | 200 | if ( $map_source == 1 && $api_key == '' ) { |
| 201 | - return '<p style="text-align: center;">' . esc_html__( 'Google Map Api Key is invalid or empty. Please set in plugin setting.', 'cbxgooglemap' ) . '</p>'; | |
| 201 | + //return '<p style="text-align: center;">' . esc_html__( 'Google Map Api Key is invalid or empty. Please set in plugin setting.', 'cbxgooglemap' ) . '</p>'; | |
| 202 | + | |
| 203 | + return '<div class="notification notification-warning" style="margin-top: 10px;"> | |
| 204 | + <div class="notification-icon"> | |
| 205 | + <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 256 256"><path fill="#f59e0b" d="M235.07 189.09L147.61 37.22a22.75 22.75 0 0 0-39.22 0L20.93 189.09a21.53 21.53 0 0 0 0 21.72A22.35 22.35 0 0 0 40.55 222h174.9a22.35 22.35 0 0 0 19.6-11.19a21.53 21.53 0 0 0 .02-21.72Zm-10.41 15.71a10.46 10.46 0 0 1-9.21 5.2H40.55a10.46 10.46 0 0 1-9.21-5.2a9.51 9.51 0 0 1 0-9.72l87.45-151.87a10.75 10.75 0 0 1 18.42 0l87.46 151.87a9.51 9.51 0 0 1-.01 9.72ZM122 144v-40a6 6 0 0 1 12 0v40a6 6 0 0 1-12 0Zm16 36a10 10 0 1 1-10-10a10 10 0 0 1 10 10Z"/></svg> | |
| 206 | + </div> | |
| 207 | + <div class="notification-content"> | |
| 208 | + <div class="notification-title">'.esc_html__('Googlemap Api Key Missing', 'cbxgooglemap').'</div> | |
| 209 | + <div class="notification-message"><p>' . esc_html__( 'Google map api key missing, Please choose alternative openstreet map or set google map api key in plugin setting.', 'cbxgooglemap' ) . '</p></div> | |
| 210 | + </div> | |
| 211 | + </div>'; | |
| 202 | 212 | } |
| 203 | 213 | |
| 204 | - $zoom_default = intval( $settings->get_field( 'zoom', 'cbxgooglemap_general', '8' ) ); | |
| 214 | + $zoom_default = absint( $settings->get_field( 'zoom', 'cbxgooglemap_general', '8' ) ); | |
| 205 | 215 | if ( $zoom_default == 0 ) { |
| 206 | 216 | $zoom_default = 8; |
| 207 | 217 | } |
| 208 | 218 | |
| @@ -211,17 +221,17 @@ | ||
| 211 | 221 | if ( $width_default == '' || $width_default == 0 ) { |
| 212 | 222 | $width_default = '100%'; |
| 213 | 223 | } |
| 214 | 224 | |
| 215 | - $height_default = intval( $settings->get_field( 'height', 'cbxgooglemap_general', '300' ) ); | |
| 225 | + $height_default = absint( $settings->get_field( 'height', 'cbxgooglemap_general', '300' ) ); | |
| 216 | 226 | if ( $height_default == 0 ) { |
| 217 | 227 | $height_default = 300; |
| 218 | 228 | } |
| 219 | 229 | |
| 220 | 230 | |
| 221 | - $scrollwheel_default = intval( $settings->get_field( 'scrollwheel', 'cbxgooglemap_general', 1 ) ); | |
| 222 | - $showinfo_default = intval( $settings->get_field( 'showinfo', 'cbxgooglemap_general', 1 ) ); | |
| 223 | - $infow_open_default = intval( $settings->get_field( 'infow_open', 'cbxgooglemap_general', 1 ) ); | |
| 231 | + $scrollwheel_default = absint( $settings->get_field( 'scrollwheel', 'cbxgooglemap_general', 1 ) ); | |
| 232 | + $showinfo_default = absint( $settings->get_field( 'showinfo', 'cbxgooglemap_general', 1 ) ); | |
| 233 | + $infow_open_default = absint( $settings->get_field( 'infow_open', 'cbxgooglemap_general', 1 ) ); | |
| 224 | 234 | |
| 225 | 235 | $maptype_default = $settings->get_field( 'maptype', 'cbxgooglemap_general', 'roadmap' ); |
| 226 | 236 | $mapicon_default = $settings->get_field( 'mapicon', 'cbxgooglemap_general', '' ); |
| 227 | 237 | |
| @@ -281,14 +291,14 @@ | ||
| 281 | 291 | $heading = isset( $meta_combined['_cbxgooglemaptitle'] ) ? esc_html( $meta_combined['_cbxgooglemaptitle'] ) : ''; |
| 282 | 292 | |
| 283 | 293 | $zoom = ( isset( $meta_combined[ $meta_prefix . 'zoom' ] ) && intval( $meta_combined[ $meta_prefix . 'zoom' ] ) > 0 ) ? intval( $meta_combined[ $meta_prefix . 'zoom' ] ) : $zoom_default; |
| 284 | 294 | |
| 285 | - $scrollwheel = ( isset( $meta_combined[ $meta_prefix . 'scrollwheel' ] ) ) ? intval( $meta_combined[ $meta_prefix . 'scrollwheel' ] ) : intval( $scrollwheel_default ); | |
| 286 | - $showinfo = ( isset( $meta_combined[ $meta_prefix . 'showinfo' ] ) ) ? intval( $meta_combined[ $meta_prefix . 'showinfo' ] ) : intval( $showinfo_default ); | |
| 287 | - $infow_open = ( isset( $meta_combined[ $meta_prefix . 'infow_open' ] ) ) ? intval( $meta_combined[ $meta_prefix . 'infow_open' ] ) : intval( $infow_open_default ); | |
| 295 | + $scrollwheel = ( isset( $meta_combined[ $meta_prefix . 'scrollwheel' ] ) ) ? absint( $meta_combined[ $meta_prefix . 'scrollwheel' ] ) : intval( $scrollwheel_default ); | |
| 296 | + $showinfo = ( isset( $meta_combined[ $meta_prefix . 'showinfo' ] ) ) ? absint( $meta_combined[ $meta_prefix . 'showinfo' ] ) : intval( $showinfo_default ); | |
| 297 | + $infow_open = ( isset( $meta_combined[ $meta_prefix . 'infow_open' ] ) ) ? absint( $meta_combined[ $meta_prefix . 'infow_open' ] ) : intval( $infow_open_default ); | |
| 288 | 298 | |
| 289 | 299 | $width = ( isset( $meta_combined[ $meta_prefix . 'width' ] ) && $meta_combined[ $meta_prefix . 'width' ] != '' ) ? $meta_combined[ $meta_prefix . 'width' ] : $width_default; |
| 290 | - $height = ( isset( $meta_combined[ $meta_prefix . 'height' ] ) && intval( $meta_combined[ $meta_prefix . 'height' ] ) > 0 ) ? intval( $meta_combined[ $meta_prefix . 'height' ] ) : $height_default; | |
| 300 | + $height = ( isset( $meta_combined[ $meta_prefix . 'height' ] ) && absint( $meta_combined[ $meta_prefix . 'height' ] ) > 0 ) ? absint( $meta_combined[ $meta_prefix . 'height' ] ) : $height_default; | |
| 291 | 301 | |
| 292 | 302 | $address = ( isset( $meta_combined[ $meta_prefix . 'address' ] ) && esc_attr( $meta_combined[ $meta_prefix . 'address' ] ) != '' ) ? esc_attr( $meta_combined[ $meta_prefix . 'address' ] ) : ''; |
| 293 | 303 | $website = ( isset( $meta_combined[ $meta_prefix . 'website' ] ) && esc_url( $meta_combined[ $meta_prefix . 'website' ] ) != '' ) ? esc_url( $meta_combined[ $meta_prefix . 'website' ] ) : ''; |
| 294 | 304 | |
| @@ -299,10 +309,10 @@ | ||
| 299 | 309 | else { |
| 300 | 310 | $atts = cbxgooglemap_decode_entities_array($atts); |
| 301 | 311 | |
| 302 | 312 | //show map from shortcode params only |
| 303 | - $lat = isset( $atts['lat'] ) ? floatval( $atts['lat'] ) : ''; | |
| 304 | - $lng = isset( $atts['lat'] ) ? floatval( $atts['lng'] ) : ''; | |
| 313 | + $lat = isset( $atts['lat'] ) ? (float) $atts['lat'] : ''; | |
| 314 | + $lng = isset( $atts['lat'] ) ? (float) $atts['lng'] : ''; | |
| 305 | 315 | |
| 306 | 316 | if($lat === 0) $lat = ''; |
| 307 | 317 | if($lng === 0) $lng = ''; |
| 308 | 318 | |
| @@ -311,9 +321,9 @@ | ||
| 311 | 321 | } //at least we need lat lng |
| 312 | 322 | |
| 313 | 323 | |
| 314 | 324 | $width = isset( $atts['width'] ) ? $atts['width'] : ''; |
| 315 | - $height = isset( $atts['height'] ) ? intval( $atts['height'] ) : ''; | |
| 325 | + $height = isset( $atts['height'] ) ? (int) $atts['height'] : ''; | |
| 316 | 326 | |
| 317 | 327 | $zoom = isset( $atts['zoom'] ) ? $atts['zoom'] : $zoom_default; |
| 318 | 328 | $heading = isset( $atts['heading'] ) ? sanitize_text_field( wp_unslash( $atts['heading'] ) ) : ''; |
| 319 | 329 | $address = isset( $atts['address'] ) ? sanitize_text_field( wp_unslash( $atts['address'] ) ) : ''; |