| 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 WdkCategoriesTree 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'; |
| 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', '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['results'] = array(); |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
if($this->data['settings']['conf_results_type'] == 'custom_categories') { |
| 133 |
$categories_ids = array(); |
| 134 |
foreach($this->data['settings']['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 |
$where = array(); |
| 142 |
$where[$this->WMVC->{$controller.'_m'}->_table_name.'.level_0_id IN (' . implode(',', $categories_ids) . ') OR '.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory IN (' . implode(',', $categories_ids) . ')'] = NULL; |
| 143 |
$this->data['categories'] = $this->WMVC->category_m->get_pagination(NULL, NULL, $where); |
| 144 |
} |
| 145 |
} else { |
| 146 |
$this->data['categories'] = $this->WMVC->category_m->get_pagination(NULL, NULL, array()); |
| 147 |
} |
| 148 |
|
| 149 |
$this->data['is_edit_mode']= false; |
| 150 |
if(Plugin::$instance->editor->is_edit_mode()) |
| 151 |
$this->data['is_edit_mode']= true; |
| 152 |
|
| 153 |
echo $this->view('wdk-categories-tree', $this->data); |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
private function generate_controls_conf() { |
| 158 |
$this->start_controls_section( |
| 159 |
'tab_conf_main_section', |
| 160 |
[ |
| 161 |
'label' => esc_html__('Main', 'wpdirectorykit'), |
| 162 |
'tab' => '1', |
| 163 |
] |
| 164 |
); |
| 165 |
|
| 166 |
$pages = array('' => __('Not Selected', 'wpdirectorykit')); |
| 167 |
foreach(get_pages(array('sort_column' => 'post_title')) as $page) |
| 168 |
{ |
| 169 |
$pages[$page->ID] = $page->post_title.' #'.$page->ID; |
| 170 |
} |
| 171 |
|
| 172 |
$this->add_control( |
| 173 |
'conf_link', |
| 174 |
[ |
| 175 |
'label' => __( 'Open results on page', 'wpdirectorykit' ), |
| 176 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 177 |
'default' => '', |
| 178 |
'options' => $pages |
| 179 |
] |
| 180 |
); |
| 181 |
|
| 182 |
|
| 183 |
$this->add_control( |
| 184 |
'conf_results_type', |
| 185 |
[ |
| 186 |
'label' => __( 'Show type', 'wpdirectorykit' ), |
| 187 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 188 |
'default' => 'results_categories', |
| 189 |
'options' => [ |
| 190 |
'results_categories' => __( 'All Categorys', 'wpdirectorykit' ), |
| 191 |
'custom_categories' => __( 'Specific', 'wpdirectorykit' ), |
| 192 |
], |
| 193 |
|
| 194 |
] |
| 195 |
); |
| 196 |
|
| 197 |
$this->add_control( |
| 198 |
'conf_limit_root', |
| 199 |
[ |
| 200 |
'label' => __( 'Limit Main Categories', 'wpdirectorykit' ), |
| 201 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 202 |
'min' => 1, |
| 203 |
'max' => 50, |
| 204 |
'step' => 1, |
| 205 |
'default' => 9, |
| 206 |
'conditions' => [ |
| 207 |
'terms' => [ |
| 208 |
[ |
| 209 |
'name' => 'conf_results_type', |
| 210 |
'operator' => '==', |
| 211 |
'value' => 'results_categories', |
| 212 |
] |
| 213 |
], |
| 214 |
], |
| 215 |
] |
| 216 |
); |
| 217 |
|
| 218 |
$this->add_control( |
| 219 |
'conf_limit_sub', |
| 220 |
[ |
| 221 |
'label' => __( 'Limit Sub Categories', 'wpdirectorykit' ), |
| 222 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 223 |
'min' => 1, |
| 224 |
'max' => 50, |
| 225 |
'step' => 1, |
| 226 |
'default' => 9, |
| 227 |
'conditions' => [ |
| 228 |
'terms' => [ |
| 229 |
[ |
| 230 |
'name' => 'conf_results_type', |
| 231 |
'operator' => '==', |
| 232 |
'value' => 'results_categories', |
| 233 |
] |
| 234 |
], |
| 235 |
], |
| 236 |
] |
| 237 |
); |
| 238 |
|
| 239 |
$this->add_control( |
| 240 |
'show_more_subs', |
| 241 |
[ |
| 242 |
'label' => __( 'Show Button Open More SubCategories', 'wpdirectorykit' ), |
| 243 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 244 |
'label_on' => __( 'On', 'wpdirectorykit' ), |
| 245 |
'label_off' => __( 'Off', 'wpdirectorykit' ), |
| 246 |
'return_value' => 'yes', |
| 247 |
'default' => '', |
| 248 |
'separator' => 'before', |
| 249 |
'conditions' => [ |
| 250 |
'terms' => [ |
| 251 |
[ |
| 252 |
'name' => 'conf_results_type', |
| 253 |
'operator' => '==', |
| 254 |
'value' => 'results_categories', |
| 255 |
] |
| 256 |
], |
| 257 |
], |
| 258 |
] |
| 259 |
); |
| 260 |
|
| 261 |
$this->add_control( |
| 262 |
'show_more', |
| 263 |
[ |
| 264 |
'label' => __( 'Show Button Open More Categories', 'wpdirectorykit' ), |
| 265 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 266 |
'label_on' => __( 'On', 'wpdirectorykit' ), |
| 267 |
'label_off' => __( 'Off', 'wpdirectorykit' ), |
| 268 |
'return_value' => 'yes', |
| 269 |
'default' => '', |
| 270 |
'separator' => 'after', |
| 271 |
'conditions' => [ |
| 272 |
'terms' => [ |
| 273 |
[ |
| 274 |
'name' => 'conf_results_type', |
| 275 |
'operator' => '==', |
| 276 |
'value' => 'results_categories', |
| 277 |
] |
| 278 |
], |
| 279 |
], |
| 280 |
] |
| 281 |
); |
| 282 |
|
| 283 |
if(true){ |
| 284 |
|
| 285 |
$repeater = new Repeater(); |
| 286 |
$repeater->start_controls_tabs( 'categories' ); |
| 287 |
|
| 288 |
$WMVC = &wdk_get_instance(); |
| 289 |
$WMVC->model('category_m'); |
| 290 |
$categories_root = array('' => esc_html__('Not Selected', 'wpdirectorykit')); |
| 291 |
$categories = $WMVC->category_m->get_pagination(NULL, NULL, array('('.$WMVC->category_m->_table_name.'.level = 0)'=>NULL)); |
| 292 |
foreach ($categories as $key => $category) { |
| 293 |
$categories_root[$category->idcategory] = $category->category_title; |
| 294 |
} |
| 295 |
|
| 296 |
$repeater->add_control( |
| 297 |
'category_id', |
| 298 |
[ |
| 299 |
'label' => __( 'Categories', 'wpdirectorykit' ), |
| 300 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 301 |
'default' => '', |
| 302 |
'options' => $categories_root, |
| 303 |
'separator' => 'after', |
| 304 |
] |
| 305 |
); |
| 306 |
|
| 307 |
$repeater->end_controls_tabs(); |
| 308 |
|
| 309 |
$this->add_control( |
| 310 |
'conf_custom_results', |
| 311 |
[ |
| 312 |
'type' => Controls_Manager::REPEATER, |
| 313 |
'fields' => $repeater->get_controls(), |
| 314 |
'default' => [ |
| 315 |
], |
| 316 |
'title_field' => '{{{ category_id }}}', |
| 317 |
'conditions' => [ |
| 318 |
'terms' => [ |
| 319 |
[ |
| 320 |
'name' => 'conf_results_type', |
| 321 |
'operator' => '==', |
| 322 |
'value' => 'custom_categories', |
| 323 |
] |
| 324 |
], |
| 325 |
], |
| 326 |
] |
| 327 |
); |
| 328 |
} |
| 329 |
|
| 330 |
$this->add_control( |
| 331 |
'show_icon', |
| 332 |
[ |
| 333 |
'label' => __( 'Enable Category Icons', 'wpdirectorykit' ), |
| 334 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 335 |
'label_on' => __( 'On', 'wpdirectorykit' ), |
| 336 |
'label_off' => __( 'Off', 'wpdirectorykit' ), |
| 337 |
'return_value' => 'yes', |
| 338 |
'default' => 'yes', |
| 339 |
'separator' => 'before', |
| 340 |
] |
| 341 |
); |
| 342 |
|
| 343 |
$this->add_control( |
| 344 |
'layout_image_type', |
| 345 |
[ |
| 346 |
'label' => __( 'Thumbnail Type', 'wpdirectorykit' ), |
| 347 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 348 |
'default' => 'font_icon', |
| 349 |
'options' => [ |
| 350 |
'icon' => __( 'Icon', 'wpdirectorykit' ), |
| 351 |
'image' => __( 'Image', 'wpdirectorykit' ), |
| 352 |
'font_icon' => __( 'Font Icon', 'wpdirectorykit' ), |
| 353 |
], |
| 354 |
'conditions' => [ |
| 355 |
'terms' => [ |
| 356 |
[ |
| 357 |
'name' => 'show_icon', |
| 358 |
'operator' => '==', |
| 359 |
'value' => 'yes', |
| 360 |
] |
| 361 |
], |
| 362 |
], |
| 363 |
] |
| 364 |
); |
| 365 |
|
| 366 |
$this->add_control( |
| 367 |
'important_note', |
| 368 |
[ |
| 369 |
'label' => '', |
| 370 |
'type' => \Elementor\Controls_Manager::RAW_HTML, |
| 371 |
'raw' => wdk_sprintf(__( 'Manage Categories <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_category')), |
| 372 |
'content_classes' => 'wdk_elementor_hint', |
| 373 |
] |
| 374 |
); |
| 375 |
|
| 376 |
$this->add_responsive_control( |
| 377 |
'row_gap_col', |
| 378 |
[ |
| 379 |
'label' => __( 'Columns', 'wpdirectorykit' ), |
| 380 |
'type' => Controls_Manager::SELECT, |
| 381 |
'options' => [ |
| 382 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 383 |
'auto' => esc_html__('Auto', 'wpdirectorykit'), |
| 384 |
'100%' => '1', |
| 385 |
'50%' => '2', |
| 386 |
'calc(100% / 3)' => '3', |
| 387 |
'25%' => '4', |
| 388 |
'20%' => '5', |
| 389 |
'auto_flexible' => 'auto flexible', |
| 390 |
], |
| 391 |
'selectors_dictionary' => [ |
| 392 |
'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto', |
| 393 |
'100%' => '-webkit-flex:0 0 100%;flex:0 0 100%', |
| 394 |
'50%' => '-webkit-flex:0 0 50%;flex:0 0 50%', |
| 395 |
'calc(100% / 3)' => '-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)', |
| 396 |
'25%' => '-webkit-flex:0 0 25%;flex:0 0 25%', |
| 397 |
'20%' => '-webkit-flex:0 0 20%;flex:0 0 20%', |
| 398 |
'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto', |
| 399 |
'auto_flexible' => '-webkit-flex:0 0 auto;flex:0 0 auto', |
| 400 |
], |
| 401 |
'selectors' => [ |
| 402 |
'{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}', |
| 403 |
], |
| 404 |
'default' => 'calc(100% / 3)', |
| 405 |
'separator' => 'before', |
| 406 |
] |
| 407 |
); |
| 408 |
|
| 409 |
$this->add_responsive_control( |
| 410 |
'column_gap', |
| 411 |
[ |
| 412 |
'label' => esc_html__('Columns Gap', 'wpdirectorykit'), |
| 413 |
'type' => Controls_Manager::SLIDER, |
| 414 |
'default' => [ |
| 415 |
'size' => 10, |
| 416 |
], |
| 417 |
'range' => [ |
| 418 |
'px' => [ |
| 419 |
'min' => 0, |
| 420 |
'max' => 60, |
| 421 |
], |
| 422 |
], |
| 423 |
'selectors' => [ |
| 424 |
'{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;', |
| 425 |
'{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};', |
| 426 |
], |
| 427 |
] |
| 428 |
); |
| 429 |
|
| 430 |
$this->add_responsive_control( |
| 431 |
'row_gap', |
| 432 |
[ |
| 433 |
'label' => esc_html__('Rows Gap', 'wpdirectorykit'), |
| 434 |
'type' => Controls_Manager::SLIDER, |
| 435 |
'default' => [ |
| 436 |
'size' => 10, |
| 437 |
], |
| 438 |
'range' => [ |
| 439 |
'px' => [ |
| 440 |
'min' => 0, |
| 441 |
'max' => 60, |
| 442 |
], |
| 443 |
], |
| 444 |
'selectors' => [ |
| 445 |
'{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 446 |
'{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};', |
| 447 |
], |
| 448 |
] |
| 449 |
); |
| 450 |
|
| 451 |
$this->end_controls_section(); |
| 452 |
} |
| 453 |
|
| 454 |
private function generate_controls_layout() { |
| 455 |
} |
| 456 |
|
| 457 |
private function generate_controls_styles() { |
| 458 |
$this->start_controls_section( |
| 459 |
'sstyles_thmbn_section', |
| 460 |
[ |
| 461 |
'label' => esc_html__('Main', 'wpdirectorykit'), |
| 462 |
'tab' => Controls_Manager::TAB_STYLE, |
| 463 |
] |
| 464 |
); |
| 465 |
|
| 466 |
$this->add_responsive_control( |
| 467 |
'list_gap', |
| 468 |
[ |
| 469 |
'label' => esc_html__('Rows Gap', 'wpdirectorykit'), |
| 470 |
'type' => Controls_Manager::SLIDER, |
| 471 |
'default' => [ |
| 472 |
'size' => 10, |
| 473 |
], |
| 474 |
'range' => [ |
| 475 |
'px' => [ |
| 476 |
'min' => 0, |
| 477 |
'max' => 60, |
| 478 |
], |
| 479 |
], |
| 480 |
'selectors' => [ |
| 481 |
'{{WRAPPER}} .wdk-categories .wdk-item' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 482 |
], |
| 483 |
] |
| 484 |
); |
| 485 |
|
| 486 |
$this->end_controls_section(); |
| 487 |
|
| 488 |
$items = [ |
| 489 |
[ |
| 490 |
'key'=>'title', |
| 491 |
'label'=> esc_html__('Title', 'wpdirectorykit'), |
| 492 |
'selector'=>'.title', |
| 493 |
'selector_hover'=>'.title%1$s', |
| 494 |
'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'], |
| 495 |
], |
| 496 |
[ |
| 497 |
'key'=>'item_button', |
| 498 |
'label'=> esc_html__('Item Box', 'wpdirectorykit'), |
| 499 |
'selector'=>'.wdk-categories .wdk-link', |
| 500 |
'selector_hover'=>'.wdk-categories .wdk-link%1$s', |
| 501 |
'options'=>['color','background','border','border_radius','padding','shadow','transition'], |
| 502 |
], |
| 503 |
[ |
| 504 |
'key'=>'item_icon', |
| 505 |
'label'=> esc_html__('Item Icon', 'wpdirectorykit'), |
| 506 |
'selector'=>'.wdk-categories .wdk-link i', |
| 507 |
'selector_hover'=>'.wdk-categories .wdk-link%1$s i', |
| 508 |
'options'=>['margin','color','background','border','border_radius','padding','shadow'], |
| 509 |
], |
| 510 |
[ |
| 511 |
'key'=>'category_icon', |
| 512 |
'label'=> esc_html__('Category Icon', 'wpdirectorykit'), |
| 513 |
'selector'=>'.title .wdk-icon', |
| 514 |
'selector_hover'=>'.title%1$s .wdk-icon', |
| 515 |
'options'=>['margin','color','background','border','border_radius','padding','shadow','image_size_control','image_fit_control'], |
| 516 |
], |
| 517 |
[ |
| 518 |
'key'=>'category_image', |
| 519 |
'label'=> esc_html__('Category Image', 'wpdirectorykit'), |
| 520 |
'selector'=>'.title .wdk-image', |
| 521 |
'selector_hover'=>'.title%1$s .wdk-image', |
| 522 |
'options'=>['margin','background','border','border_radius','padding','shadow','transition','image_size_control', 'css_filters','image_fit_control'], |
| 523 |
], |
| 524 |
[ |
| 525 |
'key'=>'category_font_icon', |
| 526 |
'label'=> esc_html__('Category Font Icon', 'wpdirectorykit'), |
| 527 |
'selector'=>'.title .wdk-font-icon', |
| 528 |
'selector_hover'=>'.title%1$s .wdk-font-icon', |
| 529 |
'options'=>['margin','background','border','border_radius','shadow','color','font-size','height','width'], |
| 530 |
], |
| 531 |
[ |
| 532 |
'key'=>'item_title', |
| 533 |
'label'=> esc_html__('Item Title', 'wpdirectorykit'), |
| 534 |
'selector'=>'.wdk-categories .wdk-link .wdk-title', |
| 535 |
'selector_hover'=>'.wdk-categories .wdk-link%1$s .wdk-title', |
| 536 |
'options'=>['margin','typo','color','background','border','border_radius','padding'], |
| 537 |
], |
| 538 |
[ |
| 539 |
'key'=>'item_count', |
| 540 |
'label'=> esc_html__('Item Count', 'wpdirectorykit'), |
| 541 |
'selector'=>'.wdk-categories .wdk-link .wdk-count', |
| 542 |
'selector_hover'=>'.wdk-categories .wdk-link%1$s .wdk-count', |
| 543 |
'options'=>['margin','typo','color','background','border','border_radius','padding'], |
| 544 |
], |
| 545 |
[ |
| 546 |
'key'=>'btn_more', |
| 547 |
'label'=> esc_html__('Btn More', 'wpdirectorykit'), |
| 548 |
'selector'=>'.wdk-categories-tree .btn-more', |
| 549 |
'selector_hover'=>'.wdk-categories-tree .btn-more%1$s', |
| 550 |
'options'=>['margin','typo','color','background','border','border_radius','padding'], |
| 551 |
], |
| 552 |
]; |
| 553 |
|
| 554 |
foreach ($items as $item) { |
| 555 |
if($item['key'] == 'category_icon') { |
| 556 |
$this->start_controls_section( |
| 557 |
$item['key'].'_section', |
| 558 |
[ |
| 559 |
'label' => $item['label'], |
| 560 |
'tab' => Controls_Manager::TAB_STYLE, |
| 561 |
'conditions' => [ |
| 562 |
'terms' => [ |
| 563 |
[ |
| 564 |
'name' => 'show_icon', |
| 565 |
'operator' => '==', |
| 566 |
'value' => 'yes', |
| 567 |
], |
| 568 |
[ |
| 569 |
'name' => 'layout_image_type', |
| 570 |
'operator' => '==', |
| 571 |
'value' => 'icon', |
| 572 |
] |
| 573 |
], |
| 574 |
], |
| 575 |
] |
| 576 |
); |
| 577 |
} elseif($item['key'] == 'category_image') { |
| 578 |
$this->start_controls_section( |
| 579 |
$item['key'].'_section', |
| 580 |
[ |
| 581 |
'label' => $item['label'], |
| 582 |
'tab' => Controls_Manager::TAB_STYLE, |
| 583 |
'conditions' => [ |
| 584 |
'terms' => [ |
| 585 |
[ |
| 586 |
'name' => 'show_icon', |
| 587 |
'operator' => '==', |
| 588 |
'value' => 'yes', |
| 589 |
], |
| 590 |
[ |
| 591 |
'name' => 'layout_image_type', |
| 592 |
'operator' => '==', |
| 593 |
'value' => 'image', |
| 594 |
] |
| 595 |
], |
| 596 |
], |
| 597 |
] |
| 598 |
); |
| 599 |
} elseif($item['key'] == 'category_font_icon') { |
| 600 |
$this->start_controls_section( |
| 601 |
$item['key'].'_section', |
| 602 |
[ |
| 603 |
'label' => $item['label'], |
| 604 |
'tab' => Controls_Manager::TAB_STYLE, |
| 605 |
'conditions' => [ |
| 606 |
'terms' => [ |
| 607 |
[ |
| 608 |
'name' => 'show_icon', |
| 609 |
'operator' => '==', |
| 610 |
'value' => 'yes', |
| 611 |
], |
| 612 |
[ |
| 613 |
'name' => 'layout_image_type', |
| 614 |
'operator' => '==', |
| 615 |
'value' => 'font_icon', |
| 616 |
] |
| 617 |
], |
| 618 |
], |
| 619 |
] |
| 620 |
); |
| 621 |
} else { |
| 622 |
$this->start_controls_section( |
| 623 |
$item['key'].'_section', |
| 624 |
[ |
| 625 |
'label' => $item['label'], |
| 626 |
'tab' => Controls_Manager::TAB_STYLE, |
| 627 |
] |
| 628 |
); |
| 629 |
} |
| 630 |
|
| 631 |
$this->add_responsive_control( |
| 632 |
$item['key'].'_hide', |
| 633 |
[ |
| 634 |
'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ), |
| 635 |
'type' => Controls_Manager::SWITCHER, |
| 636 |
'none' => esc_html__( 'Hide', 'wpdirectorykit' ), |
| 637 |
'block' => esc_html__( 'Show', 'wpdirectorykit' ), |
| 638 |
'return_value' => 'none', |
| 639 |
'default' => '', |
| 640 |
'selectors' => [ |
| 641 |
'{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};', |
| 642 |
], |
| 643 |
] |
| 644 |
); |
| 645 |
$selectors = array( |
| 646 |
'normal' => '{{WRAPPER}} '.$item['selector'], |
| 647 |
'hover'=>'{{WRAPPER}} '.$item['selector_hover'], |
| 648 |
); |
| 649 |
$this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']); |
| 650 |
|
| 651 |
/* special for some elements */ |
| 652 |
if($item['key'] == 'item_icon') { |
| 653 |
$this->add_control( |
| 654 |
$item['key'].'_i', |
| 655 |
[ |
| 656 |
'label' => esc_html__('Icon', 'wpdirectorykit'), |
| 657 |
'type' => Controls_Manager::ICONS, |
| 658 |
'label_block' => true, |
| 659 |
'default' => [ |
| 660 |
'value' => 'fa fa-angle-right', |
| 661 |
'library' => 'solid', |
| 662 |
], |
| 663 |
] |
| 664 |
); |
| 665 |
$this->add_responsive_control( |
| 666 |
$item['key'].'_size', |
| 667 |
[ |
| 668 |
'label' => __( 'Size', 'wpdirectorykit' ), |
| 669 |
'type' => Controls_Manager::SLIDER, |
| 670 |
'size_units' => [ 'px'], |
| 671 |
'range' => [ |
| 672 |
'px' => [ |
| 673 |
'min' => 1, |
| 674 |
'max' => 60, |
| 675 |
'step' => 1, |
| 676 |
], |
| 677 |
], |
| 678 |
'default' => [ |
| 679 |
'unit' => 'px', |
| 680 |
'size' => 14, |
| 681 |
], |
| 682 |
'selectors' => [ |
| 683 |
'{{WRAPPER}} '.$item['selector'] => 'font-size: {{SIZE}}{{UNIT}};', |
| 684 |
], |
| 685 |
] |
| 686 |
); |
| 687 |
} |
| 688 |
if($item['key'] == 'item_count') { |
| 689 |
$this->add_responsive_control( |
| 690 |
$item['key'].'_align', |
| 691 |
[ |
| 692 |
'label' => __( 'Position', 'wpdirectorykit' ), |
| 693 |
'type' => Controls_Manager::CHOOSE, |
| 694 |
'options' => [ |
| 695 |
'left' => [ |
| 696 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 697 |
'icon' => 'eicon-text-align-left', |
| 698 |
], |
| 699 |
'center' => [ |
| 700 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 701 |
'icon' => 'eicon-text-align-center', |
| 702 |
], |
| 703 |
'right' => [ |
| 704 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 705 |
'icon' => 'eicon-text-align-right', |
| 706 |
], |
| 707 |
|
| 708 |
], |
| 709 |
'render_type' => 'ui', |
| 710 |
'selectors_dictionary' => [ |
| 711 |
'left' => 'text-align: left;', |
| 712 |
'center' => 'text-alig: center;', |
| 713 |
'right' => 'text-align: right;', |
| 714 |
], |
| 715 |
'selectors' => [ |
| 716 |
'{{WRAPPER}} '.$item['selector'] => '{{VALUE}};', |
| 717 |
], |
| 718 |
] |
| 719 |
); |
| 720 |
} |
| 721 |
|
| 722 |
$this->end_controls_section(); |
| 723 |
} |
| 724 |
} |
| 725 |
|
| 726 |
private function generate_controls_content() { |
| 727 |
|
| 728 |
} |
| 729 |
|
| 730 |
public function enqueue_styles_scripts() { |
| 731 |
wp_enqueue_style('wdk-categories-tree'); |
| 732 |
} |
| 733 |
} |
| 734 |
|