| 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 WdkCategoriesTreeTop 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 |
if ($this->is_edit_mode_load()) { |
| 45 |
$this->enqueue_styles_scripts(); |
| 46 |
} |
| 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-categories-tree-top'; |
| 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 Categories Tree Top', '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-sitemap'; |
| 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('1'); |
| 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 |
$controller = 'category'; |
| 124 |
$this->WMVC->model($controller.'_m'); |
| 125 |
$this->WMVC->model('listing_m'); |
| 126 |
$this->WMVC->model('category_m'); |
| 127 |
|
| 128 |
$this->data['categories_primary'] = array(); |
| 129 |
$this->data['categories_secondary'] = array(); |
| 130 |
|
| 131 |
/* primary */ |
| 132 |
if($this->data['settings']['primary_conf_results_type'] == 'custom_categories') { |
| 133 |
$categories_ids = array(); |
| 134 |
foreach($this->data['settings']['primary_conf_custom_results'] as $category) { |
| 135 |
if(isset($category['category_id']) && !empty($category['category_id'])) { |
| 136 |
$categories_ids [] = $category['category_id']; |
| 137 |
} |
| 138 |
} |
| 139 |
/* where in */ |
| 140 |
if(!empty($categories_ids)){ |
| 141 |
$this->WMVC->db->select($this->WMVC->{$controller.'_m'}->_table_name.'.*, COUNT('.$this->WMVC->listing_m->_table_name.'.post_id) AS listings_counter'); |
| 142 |
$this->WMVC->db->join($this->WMVC->listing_m->_table_name.' ON '.$this->WMVC->listing_m->_table_name.'.category_id = '.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory', TRUE, 'LEFT'); |
| 143 |
$this->WMVC->db->where($this->WMVC->{$controller.'_m'}->_table_name.'.idcategory IN(' . implode(',', $categories_ids) . ')', null, false); |
| 144 |
$this->WMVC->db->order_by('FIELD('.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory, '. implode(',', $categories_ids) . ')'); |
| 145 |
$this->WMVC->db->group_by($this->WMVC->{$controller.'_m'}->_primary_key); |
| 146 |
$this->data['categories_primary'] = $this->WMVC->{$controller.'_m'}->get(); |
| 147 |
} |
| 148 |
} else { |
| 149 |
$where = array(); |
| 150 |
if ($this->data['settings']['primary_root_enable'] == 'yes' && $this->data['settings']['primary_sub_enable'] != 'yes') { |
| 151 |
$where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level = 0)'] = NULL; |
| 152 |
} elseif ($this->data['settings']['primary_root_enable'] != 'yes' && $this->data['settings']['primary_sub_enable'] == 'yes') { |
| 153 |
$where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level != 0)'] = NULL; |
| 154 |
} |
| 155 |
|
| 156 |
$order_by = NULL; |
| 157 |
if($this->data['settings']['primary_conf_order_by'] == 'order_most') { |
| 158 |
/* get category with most listings */ |
| 159 |
$order_by = 'listings_counter '.$this->data['settings']['primary_conf_order']; |
| 160 |
} else if (!empty($this->data['settings']['primary_conf_order_by'])) { |
| 161 |
$order_by = $this->data['settings']['primary_conf_order_by'].' '.$this->data['settings']['primary_conf_order']; |
| 162 |
} |
| 163 |
|
| 164 |
$this->data['categories_primary'] = $this->WMVC->{$controller.'_m'}->get_pagination($this->data['settings']['primary_conf_limit'], $this->data['settings']['primary_conf_offset'], $where, $order_by); |
| 165 |
} |
| 166 |
|
| 167 |
/* secondary */ |
| 168 |
if($this->data['settings']['secondary_categories_enable'] == 'yes') |
| 169 |
if($this->data['settings']['secondary_conf_results_type'] == 'custom_categories') { |
| 170 |
$categories_ids = array(); |
| 171 |
foreach($this->data['settings']['secondary_conf_custom_results'] as $category) { |
| 172 |
if(isset($category['category_id']) && !empty($category['category_id'])) { |
| 173 |
$categories_ids [] = $category['category_id']; |
| 174 |
} |
| 175 |
} |
| 176 |
/* where in */ |
| 177 |
if(!empty($categories_ids)){ |
| 178 |
$this->WMVC->db->select($this->WMVC->{$controller.'_m'}->_table_name.'.*, COUNT('.$this->WMVC->listing_m->_table_name.'.post_id) AS listings_counter'); |
| 179 |
$this->WMVC->db->join($this->WMVC->listing_m->_table_name.' ON '.$this->WMVC->listing_m->_table_name.'.category_id = '.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory', TRUE, 'LEFT'); |
| 180 |
$this->WMVC->db->where($this->WMVC->{$controller.'_m'}->_table_name.'.idcategory IN(' . implode(',', $categories_ids) . ')', null, false); |
| 181 |
$this->WMVC->db->order_by('FIELD('.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory, '. implode(',', $categories_ids) . ')'); |
| 182 |
$this->WMVC->db->group_by($this->WMVC->{$controller.'_m'}->_secondary_key); |
| 183 |
$this->data['categories_secondary'] = $this->WMVC->{$controller.'_m'}->get(); |
| 184 |
} |
| 185 |
} else { |
| 186 |
$where = array(); |
| 187 |
if ($this->data['settings']['secondary_root_enable'] == 'yes' && $this->data['settings']['secondary_sub_enable'] != 'yes') { |
| 188 |
$where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level = 0)'] = NULL; |
| 189 |
} elseif ($this->data['settings']['secondary_root_enable'] != 'yes' && $this->data['settings']['secondary_sub_enable'] == 'yes') { |
| 190 |
$where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level != 0)'] = NULL; |
| 191 |
} |
| 192 |
|
| 193 |
$order_by = NULL; |
| 194 |
if($this->data['settings']['secondary_conf_order_by'] == 'order_most') { |
| 195 |
/* get category with most listings */ |
| 196 |
$order_by = 'listings_counter '.$this->data['settings']['secondary_conf_order']; |
| 197 |
} else if (!empty($this->data['settings']['secondary_conf_order_by'])) { |
| 198 |
$order_by = $this->data['settings']['secondary_conf_order_by'].' '.$this->data['settings']['secondary_conf_order']; |
| 199 |
} |
| 200 |
|
| 201 |
$this->data['categories_secondary'] = $this->WMVC->{$controller.'_m'}->get_pagination($this->data['settings']['secondary_conf_limit'], $this->data['settings']['secondary_conf_offset'], $where, $order_by); |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
$this->data['is_edit_mode']= false; |
| 206 |
if(Plugin::$instance->editor->is_edit_mode()) |
| 207 |
$this->data['is_edit_mode']= true; |
| 208 |
|
| 209 |
echo $this->view('wdk-categories-tree-top', $this->data); |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
private function generate_controls_conf() { |
| 214 |
|
| 215 |
$this->start_controls_section( |
| 216 |
'tab_conf_main_section', |
| 217 |
[ |
| 218 |
'label' => esc_html__('Main Options', 'wpdirectorykit'), |
| 219 |
'tab' => '1', |
| 220 |
] |
| 221 |
); |
| 222 |
|
| 223 |
$pages = array('' => __('Not Selected', 'wpdirectorykit')); |
| 224 |
foreach(get_pages(array('sort_column' => 'post_title')) as $page) |
| 225 |
{ |
| 226 |
$pages[$page->ID] = $page->post_title.' #'.$page->ID; |
| 227 |
} |
| 228 |
|
| 229 |
$this->add_control( |
| 230 |
'conf_link', |
| 231 |
[ |
| 232 |
'label' => __( 'Open results on page', 'wpdirectorykit' ), |
| 233 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 234 |
'default' => '', |
| 235 |
'options' => $pages |
| 236 |
] |
| 237 |
); |
| 238 |
|
| 239 |
$this->add_control( |
| 240 |
'important_note', |
| 241 |
[ |
| 242 |
'label' => '', |
| 243 |
'type' => \Elementor\Controls_Manager::RAW_HTML, |
| 244 |
'raw' => wdk_sprintf(__( 'Edit Categorys <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_category')), |
| 245 |
'content_classes' => 'wdk_elementor_hint', |
| 246 |
] |
| 247 |
); |
| 248 |
|
| 249 |
$this->end_controls_section(); |
| 250 |
|
| 251 |
|
| 252 |
$this->start_controls_section( |
| 253 |
'tab_conf_primary_section', |
| 254 |
[ |
| 255 |
'label' => esc_html__('Top section Categories', 'wpdirectorykit'), |
| 256 |
'tab' => '1', |
| 257 |
] |
| 258 |
); |
| 259 |
|
| 260 |
$this->add_control( |
| 261 |
'primary_conf_results_type', |
| 262 |
[ |
| 263 |
'label' => __( 'Show type', 'wpdirectorykit' ), |
| 264 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 265 |
'default' => 'results_categories', |
| 266 |
'options' => [ |
| 267 |
'results_categories' => __( 'All Categorys', 'wpdirectorykit' ), |
| 268 |
'custom_categories' => __( 'Specific', 'wpdirectorykit' ), |
| 269 |
], |
| 270 |
|
| 271 |
] |
| 272 |
); |
| 273 |
|
| 274 |
$this->add_responsive_control ( |
| 275 |
'primary_thumbnail_position', |
| 276 |
[ |
| 277 |
'label' => __( 'Thumbnail/icon position', 'wpdirectorykit' ), |
| 278 |
'type' => Controls_Manager::SELECT, |
| 279 |
'options' => [ |
| 280 |
'right' => esc_html__('Rigth', 'wpdirectorykit'), |
| 281 |
'left' => esc_html__('Left', 'wpdirectorykit'), |
| 282 |
'top' => esc_html__('Top', 'wpdirectorykit'), |
| 283 |
'bottom' => esc_html__('Bottom', 'wpdirectorykit'), |
| 284 |
], |
| 285 |
'selectors_dictionary' => [ |
| 286 |
'right' => '', |
| 287 |
'left' => 'flex-direction:row-reverse;text-align:right;', |
| 288 |
'top' => 'flex-direction:column-reverse;text-align:center;', |
| 289 |
'bottom' => 'flex-direction:column;text-align:center;', |
| 290 |
], |
| 291 |
'selectors' => [ |
| 292 |
'{{WRAPPER}} .wdk-categories-tree-top .primary .category-card' => '{{UNIT}}', |
| 293 |
], |
| 294 |
'default' => 'right', |
| 295 |
'separator' => 'after', |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$this->add_responsive_control( |
| 300 |
'primary_root_enable', |
| 301 |
[ |
| 302 |
'label' => esc_html__( 'Show Main Categories', 'wpdirectorykit' ), |
| 303 |
'type' => Controls_Manager::SWITCHER, |
| 304 |
'none' => esc_html__( 'No', 'wpdirectorykit' ), |
| 305 |
'block' => esc_html__( 'Yes', 'wpdirectorykit' ), |
| 306 |
'return_value' => 'yes', |
| 307 |
'default' => 'yes', |
| 308 |
] |
| 309 |
); |
| 310 |
|
| 311 |
$this->add_responsive_control( |
| 312 |
'primary_sub_enable', |
| 313 |
[ |
| 314 |
'label' => esc_html__( 'Show Sub Categories', 'wpdirectorykit' ), |
| 315 |
'type' => Controls_Manager::SWITCHER, |
| 316 |
'none' => esc_html__( 'No', 'wpdirectorykit' ), |
| 317 |
'block' => esc_html__( 'Yes', 'wpdirectorykit' ), |
| 318 |
'return_value' => 'yes', |
| 319 |
'default' => '', |
| 320 |
] |
| 321 |
); |
| 322 |
|
| 323 |
$this->add_control( |
| 324 |
'primary_layout_image_type', |
| 325 |
[ |
| 326 |
'label' => __( 'Thumbnail Type', 'wpdirectorykit' ), |
| 327 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 328 |
'default' => 'font_icon', |
| 329 |
'options' => [ |
| 330 |
'icon' => __( 'Icon', 'wpdirectorykit' ), |
| 331 |
'image' => __( 'Image', 'wpdirectorykit' ), |
| 332 |
'font_icon' => __( 'Font Icon', 'wpdirectorykit' ), |
| 333 |
], |
| 334 |
'separator' => 'before', |
| 335 |
] |
| 336 |
); |
| 337 |
|
| 338 |
$this->add_control( |
| 339 |
'primary_conf_offset', |
| 340 |
[ |
| 341 |
'label' => __( 'Offset Categories', 'wpdirectorykit' ), |
| 342 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 343 |
'min' => 1, |
| 344 |
'max' => 50, |
| 345 |
'step' => 1, |
| 346 |
'default' => 0, |
| 347 |
'separator' => 'before', |
| 348 |
'conditions' => [ |
| 349 |
'terms' => [ |
| 350 |
[ |
| 351 |
'name' => 'primary_conf_results_type', |
| 352 |
'operator' => '==', |
| 353 |
'value' => 'results_categories', |
| 354 |
] |
| 355 |
], |
| 356 |
], |
| 357 |
] |
| 358 |
); |
| 359 |
|
| 360 |
$this->add_control( |
| 361 |
'primary_conf_order_by', |
| 362 |
[ |
| 363 |
'label' => __('Order By Column', 'wpdirectorykit'), |
| 364 |
'type' => Controls_Manager::SELECT, |
| 365 |
'label_block' => true, |
| 366 |
'options' => [ |
| 367 |
'' => __('None', 'wpdirectorykit'), |
| 368 |
'category_title' => __('Title', 'wpdirectorykit'), |
| 369 |
'idcategory' => __('Category id', 'wpdirectorykit'), |
| 370 |
'order_index' => __('Order index', 'wpdirectorykit'), |
| 371 |
'listings_counter' => __('Most Listings', 'wpdirectorykit'), |
| 372 |
'rand()' => __('Random', 'wpdirectorykit'), |
| 373 |
], |
| 374 |
'default' => 'order_index', |
| 375 |
'conditions' => [ |
| 376 |
'terms' => [ |
| 377 |
[ |
| 378 |
'name' => 'primary_conf_results_type', |
| 379 |
'operator' => '==', |
| 380 |
'value' => 'results_categories', |
| 381 |
] |
| 382 |
], |
| 383 |
], |
| 384 |
] |
| 385 |
); |
| 386 |
|
| 387 |
$this->add_control( |
| 388 |
'primary_conf_order', |
| 389 |
[ |
| 390 |
'label' => __('Order', 'wpdirectorykit'), |
| 391 |
'type' => Controls_Manager::SELECT, |
| 392 |
'label_block' => true, |
| 393 |
'options' => [ |
| 394 |
'asc' => __('Ascending', 'wpdirectorykit'), |
| 395 |
'desc' => __('Descending', 'wpdirectorykit') |
| 396 |
], |
| 397 |
'default' => 'desc', |
| 398 |
'conditions' => [ |
| 399 |
'terms' => [ |
| 400 |
[ |
| 401 |
'name' => 'primary_conf_results_type', |
| 402 |
'operator' => '==', |
| 403 |
'value' => 'results_categories', |
| 404 |
] |
| 405 |
], |
| 406 |
], |
| 407 |
] |
| 408 |
); |
| 409 |
|
| 410 |
if(true){ |
| 411 |
$repeater = new Repeater(); |
| 412 |
$repeater->start_controls_tabs( 'categories' ); |
| 413 |
$repeater->add_control( |
| 414 |
'category_id', |
| 415 |
[ |
| 416 |
'label' => __( 'ID category', 'wpdirectorykit' ), |
| 417 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 418 |
'min' => 1, |
| 419 |
'step' => 1, |
| 420 |
] |
| 421 |
); |
| 422 |
$repeater->end_controls_tabs(); |
| 423 |
|
| 424 |
$this->add_control( |
| 425 |
'primary_conf_custom_results', |
| 426 |
[ |
| 427 |
'type' => Controls_Manager::REPEATER, |
| 428 |
'fields' => $repeater->get_controls(), |
| 429 |
'default' => [ |
| 430 |
], |
| 431 |
'title_field' => '{{{ category_id }}}', |
| 432 |
'conditions' => [ |
| 433 |
'terms' => [ |
| 434 |
[ |
| 435 |
'name' => 'primary_conf_results_type', |
| 436 |
'operator' => '==', |
| 437 |
'value' => 'custom_categories', |
| 438 |
] |
| 439 |
], |
| 440 |
], |
| 441 |
] |
| 442 |
); |
| 443 |
} |
| 444 |
|
| 445 |
$this->end_controls_section(); |
| 446 |
|
| 447 |
|
| 448 |
$this->start_controls_section( |
| 449 |
'tab_conf_secondary_section', |
| 450 |
[ |
| 451 |
'label' => esc_html__('Bottom section Categories', 'wpdirectorykit'), |
| 452 |
'tab' => '1', |
| 453 |
] |
| 454 |
); |
| 455 |
|
| 456 |
$this->add_control( |
| 457 |
'secondary_categories_enable', |
| 458 |
[ |
| 459 |
'label' => esc_html__( 'Show Bottom Categories', 'wpdirectorykit' ), |
| 460 |
'type' => Controls_Manager::SWITCHER, |
| 461 |
'none' => esc_html__( 'No', 'wpdirectorykit' ), |
| 462 |
'block' => esc_html__( 'Yes', 'wpdirectorykit' ), |
| 463 |
'return_value' => 'yes', |
| 464 |
'default' => 'yes', |
| 465 |
] |
| 466 |
); |
| 467 |
|
| 468 |
$this->add_control( |
| 469 |
'secondary_conf_results_type', |
| 470 |
[ |
| 471 |
'label' => __( 'Show type', 'wpdirectorykit' ), |
| 472 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 473 |
'default' => 'results_categories', |
| 474 |
'options' => [ |
| 475 |
'results_categories' => __( 'All Categorys', 'wpdirectorykit' ), |
| 476 |
'custom_categories' => __( 'Specific', 'wpdirectorykit' ), |
| 477 |
], |
| 478 |
] |
| 479 |
); |
| 480 |
|
| 481 |
$this->add_responsive_control ( |
| 482 |
'secondary_thumbnail_position', |
| 483 |
[ |
| 484 |
'label' => __( 'Thumbnail/icon position', 'wpdirectorykit' ), |
| 485 |
'type' => Controls_Manager::SELECT, |
| 486 |
'options' => [ |
| 487 |
'right' => esc_html__('Rigth', 'wpdirectorykit'), |
| 488 |
'left' => esc_html__('Left', 'wpdirectorykit'), |
| 489 |
'top' => esc_html__('Top', 'wpdirectorykit'), |
| 490 |
'bottom' => esc_html__('Bottom', 'wpdirectorykit'), |
| 491 |
], |
| 492 |
'selectors_dictionary' => [ |
| 493 |
'right' => '', |
| 494 |
'left' => 'flex-direction:row-reverse;text-align:right;', |
| 495 |
'top' => 'flex-direction:column-reverse;text-align:center;', |
| 496 |
'bottom' => 'flex-direction:column;text-align:center;', |
| 497 |
], |
| 498 |
'selectors' => [ |
| 499 |
'{{WRAPPER}} .wdk-categories-tree-top .secondary .category-card' => '{{UNIT}}', |
| 500 |
], |
| 501 |
'default' => 'top', |
| 502 |
'separator' => 'after', |
| 503 |
] |
| 504 |
); |
| 505 |
|
| 506 |
$this->add_responsive_control( |
| 507 |
'secondary_root_enable', |
| 508 |
[ |
| 509 |
'label' => esc_html__( 'Show Main Categories', 'wpdirectorykit' ), |
| 510 |
'type' => Controls_Manager::SWITCHER, |
| 511 |
'none' => esc_html__( 'No', 'wpdirectorykit' ), |
| 512 |
'block' => esc_html__( 'Yes', 'wpdirectorykit' ), |
| 513 |
'return_value' => 'yes', |
| 514 |
'default' => '', |
| 515 |
'conditions' => [ |
| 516 |
'terms' => [ |
| 517 |
[ |
| 518 |
'name' => 'secondary_conf_results_type', |
| 519 |
'operator' => '==', |
| 520 |
'value' => 'results_categories', |
| 521 |
] |
| 522 |
], |
| 523 |
], |
| 524 |
] |
| 525 |
); |
| 526 |
|
| 527 |
$this->add_responsive_control( |
| 528 |
'secondary_sub_enable', |
| 529 |
[ |
| 530 |
'label' => esc_html__( 'Show Sub Categories', 'wpdirectorykit' ), |
| 531 |
'type' => Controls_Manager::SWITCHER, |
| 532 |
'none' => esc_html__( 'No', 'wpdirectorykit' ), |
| 533 |
'block' => esc_html__( 'Yes', 'wpdirectorykit' ), |
| 534 |
'return_value' => 'yes', |
| 535 |
'default' => 'yes', |
| 536 |
'conditions' => [ |
| 537 |
'terms' => [ |
| 538 |
[ |
| 539 |
'name' => 'secondary_conf_results_type', |
| 540 |
'operator' => '==', |
| 541 |
'value' => 'results_categories', |
| 542 |
] |
| 543 |
], |
| 544 |
], |
| 545 |
] |
| 546 |
); |
| 547 |
|
| 548 |
$this->add_control( |
| 549 |
'secondary_layout_image_type', |
| 550 |
[ |
| 551 |
'label' => __( 'Thumbnail Type', 'wpdirectorykit' ), |
| 552 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 553 |
'default' => 'font_icon', |
| 554 |
'options' => [ |
| 555 |
'icon' => __( 'Icon', 'wpdirectorykit' ), |
| 556 |
'image' => __( 'Image', 'wpdirectorykit' ), |
| 557 |
'font_icon' => __( 'Font Icon', 'wpdirectorykit' ), |
| 558 |
], |
| 559 |
'separator' => 'before', |
| 560 |
] |
| 561 |
); |
| 562 |
|
| 563 |
$this->add_control( |
| 564 |
'secondary_conf_offset', |
| 565 |
[ |
| 566 |
'label' => __( 'Offset Categories', 'wpdirectorykit' ), |
| 567 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 568 |
'min' => 1, |
| 569 |
'max' => 50, |
| 570 |
'step' => 1, |
| 571 |
'default' => 0, |
| 572 |
'separator' => 'before', |
| 573 |
'conditions' => [ |
| 574 |
'terms' => [ |
| 575 |
[ |
| 576 |
'name' => 'secondary_conf_results_type', |
| 577 |
'operator' => '==', |
| 578 |
'value' => 'results_categories', |
| 579 |
] |
| 580 |
], |
| 581 |
], |
| 582 |
] |
| 583 |
); |
| 584 |
|
| 585 |
$this->add_control( |
| 586 |
'secondary_conf_limit', |
| 587 |
[ |
| 588 |
'label' => __( 'Limit Categories', 'wpdirectorykit' ), |
| 589 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 590 |
'min' => 1, |
| 591 |
'max' => 50, |
| 592 |
'step' => 1, |
| 593 |
'default' => 16, |
| 594 |
'separator' => 'after', |
| 595 |
'conditions' => [ |
| 596 |
'terms' => [ |
| 597 |
[ |
| 598 |
'name' => 'secondary_conf_results_type', |
| 599 |
'operator' => '==', |
| 600 |
'value' => 'results_categories', |
| 601 |
] |
| 602 |
], |
| 603 |
], |
| 604 |
] |
| 605 |
); |
| 606 |
|
| 607 |
$this->add_control( |
| 608 |
'secondary_conf_order_by', |
| 609 |
[ |
| 610 |
'label' => __('Order By Column', 'wpdirectorykit'), |
| 611 |
'type' => Controls_Manager::SELECT, |
| 612 |
'label_block' => true, |
| 613 |
'options' => [ |
| 614 |
'' => __('None', 'wpdirectorykit'), |
| 615 |
'category_title' => __('Title', 'wpdirectorykit'), |
| 616 |
'idcategory' => __('Category id', 'wpdirectorykit'), |
| 617 |
'order_index' => __('Order index', 'wpdirectorykit'), |
| 618 |
'listings_counter' => __('Most Listings', 'wpdirectorykit'), |
| 619 |
'rand()' => __('Random', 'wpdirectorykit'), |
| 620 |
], |
| 621 |
'default' => 'order_index', |
| 622 |
'conditions' => [ |
| 623 |
'terms' => [ |
| 624 |
[ |
| 625 |
'name' => 'secondary_conf_results_type', |
| 626 |
'operator' => '==', |
| 627 |
'value' => 'results_categories', |
| 628 |
] |
| 629 |
], |
| 630 |
], |
| 631 |
] |
| 632 |
); |
| 633 |
|
| 634 |
$this->add_control( |
| 635 |
'secondary_conf_order', |
| 636 |
[ |
| 637 |
'label' => __('Order', 'wpdirectorykit'), |
| 638 |
'type' => Controls_Manager::SELECT, |
| 639 |
'label_block' => true, |
| 640 |
'options' => [ |
| 641 |
'asc' => __('Ascending', 'wpdirectorykit'), |
| 642 |
'desc' => __('Descending', 'wpdirectorykit') |
| 643 |
], |
| 644 |
'default' => 'desc', |
| 645 |
'conditions' => [ |
| 646 |
'terms' => [ |
| 647 |
[ |
| 648 |
'name' => 'secondary_conf_results_type', |
| 649 |
'operator' => '==', |
| 650 |
'value' => 'results_categories', |
| 651 |
] |
| 652 |
], |
| 653 |
], |
| 654 |
] |
| 655 |
); |
| 656 |
|
| 657 |
if(true){ |
| 658 |
$repeater = new Repeater(); |
| 659 |
$repeater->start_controls_tabs( 'categories' ); |
| 660 |
$repeater->add_control( |
| 661 |
'category_id', |
| 662 |
[ |
| 663 |
'label' => __( 'ID category', 'wpdirectorykit' ), |
| 664 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 665 |
'min' => 1, |
| 666 |
'step' => 1, |
| 667 |
] |
| 668 |
); |
| 669 |
$repeater->end_controls_tabs(); |
| 670 |
|
| 671 |
$this->add_control( |
| 672 |
'secondary_conf_custom_results', |
| 673 |
[ |
| 674 |
'type' => Controls_Manager::REPEATER, |
| 675 |
'fields' => $repeater->get_controls(), |
| 676 |
'default' => [ |
| 677 |
], |
| 678 |
'title_field' => '{{{ category_id }}}', |
| 679 |
'conditions' => [ |
| 680 |
'terms' => [ |
| 681 |
[ |
| 682 |
'name' => 'secondary_conf_results_type', |
| 683 |
'operator' => '==', |
| 684 |
'value' => 'custom_categories', |
| 685 |
] |
| 686 |
], |
| 687 |
], |
| 688 |
] |
| 689 |
); |
| 690 |
} |
| 691 |
|
| 692 |
$this->end_controls_section(); |
| 693 |
|
| 694 |
} |
| 695 |
|
| 696 |
private function generate_controls_layout() { |
| 697 |
} |
| 698 |
|
| 699 |
private function generate_controls_styles() { |
| 700 |
|
| 701 |
$this->section_cards('primary'); |
| 702 |
$this->section_cards('secondary', '25%'); |
| 703 |
} |
| 704 |
|
| 705 |
private function section_cards($prefix = '', $grid_default = 'calc(100% / 3)') { |
| 706 |
|
| 707 |
$this->start_controls_section( |
| 708 |
$prefix.'styles_primary_section', |
| 709 |
[ |
| 710 |
'label' => esc_html__($prefix, 'wpdirectorykit'), |
| 711 |
'tab' => Controls_Manager::TAB_STYLE, |
| 712 |
] |
| 713 |
); |
| 714 |
|
| 715 |
$this->add_responsive_control( |
| 716 |
$prefix.'primary_row_gap_col', |
| 717 |
[ |
| 718 |
'label' => __( 'Columns', 'wpdirectorykit' ), |
| 719 |
'type' => Controls_Manager::SELECT, |
| 720 |
'options' => [ |
| 721 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 722 |
'auto' => esc_html__('Auto', 'wpdirectorykit'), |
| 723 |
'100%' => '1', |
| 724 |
'50%' => '2', |
| 725 |
'calc(100% / 3)' => '3', |
| 726 |
'25%' => '4', |
| 727 |
'20%' => '5', |
| 728 |
'auto_flexible' => 'auto flexible', |
| 729 |
], |
| 730 |
'selectors_dictionary' => [ |
| 731 |
'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto', |
| 732 |
'100%' => '-webkit-flex:1 2 100%;flex:1 2 100%', |
| 733 |
'50%' => '-webkit-flex:1 2 50%;flex:1 2 50%', |
| 734 |
'calc(100% / 3)' => '-webkit-flex:1 2 calc(100% / 3);flex:1 2 calc(100% / 3)', |
| 735 |
'25%' => '-webkit-flex:1 2 25%;flex:1 2 25%', |
| 736 |
'20%' => '-webkit-flex:1 2 20%;flex:1 2 20%', |
| 737 |
'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto', |
| 738 |
'auto_flexible' => '-webkit-flex:1 2 auto;flex:1 2 auto', |
| 739 |
], |
| 740 |
'selectors' => [ |
| 741 |
'{{WRAPPER}} .'.$prefix.' .wdk-row .wdk-col' => '{{UNIT}}', |
| 742 |
], |
| 743 |
'default' => $grid_default, |
| 744 |
'separator' => 'before', |
| 745 |
] |
| 746 |
); |
| 747 |
|
| 748 |
$this->add_responsive_control( |
| 749 |
$prefix.'primary_column_gap', |
| 750 |
[ |
| 751 |
'label' => esc_html__('Columns Gap', 'wpdirectorykit'), |
| 752 |
'type' => Controls_Manager::SLIDER, |
| 753 |
'default' => [ |
| 754 |
'size' => 10, |
| 755 |
], |
| 756 |
'range' => [ |
| 757 |
'px' => [ |
| 758 |
'min' => 0, |
| 759 |
'max' => 60, |
| 760 |
], |
| 761 |
], |
| 762 |
'selectors' => [ |
| 763 |
'{{WRAPPER}} .'.$prefix.' .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;', |
| 764 |
'{{WRAPPER}} .'.$prefix.' .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};', |
| 765 |
], |
| 766 |
] |
| 767 |
); |
| 768 |
|
| 769 |
$this->add_responsive_control( |
| 770 |
$prefix.'primary_row_gap', |
| 771 |
[ |
| 772 |
'label' => esc_html__('Rows Gap', 'wpdirectorykit'), |
| 773 |
'type' => Controls_Manager::SLIDER, |
| 774 |
'default' => [ |
| 775 |
'size' => 10, |
| 776 |
], |
| 777 |
'range' => [ |
| 778 |
'px' => [ |
| 779 |
'min' => 0, |
| 780 |
'max' => 60, |
| 781 |
], |
| 782 |
], |
| 783 |
'selectors' => [ |
| 784 |
'{{WRAPPER}} .'.$prefix.' .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 785 |
'{{WRAPPER}} .'.$prefix.' .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};', |
| 786 |
], |
| 787 |
] |
| 788 |
); |
| 789 |
|
| 790 |
$items = [ |
| 791 |
[ |
| 792 |
'key'=>$prefix.'card', |
| 793 |
'label'=> esc_html__('Card', 'wpdirectorykit'), |
| 794 |
'selectors'=> array( |
| 795 |
'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card', |
| 796 |
'hover'=>'{{WRAPPER}} .'.$prefix.' .category-card%1$s', |
| 797 |
), |
| 798 |
'options'=>['background','border','border_radius','padding','shadow','transition','padding'], |
| 799 |
], |
| 800 |
[ |
| 801 |
'key'=>$prefix.'title', |
| 802 |
'label'=> esc_html__('Title', 'wpdirectorykit'), |
| 803 |
'selectors'=> array( |
| 804 |
'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card .body .title', |
| 805 |
'hover'=>'{{WRAPPER}} .'.$prefix.' .category-card%1$s .body .title', |
| 806 |
), |
| 807 |
'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'], |
| 808 |
], |
| 809 |
[ |
| 810 |
'key'=>$prefix.'sub', |
| 811 |
'label'=> esc_html__('Subtitle (count)', 'wpdirectorykit'), |
| 812 |
'selectors'=> array( |
| 813 |
'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card .body .sub', |
| 814 |
'hover'=>'{{WRAPPER}} .'.$prefix.' .category-card%1$s .body .sub', |
| 815 |
), |
| 816 |
'selector_hider'=>'{{WRAPPER}} .'.$prefix.' .category-card .body .sub', |
| 817 |
'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'], |
| 818 |
], |
| 819 |
[ |
| 820 |
'key'=>$prefix.'thumbnail', |
| 821 |
'label'=> esc_html__('Thumbnail', 'wpdirectorykit'), |
| 822 |
'selectors'=> array( |
| 823 |
'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card .thumbnail>*', |
| 824 |
), |
| 825 |
'selector_hider'=>'{{WRAPPER}} .'.$prefix.' .category-card .thumbnail', |
| 826 |
'options'=>['border','border_radius','padding','shadow','transition','image_size_control','image_fit_control','font-size','css_filters'], |
| 827 |
], |
| 828 |
]; |
| 829 |
|
| 830 |
foreach ($items as $item) { |
| 831 |
$this->add_control( |
| 832 |
$item['key'].'_section', |
| 833 |
[ |
| 834 |
'label' => $item['label'], |
| 835 |
'type' => \Elementor\Controls_Manager::HEADING, |
| 836 |
] |
| 837 |
); |
| 838 |
|
| 839 |
if(isset($item['selector_hidder'])) { |
| 840 |
$this->add_responsive_control( |
| 841 |
$item['key'].'_hide', |
| 842 |
[ |
| 843 |
'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ), |
| 844 |
'type' => Controls_Manager::SWITCHER, |
| 845 |
'none' => esc_html__( 'Hide', 'wpdirectorykit' ), |
| 846 |
'block' => esc_html__( 'Show', 'wpdirectorykit' ), |
| 847 |
'return_value' => 'none', |
| 848 |
'default' => '', |
| 849 |
'selectors' => [ |
| 850 |
$item['selector_hidder'] => 'display: {{VALUE}};', |
| 851 |
], |
| 852 |
] |
| 853 |
); |
| 854 |
} |
| 855 |
|
| 856 |
$selectors = array(); |
| 857 |
if(isset($item['selectors'])) { |
| 858 |
$selectors = $item['selectors']; |
| 859 |
} |
| 860 |
|
| 861 |
$this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']); |
| 862 |
|
| 863 |
$this->add_control( |
| 864 |
$item['key'].'_hr', |
| 865 |
[ |
| 866 |
'type' => \Elementor\Controls_Manager::DIVIDER, |
| 867 |
] |
| 868 |
); |
| 869 |
|
| 870 |
} |
| 871 |
|
| 872 |
$this->end_controls_section(); |
| 873 |
} |
| 874 |
|
| 875 |
private function generate_controls_content() { |
| 876 |
|
| 877 |
} |
| 878 |
|
| 879 |
public function enqueue_styles_scripts() { |
| 880 |
wp_enqueue_style('wdk-categories-tree-top'); |
| 881 |
} |
| 882 |
} |
| 883 |
|