| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wdk\Elementor\Widgets; |
| 4 |
|
| 5 |
use Wdk\Elementor\Widgets\WdkElementorBase; |
| 6 |
use Elementor\Widget_Base; |
| 7 |
use Elementor\Controls_Manager; |
| 8 |
use Elementor\Utils; |
| 9 |
use Elementor\Typography; |
| 10 |
use Elementor\Editor; |
| 11 |
use Elementor\Plugin; |
| 12 |
use Elementor\Repeater; |
| 13 |
use Elementor\Core\Schemes; |
| 14 |
use Elementor\Icons_Manager; |
| 15 |
use Elementor\Group_Control_Typography; |
| 16 |
use Elementor\Group_Control_Border; |
| 17 |
use Elementor\Group_Control_Box_Shadow; |
| 18 |
|
| 19 |
if (!defined('ABSPATH')) |
| 20 |
exit; // Exit if accessed directly |
| 21 |
|
| 22 |
/** |
| 23 |
* @since 1.1.0 |
| 24 |
*/ |
| 25 |
class WdkListingMap extends WdkElementorBase { |
| 26 |
|
| 27 |
public function __construct($data = array(), $args = null) { |
| 28 |
|
| 29 |
\Elementor\Controls_Manager::add_tab( |
| 30 |
'tab_conf', |
| 31 |
esc_html__('Settings', 'wpdirectorykit') |
| 32 |
); |
| 33 |
|
| 34 |
\Elementor\Controls_Manager::add_tab( |
| 35 |
'tab_layout', |
| 36 |
esc_html__('InfoWindow', 'wpdirectorykit') |
| 37 |
); |
| 38 |
|
| 39 |
\Elementor\Controls_Manager::add_tab( |
| 40 |
'tab_content', |
| 41 |
esc_html__('Main', 'wpdirectorykit') |
| 42 |
); |
| 43 |
|
| 44 |
if ($this->is_edit_mode_load()) { |
| 45 |
$this->enqueue_styles_scripts(); |
| 46 |
} |
| 47 |
|
| 48 |
parent::__construct($data, $args); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Retrieve the list of categories the widget belongs to. |
| 53 |
* |
| 54 |
* Used to determine where to display the widget in the editor. |
| 55 |
* |
| 56 |
* Note that currently Elementor supports only one category. |
| 57 |
* When multiple categories passed, Elementor uses the first one. |
| 58 |
* |
| 59 |
* @since 1.1.0 |
| 60 |
* |
| 61 |
* @access public |
| 62 |
* |
| 63 |
* @return array Widget categories. |
| 64 |
*/ |
| 65 |
public function get_categories() { |
| 66 |
return [ 'wdk-elementor-listing-preview' ]; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Retrieve the widget name. |
| 71 |
* |
| 72 |
* @since 1.1.0 |
| 73 |
* |
| 74 |
* @access public |
| 75 |
* |
| 76 |
* @return string Widget name. |
| 77 |
*/ |
| 78 |
public function get_name() { |
| 79 |
return 'wdk-listing-map'; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Retrieve the widget title. |
| 84 |
* |
| 85 |
* @since 1.1.0 |
| 86 |
* |
| 87 |
* @access public |
| 88 |
* |
| 89 |
* @return string Widget title. |
| 90 |
*/ |
| 91 |
public function get_title() { |
| 92 |
return esc_html__('Wdk Listing Map', 'wpdirectorykit'); |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Retrieve the widget icon. |
| 97 |
* |
| 98 |
* @since 1.1.0 |
| 99 |
* |
| 100 |
* @access public |
| 101 |
* |
| 102 |
* @return string Widget icon. |
| 103 |
*/ |
| 104 |
public function get_icon() { |
| 105 |
return 'eicon-google-maps'; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Register the widget controls. |
| 110 |
* |
| 111 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 112 |
* |
| 113 |
* @since 1.1.0 |
| 114 |
* |
| 115 |
* @access protected |
| 116 |
*/ |
| 117 |
protected function register_controls() { |
| 118 |
$this->generate_controls_conf(); |
| 119 |
$this->generate_controls_layout(); |
| 120 |
$this->generate_controls_styles(); |
| 121 |
$this->generate_controls_content(); |
| 122 |
|
| 123 |
$this->insert_pro_message('1'); |
| 124 |
parent::register_controls(); |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Render the widget output on the frontend. |
| 129 |
* |
| 130 |
* Written in PHP and used to generate the final HTML. |
| 131 |
* |
| 132 |
* @since 1.1.0 |
| 133 |
* |
| 134 |
* @access protected |
| 135 |
*/ |
| 136 |
|
| 137 |
protected function render() { |
| 138 |
parent::render(); |
| 139 |
global $wdk_listing_id; |
| 140 |
|
| 141 |
$this->data['id_element'] = $this->get_id(); |
| 142 |
$this->data['settings'] = $this->get_settings(); |
| 143 |
|
| 144 |
/* default from settings */ |
| 145 |
$this->data['lat'] = wdk_get_option('wdk_default_lat', 51.505); |
| 146 |
$this->data['lng'] = wdk_get_option('wdk_default_lng', -0.09); |
| 147 |
$this->data['wdk_listing_id'] = $wdk_listing_id; |
| 148 |
|
| 149 |
if(!Plugin::$instance->editor->is_edit_mode() && !empty($wdk_listing_id)) { |
| 150 |
$this->data['lat'] = $this->data['lng'] = NULL; |
| 151 |
if(!empty($this->data['settings']['field_id'])) { |
| 152 |
if(strpos($this->data['settings']['field_id'],'__') !== FALSE){ |
| 153 |
$this->data['settings']['field_id'] = substr($this->data['settings']['field_id'], strpos($this->data['settings']['field_id'],'__')+2); |
| 154 |
} |
| 155 |
|
| 156 |
$gps = wdk_get_gps(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)); |
| 157 |
if($gps) { |
| 158 |
$this->data['lat'] = $gps['lat']; |
| 159 |
$this->data['lng'] = $gps['lng']; |
| 160 |
} |
| 161 |
} else { |
| 162 |
$this->data['lat'] = wdk_field_value ('lat', $wdk_listing_id); |
| 163 |
$this->data['lng'] = wdk_field_value ('lng', $wdk_listing_id); |
| 164 |
} |
| 165 |
} else { |
| 166 |
|
| 167 |
} |
| 168 |
|
| 169 |
$this->data['is_edit_mode']= false; |
| 170 |
if(Plugin::$instance->editor->is_edit_mode() || empty($wdk_listing_id)) { |
| 171 |
$this->data['is_edit_mode']= true; |
| 172 |
} |
| 173 |
|
| 174 |
echo $this->view('wdk-listing-map', $this->data); |
| 175 |
} |
| 176 |
|
| 177 |
private function generate_controls_conf() { |
| 178 |
if(true){ |
| 179 |
|
| 180 |
$this->start_controls_section( |
| 181 |
'conf_custom_map', |
| 182 |
[ |
| 183 |
'label' => esc_html__('Map', 'wpdirectorykit'), |
| 184 |
'tab' => '1', |
| 185 |
] |
| 186 |
); |
| 187 |
|
| 188 |
|
| 189 |
$this->add_control( |
| 190 |
'enable_router_suggest', |
| 191 |
[ |
| 192 |
'label' => esc_html__( 'Enable Router Suggestion', 'wpdirectorykit' ), |
| 193 |
'type' => Controls_Manager::SWITCHER, |
| 194 |
'none' => esc_html__( 'True', 'wpdirectorykit' ), |
| 195 |
'block' => esc_html__( 'False', 'wpdirectorykit' ), |
| 196 |
'render_type' => 'template', |
| 197 |
'return_value' => 'yes', |
| 198 |
'default' => '', |
| 199 |
] |
| 200 |
); |
| 201 |
|
| 202 |
$this->add_control( |
| 203 |
'text_suggestion_route_placeholder', |
| 204 |
[ |
| 205 |
'label' => __( 'Suggestion route placeholder', 'wpdirectorykit' ), |
| 206 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 207 |
'rows' => 5, |
| 208 |
'default' => __( 'Type your address', 'wpdirectorykit' ), |
| 209 |
'conditions' => [ |
| 210 |
'terms' => [ |
| 211 |
[ |
| 212 |
'name' => 'enable_router_suggest', |
| 213 |
'operator' => '==', |
| 214 |
'value' => 'yes', |
| 215 |
] |
| 216 |
], |
| 217 |
], |
| 218 |
] |
| 219 |
); |
| 220 |
|
| 221 |
$this->add_control( |
| 222 |
'text_suggestion_route', |
| 223 |
[ |
| 224 |
'label' => __( 'Suggestion route button', 'wpdirectorykit' ), |
| 225 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 226 |
'rows' => 5, |
| 227 |
'default' => __( 'Suggest Route', 'wpdirectorykit' ), |
| 228 |
'conditions' => [ |
| 229 |
'terms' => [ |
| 230 |
[ |
| 231 |
'name' => 'enable_router_suggest', |
| 232 |
'operator' => '==', |
| 233 |
'value' => 'yes', |
| 234 |
] |
| 235 |
], |
| 236 |
], |
| 237 |
] |
| 238 |
); |
| 239 |
|
| 240 |
$fields_data = wdk_cached_field_get(); |
| 241 |
$fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit')); |
| 242 |
$order_i = 0; |
| 243 |
|
| 244 |
$fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit'); |
| 245 |
$fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit'); |
| 246 |
$fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit'); |
| 247 |
$fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit'); |
| 248 |
$fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit'); |
| 249 |
$fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit'); |
| 250 |
$fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit'); |
| 251 |
$fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit'); |
| 252 |
$fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit'); |
| 253 |
$fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit'); |
| 254 |
$fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit'); |
| 255 |
$fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit'); |
| 256 |
$fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit'); |
| 257 |
|
| 258 |
foreach($fields_data as $field) |
| 259 |
{ |
| 260 |
if(wmvc_show_data('field_type', $field) == 'SECTION') { |
| 261 |
$fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --'; |
| 262 |
} else { |
| 263 |
$fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']'; |
| 264 |
} |
| 265 |
} |
| 266 |
$this->add_control( |
| 267 |
'field_id', |
| 268 |
[ |
| 269 |
'label' => __( 'Marker position based on field with address (Detected gps by api)', 'wpdirectorykit' ), |
| 270 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 271 |
'default' => '', |
| 272 |
'options' => $fields_list, |
| 273 |
'separator' => 'after', |
| 274 |
] |
| 275 |
); |
| 276 |
|
| 277 |
$this->add_responsive_control( |
| 278 |
'conf_custom_map_height', |
| 279 |
[ |
| 280 |
'label' => esc_html__('Height', 'wpdirectorykit'), |
| 281 |
'type' => Controls_Manager::SLIDER, |
| 282 |
'range' => [ |
| 283 |
'px' => [ |
| 284 |
'min' => 100, |
| 285 |
'max' => 1500, |
| 286 |
], |
| 287 |
], |
| 288 |
'render_type' => 'template', |
| 289 |
'default' => [ |
| 290 |
'size' => 350, |
| 291 |
], |
| 292 |
'selectors' => [ |
| 293 |
'{{WRAPPER}} .wdk-element #wdk_map_results' => 'height: {{SIZE}}px !important', |
| 294 |
], |
| 295 |
'separator' => 'after', |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$this->add_control( |
| 300 |
'conf_custom_map_zoom_index', |
| 301 |
[ |
| 302 |
'label' => esc_html__('Zoom Index', 'wpdirectorykit'), |
| 303 |
'description' => esc_html__( 'Only active if auto centering is disabled', 'wpdirectorykit' ), |
| 304 |
'type' => Controls_Manager::SLIDER, |
| 305 |
'range' => [ |
| 306 |
'px' => [ |
| 307 |
'min' => 1, |
| 308 |
'max' => 18, |
| 309 |
], |
| 310 |
], |
| 311 |
'render_type' => 'template', |
| 312 |
'default' => [ |
| 313 |
'size' => 7, |
| 314 |
], |
| 315 |
] |
| 316 |
); |
| 317 |
|
| 318 |
$this->add_responsive_control( |
| 319 |
'conf_custom_dragging', |
| 320 |
[ |
| 321 |
'label' => esc_html__( 'Dragging', 'wpdirectorykit' ), |
| 322 |
'type' => Controls_Manager::SWITCHER, |
| 323 |
'none' => esc_html__( 'True', 'wpdirectorykit' ), |
| 324 |
'block' => esc_html__( 'False', 'wpdirectorykit' ), |
| 325 |
'render_type' => 'template', |
| 326 |
'return_value' => 'yes', |
| 327 |
'default' => 'yes', |
| 328 |
'separator' => 'before', |
| 329 |
] |
| 330 |
); |
| 331 |
|
| 332 |
|
| 333 |
$this->add_responsive_control( |
| 334 |
'conf_custom_popup_enable', |
| 335 |
[ |
| 336 |
'label' => esc_html__( 'Enable Infobox', 'wpdirectorykit' ), |
| 337 |
'type' => Controls_Manager::SWITCHER, |
| 338 |
'none' => esc_html__( 'True', 'wpdirectorykit' ), |
| 339 |
'block' => esc_html__( 'False', 'wpdirectorykit' ), |
| 340 |
'render_type' => 'template', |
| 341 |
'return_value' => 'yes', |
| 342 |
'default' => 'yes', |
| 343 |
'separator' => 'before', |
| 344 |
] |
| 345 |
); |
| 346 |
|
| 347 |
$this->add_responsive_control( |
| 348 |
'puopup_custom_content', |
| 349 |
[ |
| 350 |
'label' => esc_html__( 'Custom Fields For Infobox', 'wpdirectorykit' ), |
| 351 |
'type' => Controls_Manager::SWITCHER, |
| 352 |
'none' => esc_html__( 'True', 'wpdirectorykit' ), |
| 353 |
'block' => esc_html__( 'False', 'wpdirectorykit' ), |
| 354 |
'render_type' => 'template', |
| 355 |
'return_value' => 'yes', |
| 356 |
'default' => '', |
| 357 |
'conditions' => [ |
| 358 |
'terms' => [ |
| 359 |
[ |
| 360 |
'name' => 'conf_custom_popup_enable', |
| 361 |
'operator' => '==', |
| 362 |
'value' => 'yes', |
| 363 |
] |
| 364 |
], |
| 365 |
] |
| 366 |
] |
| 367 |
); |
| 368 |
|
| 369 |
$this->add_control( |
| 370 |
'conf_custom_map_styles_h', |
| 371 |
[ |
| 372 |
'label' => __( 'Map Styles', 'wpdirectorykit' ), |
| 373 |
'type' => \Elementor\Controls_Manager::HEADING, |
| 374 |
'separator' => 'before', |
| 375 |
] |
| 376 |
); |
| 377 |
|
| 378 |
$this->add_control( |
| 379 |
'conf_custom_map_style', |
| 380 |
[ |
| 381 |
'label' => esc_html__('Styles List', 'wpdirectorykit'), |
| 382 |
'type' => Controls_Manager::SELECT, |
| 383 |
'options' => [ |
| 384 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 385 |
'custom' => esc_html__('Custom', 'wpdirectorykit'), |
| 386 |
'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Light', 'wpdirectorykit'), |
| 387 |
'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png' => esc_html__('Osmde', 'wpdirectorykit'), |
| 388 |
'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png' => esc_html__('Osmde Fr', 'wpdirectorykit'), |
| 389 |
'https://tile.openstreetmap.de/{z}/{x}/{y}.png' => esc_html__('Osmde De', 'wpdirectorykit'), |
| 390 |
'https://tile.openstreetmap.org/{z}/{x}/{y}.png' => esc_html__('Mapnik', 'wpdirectorykit'), |
| 391 |
'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png' => esc_html__('OpenTopoMap', 'wpdirectorykit'), |
| 392 |
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' => esc_html__('WorldImagery', 'wpdirectorykit'), |
| 393 |
'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Carto DarkMatter', 'wpdirectorykit'), |
| 394 |
'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png' => esc_html__('Carto Voyager', 'wpdirectorykit'), |
| 395 |
'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}{r}.png' => esc_html__('Maptiler dark (demo)', 'wpdirectorykit'), |
| 396 |
'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png' => esc_html__('Thunderforest MobileAtlas', 'wpdirectorykit'), |
| 397 |
'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' => esc_html__('Thunderforest OpenCycleMap', 'wpdirectorykit'), |
| 398 |
'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png' => esc_html__('Thunderforest TransportDark', 'wpdirectorykit'), |
| 399 |
'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png' => esc_html__('Thunderforest Landscape', 'wpdirectorykit'), |
| 400 |
'https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png' => esc_html__('Thunderforest Outdoors', 'wpdirectorykit'), |
| 401 |
'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png' => esc_html__('Thunderforest Pioneer', 'wpdirectorykit'), |
| 402 |
'https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png' => esc_html__('Thunderforest Neighbourhood', 'wpdirectorykit'), |
| 403 |
'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png' => esc_html__('CyclOSM', 'wpdirectorykit'), |
| 404 |
'https://{s}.tile.jawg.io/jawg-terrain/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Streets', 'wpdirectorykit'), |
| 405 |
'https://{s}.tile.jawg.io/jawg-streets/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Sunny', 'wpdirectorykit'), |
| 406 |
'https://{s}.tile.jawg.io/jawg-dark/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Dark', 'wpdirectorykit'), |
| 407 |
'https://{s}.tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Light', 'wpdirectorykit'), |
| 408 |
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}' => esc_html__('World Top oMap', 'wpdirectorykit'), |
| 409 |
'google_map' => esc_html__('Google Map Layout', 'wpdirectorykit'), |
| 410 |
], |
| 411 |
'default' => '', |
| 412 |
] |
| 413 |
); |
| 414 |
|
| 415 |
$this->add_control( |
| 416 |
'jawg_map_key', |
| 417 |
[ |
| 418 |
'label' => __( 'Jawg Map API Key', 'wpdirectorykit' ), |
| 419 |
'description' => wdk_sprintf(__( 'Please follow link and get API key <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://www.jawg.io/en/pricing') |
| 420 |
.' '.wdk_sprintf(__( 'or check demo maps <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://www.jawg.io/en/maps'), |
| 421 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 422 |
'default' => '', |
| 423 |
'condition' => [ |
| 424 |
'conf_custom_map_style' => [ |
| 425 |
'https://{s}.tile.jawg.io/jawg-terrain/{z}/{x}/{y}{r}.png', |
| 426 |
'https://{s}.tile.jawg.io/jawg-streets/{z}/{x}/{y}{r}.png', |
| 427 |
'https://{s}.tile.jawg.io/jawg-dark/{z}/{x}/{y}{r}.png', |
| 428 |
'https://{s}.tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png', |
| 429 |
], |
| 430 |
], |
| 431 |
] |
| 432 |
); |
| 433 |
|
| 434 |
$this->add_control( |
| 435 |
'thunderforest_map_key', |
| 436 |
[ |
| 437 |
'label' => __( 'Thunderforest Map API Key', 'wpdirectorykit' ), |
| 438 |
'description' => wdk_sprintf(__( 'Please follow link and get API key <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://www.thunderforest.com/pricing/'), |
| 439 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 440 |
'default' => '', |
| 441 |
'condition' => [ |
| 442 |
'conf_custom_map_style' => [ |
| 443 |
'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png', |
| 444 |
'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png', |
| 445 |
'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png', |
| 446 |
'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png', |
| 447 |
'https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png', |
| 448 |
'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png', |
| 449 |
'https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png', |
| 450 |
], |
| 451 |
], |
| 452 |
] |
| 453 |
); |
| 454 |
|
| 455 |
$this->add_control( |
| 456 |
'google_map_key', |
| 457 |
[ |
| 458 |
'label' => __( 'Google Map API Key', 'wpdirectorykit' ), |
| 459 |
'description' => wdk_sprintf(__( 'Please follow link and get API key <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://developers.google.com/maps/documentation/javascript/get-api-key'), |
| 460 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 461 |
'default' => '', |
| 462 |
'condition' => [ |
| 463 |
'conf_custom_map_style' => ['google_map'], |
| 464 |
], |
| 465 |
] |
| 466 |
); |
| 467 |
|
| 468 |
$this->add_control( |
| 469 |
'google_map_default_type', |
| 470 |
[ |
| 471 |
'label' => __( 'Default Type', 'wpdirectorykit' ), |
| 472 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 473 |
'default' => 'roadmap', |
| 474 |
'options' => array( |
| 475 |
'roadmap' => __( 'Roadmap', 'wpdirectorykit' ), |
| 476 |
'aerial' => __( 'Aerial', 'wpdirectorykit' ), |
| 477 |
'terrain' => __( 'Terrain', 'wpdirectorykit' ), |
| 478 |
'hybrid' => __( 'Hybrid', 'wpdirectorykit' ), |
| 479 |
'satellite' => __( 'Satellite', 'wpdirectorykit' ), |
| 480 |
'traffic' => __( 'Traffic', 'wpdirectorykit' ), |
| 481 |
'transit' => __( 'Transit', 'wpdirectorykit' ), |
| 482 |
), |
| 483 |
'condition' => [ |
| 484 |
'conf_custom_map_style' => ['google_map'], |
| 485 |
], |
| 486 |
] |
| 487 |
); |
| 488 |
|
| 489 |
$this->add_control( |
| 490 |
'conf_custom_map_style_self', |
| 491 |
[ |
| 492 |
'label' => esc_html__('Link to custom Map Style', 'wpdirectorykit'), |
| 493 |
'description' => esc_html__( 'You can add some custom map by link example https://leaflet-extras.github.io/leaflet-providers/preview/ or create your custom style and put link for example on maps.cloudmade.com/editor', 'wpdirectorykit' ), |
| 494 |
'type' => Controls_Manager::TEXTAREA, |
| 495 |
'render_type' => 'template', |
| 496 |
'conditions' => [ |
| 497 |
'terms' => [ |
| 498 |
[ |
| 499 |
'name' => 'conf_custom_map_style', |
| 500 |
'operator' => '==', |
| 501 |
'value' => 'custom', |
| 502 |
] |
| 503 |
], |
| 504 |
] |
| 505 |
] |
| 506 |
); |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
$this->end_controls_section(); |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
$this->start_controls_section( |
| 515 |
'tab_conf_main_section', |
| 516 |
[ |
| 517 |
'label' => esc_html__('Custom Popup Fields', 'wpdirectorykit'), |
| 518 |
'tab' => '1', |
| 519 |
'conditions' => [ |
| 520 |
'terms' => [ |
| 521 |
[ |
| 522 |
'name' => 'puopup_custom_content', |
| 523 |
'operator' => '==', |
| 524 |
'value' => 'yes', |
| 525 |
] |
| 526 |
], |
| 527 |
] |
| 528 |
] |
| 529 |
); |
| 530 |
|
| 531 |
$fields_data = wdk_cached_field_get(); |
| 532 |
$fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit')); |
| 533 |
$order_i = 0; |
| 534 |
|
| 535 |
$fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit'); |
| 536 |
$fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit'); |
| 537 |
$fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit'); |
| 538 |
$fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit'); |
| 539 |
$fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit'); |
| 540 |
$fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit'); |
| 541 |
$fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit'); |
| 542 |
$fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit'); |
| 543 |
$fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit'); |
| 544 |
$fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit'); |
| 545 |
$fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit'); |
| 546 |
$fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit'); |
| 547 |
$fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit'); |
| 548 |
|
| 549 |
foreach($fields_data as $field) |
| 550 |
{ |
| 551 |
if(wmvc_show_data('field_type', $field) == 'SECTION') { |
| 552 |
$fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --'; |
| 553 |
} else { |
| 554 |
$fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']'; |
| 555 |
} |
| 556 |
} |
| 557 |
$this->add_control( |
| 558 |
'title_field_id', |
| 559 |
[ |
| 560 |
'label' => __( 'Title Field', 'wpdirectorykit' ), |
| 561 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 562 |
'default' => '', |
| 563 |
'options' => $fields_list, |
| 564 |
] |
| 565 |
); |
| 566 |
|
| 567 |
$this->add_control( |
| 568 |
'content_field_id', |
| 569 |
[ |
| 570 |
'label' => __( 'Content Field', 'wpdirectorykit' ), |
| 571 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 572 |
'default' => '', |
| 573 |
'options' => $fields_list, |
| 574 |
] |
| 575 |
); |
| 576 |
|
| 577 |
$this->end_controls_section(); |
| 578 |
|
| 579 |
} |
| 580 |
|
| 581 |
private function generate_controls_layout() { |
| 582 |
|
| 583 |
/* default marker layout */ |
| 584 |
$this->generate_controls_layout_default(); |
| 585 |
} |
| 586 |
|
| 587 |
private function generate_controls_styles() { |
| 588 |
/* marker */ |
| 589 |
$this->start_controls_section( |
| 590 |
'styles_marker_sec', |
| 591 |
[ |
| 592 |
'label' => esc_html__('Marker', 'wpdirectorykit'), |
| 593 |
'tab' => Controls_Manager::TAB_STYLE, |
| 594 |
] |
| 595 |
); |
| 596 |
|
| 597 |
|
| 598 |
$this->add_control( |
| 599 |
'styles_marker_h', |
| 600 |
[ |
| 601 |
'label' => esc_html__('Marker', 'wpdirectorykit'), |
| 602 |
'type' => Controls_Manager::HEADING, |
| 603 |
'separator' => 'before', |
| 604 |
] |
| 605 |
); |
| 606 |
|
| 607 |
$this->start_controls_tabs('marker_button_style'); |
| 608 |
|
| 609 |
$this->start_controls_tab( |
| 610 |
'marker', |
| 611 |
[ |
| 612 |
'label' => esc_html__('Normal', 'wpdirectorykit'), |
| 613 |
] |
| 614 |
); |
| 615 |
|
| 616 |
$this->add_control( |
| 617 |
'styles_marker_color', |
| 618 |
[ |
| 619 |
'label' => esc_html__('Marker Border Color', 'wpdirectorykit'), |
| 620 |
'type' => Controls_Manager::COLOR, |
| 621 |
'selectors' => [ |
| 622 |
'{{WRAPPER}} .wdk-element .wdk-map .wdk_marker-card::before' => 'background-color: {{VALUE}};', |
| 623 |
], |
| 624 |
] |
| 625 |
); |
| 626 |
|
| 627 |
$this->add_control( |
| 628 |
'styles_marker_color_bckg', |
| 629 |
[ |
| 630 |
'label' => esc_html__('Marker Color', 'wpdirectorykit'), |
| 631 |
'type' => Controls_Manager::COLOR, |
| 632 |
'selectors' => [ |
| 633 |
'{{WRAPPER}} .wdk-element .wdk_marker-card:after' => 'background-color: {{VALUE}};', |
| 634 |
], |
| 635 |
] |
| 636 |
); |
| 637 |
|
| 638 |
$this->add_control( |
| 639 |
'styles_marker_color_text', |
| 640 |
[ |
| 641 |
'label' => esc_html__('Marker Text Color', 'wpdirectorykit'), |
| 642 |
'type' => Controls_Manager::COLOR, |
| 643 |
'selectors' => [ |
| 644 |
'{{WRAPPER}} .wdk_face i' => 'color: {{VALUE}};', |
| 645 |
], |
| 646 |
] |
| 647 |
); |
| 648 |
|
| 649 |
$this->add_control( |
| 650 |
'conf_custom_map_pin_icon', |
| 651 |
[ |
| 652 |
'label' => esc_html__('Icon', 'wpdirectorykit'), |
| 653 |
'type' => Controls_Manager::ICONS, |
| 654 |
'label_block' => true, |
| 655 |
'default' => [ |
| 656 |
'value' => 'fa fa-home', |
| 657 |
'library' => 'solid', |
| 658 |
], |
| 659 |
] |
| 660 |
); |
| 661 |
|
| 662 |
$this->add_control( |
| 663 |
'conf_custom_map_pin', |
| 664 |
[ |
| 665 |
'label' => esc_html__('Custom Marker Pin Image', 'wpdirectorykit'), |
| 666 |
'type' => Controls_Manager::MEDIA, |
| 667 |
] |
| 668 |
); |
| 669 |
|
| 670 |
$this->end_controls_tab(); |
| 671 |
|
| 672 |
$this->start_controls_tab( |
| 673 |
'marker_hover', |
| 674 |
[ |
| 675 |
'label' => esc_html__('Hover', 'wpdirectorykit'), |
| 676 |
] |
| 677 |
); |
| 678 |
|
| 679 |
$this->add_control( |
| 680 |
'styles_marker_color_hover', |
| 681 |
[ |
| 682 |
'label' => esc_html__('Marker Border Color', 'wpdirectorykit'), |
| 683 |
'type' => Controls_Manager::COLOR, |
| 684 |
'selectors' => [ |
| 685 |
'{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:before' => 'background-color: {{VALUE}};', |
| 686 |
], |
| 687 |
] |
| 688 |
); |
| 689 |
|
| 690 |
$this->add_control( |
| 691 |
'styles_marker_color_hover_bckg', |
| 692 |
[ |
| 693 |
'label' => esc_html__('Marker Color', 'wpdirectorykit'), |
| 694 |
'type' => Controls_Manager::COLOR, |
| 695 |
'selectors' => [ |
| 696 |
'{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:after' => 'background-color: {{VALUE}};', |
| 697 |
], |
| 698 |
] |
| 699 |
); |
| 700 |
|
| 701 |
$this->add_control( |
| 702 |
'styles_marker_color_text_hover', |
| 703 |
[ |
| 704 |
'label' => esc_html__('Marker Text Color', 'wpdirectorykit'), |
| 705 |
'type' => Controls_Manager::COLOR, |
| 706 |
'selectors' => [ |
| 707 |
'{{WRAPPER}} .wdk_marker-container:hover .wdk_face.back i, .wdk_marker-container:hover .wdk_face i' => 'color: {{VALUE}};', |
| 708 |
], |
| 709 |
] |
| 710 |
); |
| 711 |
|
| 712 |
$this->add_control( |
| 713 |
'styles_marker_effect_duration', |
| 714 |
[ |
| 715 |
'label' => esc_html__('Transition Duration', 'wpdirectorykit'), |
| 716 |
'type' => Controls_Manager::SLIDER, |
| 717 |
'render_type' => 'template', |
| 718 |
'range' => [ |
| 719 |
'px' => [ |
| 720 |
'min' => 0, |
| 721 |
'max' => 3000, |
| 722 |
], |
| 723 |
], |
| 724 |
'selectors' => [ |
| 725 |
'{{WRAPPER}} .wdk_map-marker-container.clicked .wdk_face.front, .wdk_marker-container:hover .wdk_face.front' => 'transition-duration: {{SIZE}}ms', |
| 726 |
], |
| 727 |
] |
| 728 |
); |
| 729 |
|
| 730 |
$this->end_controls_tab(); |
| 731 |
|
| 732 |
$this->end_controls_tabs(); |
| 733 |
$this->end_controls_section(); |
| 734 |
|
| 735 |
$this->start_controls_section( |
| 736 |
'section_form_suggestion', |
| 737 |
[ |
| 738 |
'label' => __( 'Form Suggestion Route', 'wpdirectorykit' ), |
| 739 |
'tab' => Controls_Manager::TAB_STYLE, |
| 740 |
'conditions' => [ |
| 741 |
'terms' => [ |
| 742 |
[ |
| 743 |
'name' => 'enable_router_suggest', |
| 744 |
'operator' => '==', |
| 745 |
'value' => 'yes', |
| 746 |
] |
| 747 |
], |
| 748 |
], |
| 749 |
] |
| 750 |
); |
| 751 |
|
| 752 |
|
| 753 |
$this->add_responsive_control ( |
| 754 |
'form_suggestion_style_align', |
| 755 |
[ |
| 756 |
'label' => __( 'Position', 'wpdirectorykit' ), |
| 757 |
'type' => Controls_Manager::CHOOSE, |
| 758 |
'options' => [ |
| 759 |
'left' => [ |
| 760 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 761 |
'icon' => 'eicon-text-align-left', |
| 762 |
], |
| 763 |
'center' => [ |
| 764 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 765 |
'icon' => 'eicon-text-align-center', |
| 766 |
], |
| 767 |
'right' => [ |
| 768 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 769 |
'icon' => 'eicon-text-align-right', |
| 770 |
], |
| 771 |
'justify' => [ |
| 772 |
'title' => esc_html__( 'Default', 'wpdirectorykit' ), |
| 773 |
'icon' => 'eicon-text-align-justify', |
| 774 |
] , |
| 775 |
], |
| 776 |
'render_type' => 'ui', |
| 777 |
'selectors_dictionary' => [ |
| 778 |
'left' => 'flex-start', |
| 779 |
'center' => 'center', |
| 780 |
'right' => 'flex-end', |
| 781 |
'justify' => 'space-between', |
| 782 |
], |
| 783 |
'selectors' => [ |
| 784 |
'{{WRAPPER}} .route_suggestion' => 'justify-content:{{VALUE}};', |
| 785 |
], |
| 786 |
] |
| 787 |
); |
| 788 |
|
| 789 |
$this->add_responsive_control( |
| 790 |
'form_suggestion_column_direct', |
| 791 |
[ |
| 792 |
'label' => __( 'Direction', 'wpdirectorykit' ), |
| 793 |
'type' => Controls_Manager::SELECT, |
| 794 |
'options' => [ |
| 795 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 796 |
'row' => esc_html__('Row', 'wpdirectorykit'), |
| 797 |
'row-reverse' => esc_html__('Row reverse', 'wpdirectorykit'), |
| 798 |
'column' => esc_html__('Column', 'wpdirectorykit'), |
| 799 |
'column-reverse' => esc_html__('Column reverse', 'wpdirectorykit'), |
| 800 |
], |
| 801 |
'selectors' => [ |
| 802 |
'{{WRAPPER}} .route_suggestion' => 'flex-direction: {{UNIT}}', |
| 803 |
], |
| 804 |
'separator' => 'before', |
| 805 |
] |
| 806 |
); |
| 807 |
|
| 808 |
$this->add_responsive_control( |
| 809 |
'form_suggestion_column_gap', |
| 810 |
[ |
| 811 |
'label' => esc_html__('Columns Gap', 'wpdirectorykit'), |
| 812 |
'type' => Controls_Manager::SLIDER, |
| 813 |
'default' => [ |
| 814 |
'size' => 10, |
| 815 |
], |
| 816 |
'range' => [ |
| 817 |
'px' => [ |
| 818 |
'min' => 0, |
| 819 |
'max' => 60, |
| 820 |
], |
| 821 |
], |
| 822 |
'selectors' => [ |
| 823 |
'{{WRAPPER}} .route_suggestion > *' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;', |
| 824 |
'{{WRAPPER}} .route_suggestion' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};', |
| 825 |
], |
| 826 |
] |
| 827 |
); |
| 828 |
|
| 829 |
$this->add_responsive_control( |
| 830 |
'form_suggestion_row_gap', |
| 831 |
[ |
| 832 |
'label' => esc_html__('Rows Gap', 'wpdirectorykit'), |
| 833 |
'type' => Controls_Manager::SLIDER, |
| 834 |
'default' => [ |
| 835 |
'size' => 10, |
| 836 |
], |
| 837 |
'range' => [ |
| 838 |
'px' => [ |
| 839 |
'min' => 0, |
| 840 |
'max' => 60, |
| 841 |
], |
| 842 |
], |
| 843 |
'selectors' => [ |
| 844 |
'{{WRAPPER}} .route_suggestion > *' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 845 |
'{{WRAPPER}} .route_suggestion ' => 'margin-bottom: -{{SIZE}}{{UNIT}};', |
| 846 |
], |
| 847 |
] |
| 848 |
); |
| 849 |
|
| 850 |
|
| 851 |
$this->add_responsive_control( |
| 852 |
'form_suggestion_space_top', |
| 853 |
[ |
| 854 |
'label' => esc_html__('Space Top', 'wpdirectorykit'), |
| 855 |
'type' => Controls_Manager::SLIDER, |
| 856 |
'default' => [ |
| 857 |
'size' => 25, |
| 858 |
], |
| 859 |
'range' => [ |
| 860 |
'px' => [ |
| 861 |
'min' => 0, |
| 862 |
'max' => 500, |
| 863 |
], |
| 864 |
], |
| 865 |
'selectors' => [ |
| 866 |
'{{WRAPPER}} .route_suggestion' => 'margin-top: {{SIZE}}{{UNIT}};', |
| 867 |
], |
| 868 |
] |
| 869 |
); |
| 870 |
|
| 871 |
$this->add_control( |
| 872 |
'form_suggestion_header_1', |
| 873 |
[ |
| 874 |
'label' => __( 'Input', 'wpdirectorykit' ), |
| 875 |
'type' => Controls_Manager::HEADING, |
| 876 |
] |
| 877 |
); |
| 878 |
|
| 879 |
$selectors = array( |
| 880 |
'normal' => '{{WRAPPER}} .route_suggestion .input_text', |
| 881 |
); |
| 882 |
|
| 883 |
$this->generate_renders_tabs($selectors, 'form_suggestion_input_dynamic', ['typo','color','background','border','border_radius','padding','shadow','transition', 'height', 'width']); |
| 884 |
|
| 885 |
|
| 886 |
$this->add_control( |
| 887 |
'form_suggestion_header_2', |
| 888 |
[ |
| 889 |
'label' => __( 'Placeholder', 'wpdirectorykit' ), |
| 890 |
'type' => Controls_Manager::HEADING, |
| 891 |
] |
| 892 |
); |
| 893 |
|
| 894 |
$selectors = array( |
| 895 |
'normal' => '{{WRAPPER}} .route_suggestion .input_text::placeholder', |
| 896 |
); |
| 897 |
|
| 898 |
$this->generate_renders_tabs($selectors, 'form_suggestion_input_pl_dynamic', ['align','typo','color']); |
| 899 |
|
| 900 |
$this->add_control( |
| 901 |
'form_suggestion_header_3', |
| 902 |
[ |
| 903 |
'label' => __( 'Submit Button', 'wpdirectorykit' ), |
| 904 |
'type' => Controls_Manager::HEADING, |
| 905 |
] |
| 906 |
); |
| 907 |
|
| 908 |
$selectors = array( |
| 909 |
'normal' => '{{WRAPPER}} .route_suggestion .wdk-btn', |
| 910 |
'hover' => '{{WRAPPER}} .route_suggestion .wdk-btn%1$s', |
| 911 |
); |
| 912 |
|
| 913 |
$this->generate_renders_tabs($selectors, 'form_suggestion_btn_dynamic', ['typo', 'color', 'border', 'border_radius', 'shadow', 'transition', 'background_group','padding']); |
| 914 |
|
| 915 |
$this->end_controls_section(); |
| 916 |
} |
| 917 |
|
| 918 |
private function generate_controls_content() { |
| 919 |
} |
| 920 |
|
| 921 |
private function generate_controls_layout_default() { |
| 922 |
|
| 923 |
} |
| 924 |
|
| 925 |
private function generate_controls_styles_default() { |
| 926 |
|
| 927 |
} |
| 928 |
|
| 929 |
public function enqueue_styles_scripts() { |
| 930 |
wp_enqueue_style('leaflet'); |
| 931 |
wp_enqueue_style('leaflet-cluster-def'); |
| 932 |
wp_enqueue_style('leaflet-cluster'); |
| 933 |
wp_enqueue_script('leaflet'); |
| 934 |
wp_enqueue_script('leaflet-cluster'); |
| 935 |
wp_enqueue_script('leaflet-fullscreen'); |
| 936 |
wp_enqueue_style('leaflet-fullscreen'); |
| 937 |
|
| 938 |
wp_enqueue_style('wdk-notify'); |
| 939 |
wp_enqueue_script('wdk-notify'); |
| 940 |
wp_enqueue_style( 'wdk-listings-map' ); |
| 941 |
|
| 942 |
wp_enqueue_style('slick'); |
| 943 |
wp_enqueue_style('slick-theme'); |
| 944 |
wp_enqueue_style('wdk-hover'); |
| 945 |
wp_enqueue_script('slick'); |
| 946 |
wp_enqueue_script('leaflet-googlemutant'); |
| 947 |
} |
| 948 |
} |
| 949 |
|