| 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 WdkListingsList 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__('Layout', 'wpdirectorykit') |
| 37 |
); |
| 38 |
|
| 39 |
\Elementor\Controls_Manager::add_tab( |
| 40 |
'tab_content', |
| 41 |
esc_html__('Main', 'wpdirectorykit') |
| 42 |
); |
| 43 |
|
| 44 |
|
| 45 |
if ($this->is_edit_mode_load()) { |
| 46 |
$this->enqueue_styles_scripts(); |
| 47 |
} |
| 48 |
parent::__construct($data, $args); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Retrieve the widget name. |
| 53 |
* |
| 54 |
* @since 1.1.0 |
| 55 |
* |
| 56 |
* @access public |
| 57 |
* |
| 58 |
* @return string Widget name. |
| 59 |
*/ |
| 60 |
public function get_name() { |
| 61 |
return 'wdk-listings-list'; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Retrieve the widget title. |
| 66 |
* |
| 67 |
* @since 1.1.0 |
| 68 |
* |
| 69 |
* @access public |
| 70 |
* |
| 71 |
* @return string Widget title. |
| 72 |
*/ |
| 73 |
public function get_title() { |
| 74 |
return esc_html__('Wdk Listings List', 'wpdirectorykit'); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Retrieve the widget icon. |
| 79 |
* |
| 80 |
* @since 1.1.0 |
| 81 |
* |
| 82 |
* @access public |
| 83 |
* |
| 84 |
* @return string Widget icon. |
| 85 |
*/ |
| 86 |
public function get_icon() { |
| 87 |
return 'eicon-section'; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Register the widget controls. |
| 92 |
* |
| 93 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 94 |
* |
| 95 |
* @since 1.1.0 |
| 96 |
* |
| 97 |
* @access protected |
| 98 |
*/ |
| 99 |
protected function register_controls() { |
| 100 |
$this->generate_controls_conf(); |
| 101 |
$this->generate_controls_layout(); |
| 102 |
$this->generate_controls_styles(); |
| 103 |
$this->generate_controls_content(); |
| 104 |
|
| 105 |
$this->insert_pro_message('tab_conf'); |
| 106 |
parent::register_controls(); |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Render the widget output on the frontend. |
| 111 |
* |
| 112 |
* Written in PHP and used to generate the final HTML. |
| 113 |
* |
| 114 |
* @since 1.1.0 |
| 115 |
* |
| 116 |
* @access protected |
| 117 |
*/ |
| 118 |
protected function render() { |
| 119 |
parent::render(); |
| 120 |
$this->data['id_element'] = $this->get_id(); |
| 121 |
$this->data['settings'] = $this->get_settings(); |
| 122 |
|
| 123 |
$this->data['listings_count'] = 0; |
| 124 |
$this->data['results'] = array(); |
| 125 |
$this->data['pagination_output'] = ''; |
| 126 |
|
| 127 |
$columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by','is_featured', 'address'); |
| 128 |
$external_columns = array('location_id', 'category_id', 'post_title'); |
| 129 |
$custom_parameters = array(); |
| 130 |
|
| 131 |
$this->data['custom_order'] = array(); |
| 132 |
if($this->data['settings']['custom_order_list']) { |
| 133 |
foreach($this->data['settings']['custom_order_list'] as $item){ |
| 134 |
if(empty($item['title']) || empty($item['key'])) continue; |
| 135 |
$this->data['custom_order'][] = array('title'=>$item['title'],'key'=>$item['key']); |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
if($this->data['settings']['conf_results_type'] == 'results_listings') { |
| 140 |
$controller = 'listing'; |
| 141 |
$offset = NULL; |
| 142 |
|
| 143 |
$custom_parameters['order_by'] = $this->data['settings']['conf_order_by'].' '.$this->data['settings']['conf_order']; |
| 144 |
|
| 145 |
/* if detected custom field for order */ |
| 146 |
if(!empty($this->data['settings']['conf_order_by_custom'])) { |
| 147 |
$custom_parameters['order_by'] = $this->data['settings']['conf_order_by_custom'].' '.$this->data['settings']['conf_order']; |
| 148 |
} |
| 149 |
|
| 150 |
if(!empty($this->data['settings']['conf_query'])) { |
| 151 |
$qr_string = trim($this->data['settings']['conf_query'],'?'); |
| 152 |
$string_par = array(); |
| 153 |
parse_str($qr_string, $string_par); |
| 154 |
$custom_parameters += array_map('trim', $string_par); |
| 155 |
} |
| 156 |
if($this->data['settings']['only_is_featured'] == 'yes') { |
| 157 |
$custom_parameters['is_featured'] = 'on'; |
| 158 |
} |
| 159 |
|
| 160 |
wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters, TRUE); |
| 161 |
$this->data['results'] = $this->WMVC->listing_m->get_pagination($this->data['settings']['per_page'], $offset, array('is_activated' => 1,'is_approved'=>1)); |
| 162 |
} else if($this->data['settings']['conf_results_type'] == 'custom_listings') { |
| 163 |
$listings_ids = array(); |
| 164 |
foreach($this->data['settings']['conf_custom_results'] as $listing) { |
| 165 |
if(isset($listing['listing_post_id']) && !empty($listing['listing_post_id'])) { |
| 166 |
$listings_ids [] = $listing['listing_post_id']; |
| 167 |
} |
| 168 |
} |
| 169 |
/* where in */ |
| 170 |
if(!empty($listings_ids)){ |
| 171 |
$this->WMVC->db->where( $this->WMVC->db->prefix.'wdk_listings.post_id IN(' . implode(',', $listings_ids) . ')', null, false); |
| 172 |
$this->WMVC->db->where(array('is_activated' => 1)); |
| 173 |
$this->WMVC->db->order_by('FIELD('.$this->WMVC->db->prefix.'wdk_listings.post_id, '. implode(',', $listings_ids) . ')'); |
| 174 |
|
| 175 |
$this->data['results'] = $this->WMVC->listing_m->get(); |
| 176 |
} |
| 177 |
|
| 178 |
/* hide filter header on specific results */ |
| 179 |
$this->data['settings']['get_filters_enable'] = ''; |
| 180 |
} |
| 181 |
|
| 182 |
$this->data['is_edit_mode'] = false; |
| 183 |
if(Plugin::$instance->editor->is_edit_mode()) |
| 184 |
$this->data['is_edit_mode'] = true; |
| 185 |
|
| 186 |
echo $this->view('wdk-listings-list', $this->data); |
| 187 |
|
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
private function generate_controls_conf() { |
| 192 |
$this->start_controls_section( |
| 193 |
'tab_conf_main_section', |
| 194 |
[ |
| 195 |
'label' => esc_html__('Main', 'wpdirectorykit'), |
| 196 |
'tab' => 'tab_conf', |
| 197 |
] |
| 198 |
); |
| 199 |
|
| 200 |
$this->add_control( |
| 201 |
'conf_results_type', |
| 202 |
[ |
| 203 |
'label' => __( 'Results type', 'wpdirectorykit' ), |
| 204 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 205 |
'default' => 'results_listings', |
| 206 |
'options' => [ |
| 207 |
'results_listings' => __( 'Results Listings', 'wpdirectorykit' ), |
| 208 |
'custom_listings' => __( 'Specific Listings', 'wpdirectorykit' ), |
| 209 |
], |
| 210 |
'separator' => 'after', |
| 211 |
] |
| 212 |
); |
| 213 |
|
| 214 |
/* conf_results_type :: results_listings */ |
| 215 |
if(true){ |
| 216 |
$this->add_control( |
| 217 |
'conf_results_type_results_listings_header', |
| 218 |
[ |
| 219 |
'label' => esc_html__('Results listings', 'wpdirectorykit'), |
| 220 |
'type' => Controls_Manager::HEADING, |
| 221 |
'separator' => 'before', |
| 222 |
'conditions' => [ |
| 223 |
'terms' => [ |
| 224 |
[ |
| 225 |
'name' => 'conf_results_type', |
| 226 |
'operator' => '==', |
| 227 |
'value' => 'results_listings', |
| 228 |
] |
| 229 |
], |
| 230 |
], |
| 231 |
] |
| 232 |
); |
| 233 |
|
| 234 |
$this->add_control( |
| 235 |
'per_page', |
| 236 |
[ |
| 237 |
'label' => __( 'Limit Results (Per page)', 'wpdirectorykit' ), |
| 238 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 239 |
'min' => 1, |
| 240 |
'max' => 250, |
| 241 |
'step' => 1, |
| 242 |
'default' => 3, |
| 243 |
'conditions' => [ |
| 244 |
'terms' => [ |
| 245 |
[ |
| 246 |
'name' => 'conf_results_type', |
| 247 |
'operator' => '==', |
| 248 |
'value' => 'results_listings', |
| 249 |
] |
| 250 |
], |
| 251 |
], |
| 252 |
] |
| 253 |
); |
| 254 |
|
| 255 |
$this->add_control( |
| 256 |
'only_is_featured', |
| 257 |
[ |
| 258 |
'label' => __( 'Only show featured', 'wpdirectorykit' ), |
| 259 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 260 |
'label_on' => __( 'True', 'wpdirectorykit' ), |
| 261 |
'label_off' => __( 'False', 'wpdirectorykit' ), |
| 262 |
'return_value' => 'yes', |
| 263 |
'default' => '', |
| 264 |
'conditions' => [ |
| 265 |
'terms' => [ |
| 266 |
[ |
| 267 |
'name' => 'conf_results_type', |
| 268 |
'operator' => '==', |
| 269 |
'value' => 'results_listings', |
| 270 |
] |
| 271 |
], |
| 272 |
], |
| 273 |
] |
| 274 |
); |
| 275 |
|
| 276 |
$this->add_control( |
| 277 |
'conf_query', |
| 278 |
[ |
| 279 |
'label' => __( 'Query', 'wpdirectorykit' ), |
| 280 |
'type' => \Elementor\Controls_Manager::TEXTAREA, |
| 281 |
'rows' => 5, |
| 282 |
'default' => '', |
| 283 |
'placeholder' => __( 'Type your query here, example xxx', 'wpdirectorykit' ), |
| 284 |
'description' => '<span style="word-break: break-all;">'.__( 'Example (same like on url):', 'wpdirectorykit' ). |
| 285 |
' field_6_min=100&field_6_max=200&field_5=rent&is_featured=on&search_category=3&search_location=4&search_agents_ids=3'. |
| 286 |
'</span>', |
| 287 |
'conditions' => [ |
| 288 |
'terms' => [ |
| 289 |
[ |
| 290 |
'name' => 'conf_results_type', |
| 291 |
'operator' => '==', |
| 292 |
'value' => 'results_listings', |
| 293 |
] |
| 294 |
], |
| 295 |
], |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$this->add_control( |
| 300 |
'conf_order_by', |
| 301 |
[ |
| 302 |
'label' => __('Default Sort By Column', 'wpdirectorykit'), |
| 303 |
'type' => Controls_Manager::SELECT, |
| 304 |
'label_block' => true, |
| 305 |
'options' => [ |
| 306 |
'none' => __('None', 'wpdirectorykit'), |
| 307 |
'post_id' => __('ID', 'wpdirectorykit'), |
| 308 |
'post_title' => __('Title', 'wpdirectorykit'), |
| 309 |
], |
| 310 |
'default' => 'post_id', |
| 311 |
'conditions' => [ |
| 312 |
'terms' => [ |
| 313 |
[ |
| 314 |
'name' => 'conf_results_type', |
| 315 |
'operator' => '==', |
| 316 |
'value' => 'results_listings', |
| 317 |
] |
| 318 |
], |
| 319 |
], |
| 320 |
] |
| 321 |
); |
| 322 |
|
| 323 |
$this->add_control( |
| 324 |
'conf_order_by_custom', |
| 325 |
[ |
| 326 |
'label' => __('Default Custom Sort By (Column)', 'wpdirectorykit'), |
| 327 |
'description' => '<span style="word-break: break-all;">'.__( 'Example:', 'wpdirectorykit' ). |
| 328 |
'<br> field_13_NUMBER - where 13 is field id, NUMBER - field type'. |
| 329 |
'<br> field_4_NUMBER - where 4 is field id, NUMBER - field type'. |
| 330 |
'<br> field_6_DROPDOWN - where 6 is field id, DROPDOWN - field type'. |
| 331 |
'<br> category_title - Category Title'. |
| 332 |
'<br> location_title - Location Title'. |
| 333 |
'</span>', |
| 334 |
'type' => Controls_Manager::TEXT, |
| 335 |
'label_block' => true, |
| 336 |
'default' => 'post_id', |
| 337 |
'conditions' => [ |
| 338 |
'terms' => [ |
| 339 |
[ |
| 340 |
'name' => 'conf_results_type', |
| 341 |
'operator' => '==', |
| 342 |
'value' => 'results_listings', |
| 343 |
] |
| 344 |
], |
| 345 |
], |
| 346 |
] |
| 347 |
); |
| 348 |
|
| 349 |
$this->add_control( |
| 350 |
'conf_order', |
| 351 |
[ |
| 352 |
'label' => __('Default Listing Order', 'wpdirectorykit'), |
| 353 |
'type' => Controls_Manager::SELECT, |
| 354 |
'label_block' => true, |
| 355 |
'options' => [ |
| 356 |
'asc' => __('Ascending', 'wpdirectorykit'), |
| 357 |
'desc' => __('Descending', 'wpdirectorykit') |
| 358 |
], |
| 359 |
'default' => 'desc', |
| 360 |
'conditions' => [ |
| 361 |
'terms' => [ |
| 362 |
[ |
| 363 |
'name' => 'conf_results_type', |
| 364 |
'operator' => '==', |
| 365 |
'value' => 'results_listings', |
| 366 |
] |
| 367 |
], |
| 368 |
], |
| 369 |
] |
| 370 |
); |
| 371 |
|
| 372 |
|
| 373 |
} |
| 374 |
|
| 375 |
if(true) { |
| 376 |
$this->add_control( |
| 377 |
'conf_results_type_custom_listings_header', |
| 378 |
[ |
| 379 |
'label' => esc_html__('Custom listings', 'wpdirectorykit'), |
| 380 |
'type' => Controls_Manager::HEADING, |
| 381 |
'separator' => 'before', |
| 382 |
'conditions' => [ |
| 383 |
'terms' => [ |
| 384 |
[ |
| 385 |
'name' => 'conf_results_type', |
| 386 |
'operator' => '==', |
| 387 |
'value' => 'custom_listings', |
| 388 |
] |
| 389 |
], |
| 390 |
], |
| 391 |
] |
| 392 |
); |
| 393 |
|
| 394 |
|
| 395 |
if(true){ |
| 396 |
$repeater = new Repeater(); |
| 397 |
$repeater->start_controls_tabs( 'listings' ); |
| 398 |
$repeater->add_control( |
| 399 |
'listing_post_id', |
| 400 |
[ |
| 401 |
'label' => __( 'ID Post Listing', 'wpdirectorykit' ), |
| 402 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 403 |
'min' => 1, |
| 404 |
'step' => 1, |
| 405 |
] |
| 406 |
); |
| 407 |
$repeater->end_controls_tabs(); |
| 408 |
|
| 409 |
|
| 410 |
$this->add_control( |
| 411 |
'conf_custom_results', |
| 412 |
[ |
| 413 |
'type' => Controls_Manager::REPEATER, |
| 414 |
'fields' => $repeater->get_controls(), |
| 415 |
'default' => [ |
| 416 |
], |
| 417 |
'title_field' => '{{{ listing_post_id }}}', |
| 418 |
'conditions' => [ |
| 419 |
'terms' => [ |
| 420 |
[ |
| 421 |
'name' => 'conf_results_type', |
| 422 |
'operator' => '==', |
| 423 |
'value' => 'custom_listings', |
| 424 |
] |
| 425 |
], |
| 426 |
], |
| 427 |
] |
| 428 |
); |
| 429 |
|
| 430 |
} |
| 431 |
} |
| 432 |
|
| 433 |
$this->add_control( |
| 434 |
'important_note', |
| 435 |
[ |
| 436 |
'label' => '', |
| 437 |
'type' => \Elementor\Controls_Manager::RAW_HTML, |
| 438 |
'raw' => wdk_sprintf(__( 'Edit Result Card Designer <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_resultitem')), |
| 439 |
'content_classes' => 'wdk_elementor_hint', |
| 440 |
] |
| 441 |
); |
| 442 |
|
| 443 |
|
| 444 |
$this->end_controls_section(); |
| 445 |
|
| 446 |
$this->start_controls_section( |
| 447 |
'tab_conf_main_section_order', |
| 448 |
[ |
| 449 |
'label' => esc_html__('Custom Sort', 'wpdirectorykit'), |
| 450 |
'tab' => 'tab_conf', |
| 451 |
] |
| 452 |
); |
| 453 |
|
| 454 |
$repeater_order = new Repeater(); |
| 455 |
$repeater_order->start_controls_tabs( 'orders' ); |
| 456 |
$repeater_order->add_control( |
| 457 |
'key', |
| 458 |
[ |
| 459 |
'label' => __( 'Sort Key', 'wpdirectorykit' ), |
| 460 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 461 |
'placeholder' => 'post_id ASC', |
| 462 |
'description' => '<span style="word-break: break-all;">'.__( 'Custom Fields Order Example:', 'wpdirectorykit' ). |
| 463 |
'<br> field_13_NUMBER ASC - where 13 is field id, NUMBER - field type'. |
| 464 |
'<br> field_4_NUMBER DESC - where 4 is field id, NUMBER - field type'. |
| 465 |
'<br> field_6_DROPDOWN ASC - where 6 is field id, DROPDOWN - field type'. |
| 466 |
'<br> category_title - Category Title'. |
| 467 |
'<br> location_title - Location Title'. |
| 468 |
'</span>', |
| 469 |
] |
| 470 |
); |
| 471 |
$repeater_order->add_control( |
| 472 |
'title', |
| 473 |
[ |
| 474 |
'label' => __( 'Title', 'wpdirectorykit' ), |
| 475 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 476 |
'placeholder' => __( 'Title', 'wpdirectorykit' ), |
| 477 |
] |
| 478 |
); |
| 479 |
$repeater_order->end_controls_tabs(); |
| 480 |
|
| 481 |
$this->add_control( |
| 482 |
'custom_order_list', |
| 483 |
[ |
| 484 |
'type' => Controls_Manager::REPEATER, |
| 485 |
'fields' => $repeater_order->get_controls(), |
| 486 |
'default' => [ |
| 487 |
], |
| 488 |
'title_field' => '{{{ title }}}', |
| 489 |
] |
| 490 |
); |
| 491 |
|
| 492 |
$this->end_controls_section(); |
| 493 |
|
| 494 |
} |
| 495 |
|
| 496 |
private function generate_controls_layout() { |
| 497 |
$this->start_controls_section( |
| 498 |
'tab_content', |
| 499 |
[ |
| 500 |
'label' => esc_html__('Basic', 'wpdirectorykit'), |
| 501 |
'tab' => 'tab_layout', |
| 502 |
] |
| 503 |
); |
| 504 |
$this->add_responsive_control( |
| 505 |
'row_gap', |
| 506 |
[ |
| 507 |
'label' => esc_html__('Rows Gap', 'wpdirectorykit'), |
| 508 |
'type' => Controls_Manager::SLIDER, |
| 509 |
'default' => [ |
| 510 |
'size' => 27, |
| 511 |
], |
| 512 |
'range' => [ |
| 513 |
'px' => [ |
| 514 |
'min' => 0, |
| 515 |
'max' => 60, |
| 516 |
], |
| 517 |
], |
| 518 |
'selectors' => [ |
| 519 |
'{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 520 |
'{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};', |
| 521 |
], |
| 522 |
] |
| 523 |
); |
| 524 |
|
| 525 |
$this->add_responsive_control( |
| 526 |
'thumbnail_width', |
| 527 |
[ |
| 528 |
'label' => esc_html__('Thumbnail width', 'wpdirectorykit'), |
| 529 |
'type' => Controls_Manager::SLIDER, |
| 530 |
'size_units' => [ 'px', '%' ], |
| 531 |
'range' => [ |
| 532 |
'px' => [ |
| 533 |
'min' => 0, |
| 534 |
'max' => 600, |
| 535 |
], |
| 536 |
'%' => [ |
| 537 |
'min' => 0, |
| 538 |
'max' => 100, |
| 539 |
], |
| 540 |
], |
| 541 |
'selectors' => [ |
| 542 |
'{{WRAPPER}} .wdk-listings-list .listing-item .listing-img-sec' => 'flex: 0 0 {{SIZE}}{{UNIT}};', |
| 543 |
], |
| 544 |
] |
| 545 |
); |
| 546 |
|
| 547 |
|
| 548 |
$this->end_controls_section(); |
| 549 |
|
| 550 |
} |
| 551 |
|
| 552 |
private function generate_controls_styles() { |
| 553 |
$this->start_controls_section( |
| 554 |
'sstyles_thmbn_section', |
| 555 |
[ |
| 556 |
'label' => esc_html__('Section Image', 'wpdirectorykit'), |
| 557 |
'tab' => Controls_Manager::TAB_STYLE, |
| 558 |
] |
| 559 |
); |
| 560 |
|
| 561 |
$this->add_responsive_control( |
| 562 |
'styles_thmbn_des_type', |
| 563 |
[ |
| 564 |
'label' => __( 'Design type', 'wpdirectorykit' ), |
| 565 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 566 |
'default' => 'wdk_size_image_cover', |
| 567 |
'options' => [ |
| 568 |
'container' => __( 'Default Sizes', 'wpdirectorykit' ), |
| 569 |
'cover' => __( 'Image auto crop/resize', 'wpdirectorykit' ), |
| 570 |
], |
| 571 |
'selectors_dictionary' => [ |
| 572 |
'container' => 'object-fit: contain;', |
| 573 |
'cover' => 'object-fit: cover;', |
| 574 |
], |
| 575 |
'default' => 'cover', |
| 576 |
'selectors' => [ |
| 577 |
'{{WRAPPER}} .wdk-listings-list .listing-item .listing-img-sec img' => '{{UNIT}}', |
| 578 |
], |
| 579 |
] |
| 580 |
); |
| 581 |
|
| 582 |
$this->add_responsive_control( |
| 583 |
'styles_thmbn_des_height', |
| 584 |
[ |
| 585 |
'label' => esc_html__('Height', 'wpdirectorykit'), |
| 586 |
'type' => Controls_Manager::SLIDER, |
| 587 |
'range' => [ |
| 588 |
'px' => [ |
| 589 |
'min' => 15, |
| 590 |
'max' => 350, |
| 591 |
], |
| 592 |
], |
| 593 |
'size_units' => [ 'px' ], |
| 594 |
'selectors' => [ |
| 595 |
'{{WRAPPER}} .wdk-listings-list .listing-item .listing-img-sec img' => 'height: {{SIZE}}{{UNIT}}', |
| 596 |
], |
| 597 |
'separator' => 'after', |
| 598 |
] |
| 599 |
); |
| 600 |
$this->end_controls_section(); |
| 601 |
|
| 602 |
} |
| 603 |
|
| 604 |
private function generate_controls_content() { |
| 605 |
$this->start_controls_section( |
| 606 |
'content_thumbnail_section', |
| 607 |
[ |
| 608 |
'label' => esc_html__('Colors', 'wpdirectorykit'), |
| 609 |
'tab' => '1', |
| 610 |
] |
| 611 |
); |
| 612 |
|
| 613 |
$this->add_control( |
| 614 |
'content_thumbnail_section_header', |
| 615 |
[ |
| 616 |
'label' => esc_html__('Color Hover Thumbnail', 'wpdirectorykit'), |
| 617 |
'type' => Controls_Manager::HEADING, |
| 618 |
] |
| 619 |
); |
| 620 |
|
| 621 |
$this->add_responsive_control( |
| 622 |
'content_thumbnail_section_d_background', |
| 623 |
[ |
| 624 |
'label' => esc_html__( 'Color', 'wpdirectorykit' ), |
| 625 |
'description' => esc_html__( 'Set some opacity for color', 'wpdirectorykit' ), |
| 626 |
'type' => Controls_Manager::COLOR, |
| 627 |
'selectors' => [ |
| 628 |
'{{WRAPPER}} .wdk-listing-card .wdk-thumbnail::before, {{WRAPPER}} .wdk-listing-card .wdk-thumbnail::after,{{WRAPPER}} .wdk-listing-card .overlay' => 'background-color: {{VALUE}};', |
| 629 |
], |
| 630 |
] |
| 631 |
); |
| 632 |
|
| 633 |
$this->add_control( |
| 634 |
'content_thumbnail_section_header_f', |
| 635 |
[ |
| 636 |
'label' => esc_html__('Shadow around Card, for Featured Listings', 'wpdirectorykit'), |
| 637 |
'type' => Controls_Manager::HEADING, |
| 638 |
] |
| 639 |
); |
| 640 |
|
| 641 |
$this->add_group_control( |
| 642 |
Group_Control_Box_Shadow::get_type(), |
| 643 |
[ |
| 644 |
'name' => 'content_thumbnail_section_d_featured', |
| 645 |
'exclude' => [ |
| 646 |
'field_shadow_position', |
| 647 |
], |
| 648 |
'selector' => '{{WRAPPER}} .wdk-listing-card.is_featured', |
| 649 |
] |
| 650 |
); |
| 651 |
|
| 652 |
$this->end_controls_section(); |
| 653 |
|
| 654 |
|
| 655 |
$items = [ |
| 656 |
[ |
| 657 |
'key'=>'item_box', |
| 658 |
'label'=> esc_html__('Item', 'wpdirectorykit'), |
| 659 |
'selector'=>'.wdk-element .wdk-listing-card', |
| 660 |
'options'=>'block', |
| 661 |
], |
| 662 |
[ |
| 663 |
'key'=>'item_image_box', |
| 664 |
'label'=> esc_html__('Image Box', 'wpdirectorykit'), |
| 665 |
'selector'=>'.wdk-listings-list .listing-item .listing-img-sec img', |
| 666 |
'options'=>'block', |
| 667 |
], |
| 668 |
[ |
| 669 |
'key'=>'item_info_box', |
| 670 |
'label'=> esc_html__('Text Box', 'wpdirectorykit'), |
| 671 |
'selector'=>'.wdk-listings-list .listing-item .listing-inf-sec', |
| 672 |
'options'=>'block', |
| 673 |
], |
| 674 |
[ |
| 675 |
'key'=>'item_title', |
| 676 |
'label'=> esc_html__('Title', 'wpdirectorykit'), |
| 677 |
'selector'=>'.wdk-listings-list .listing-item .listing-inf-sec .title', |
| 678 |
'options'=>'full', |
| 679 |
], |
| 680 |
[ |
| 681 |
'key'=>'item_price', |
| 682 |
'label'=> esc_html__('Price', 'wpdirectorykit'), |
| 683 |
'selector'=>'.wdk-listings-list .listing-item .listing-inf-sec .price', |
| 684 |
'options'=>'full', |
| 685 |
], |
| 686 |
]; |
| 687 |
|
| 688 |
foreach ($items as $item) { |
| 689 |
$this->start_controls_section( |
| 690 |
$item['key'].'_section', |
| 691 |
[ |
| 692 |
'label' => $item['label'], |
| 693 |
'tab' => '1', |
| 694 |
] |
| 695 |
); |
| 696 |
$this->add_responsive_control( |
| 697 |
$item['key'].'_hide', |
| 698 |
[ |
| 699 |
'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ), |
| 700 |
'type' => Controls_Manager::SWITCHER, |
| 701 |
'none' => esc_html__( 'Hide', 'wpdirectorykit' ), |
| 702 |
'block' => esc_html__( 'Show', 'wpdirectorykit' ), |
| 703 |
'return_value' => 'none', |
| 704 |
'default' => '', |
| 705 |
'selectors' => [ |
| 706 |
'{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};', |
| 707 |
], |
| 708 |
] |
| 709 |
); |
| 710 |
$selectors = array( |
| 711 |
'normal' => '{{WRAPPER}} '.$item['selector'], |
| 712 |
'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s' |
| 713 |
); |
| 714 |
|
| 715 |
$this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']); |
| 716 |
|
| 717 |
$this->end_controls_section(); |
| 718 |
} |
| 719 |
|
| 720 |
} |
| 721 |
|
| 722 |
public function enqueue_styles_scripts() { |
| 723 |
wp_enqueue_style('wdk-listings-list'); |
| 724 |
wp_enqueue_style('wdk-notify'); |
| 725 |
wp_enqueue_script('wdk-notify'); |
| 726 |
} |
| 727 |
} |
| 728 |
|