| @@ -1,0 +1,889 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace King_Addons; | |
| 4 | + | |
| 5 | +use Elementor\Controls_Manager; | |
| 6 | +use Elementor\Icons_Manager; | |
| 7 | +use Elementor\Repeater; | |
| 8 | +use Elementor\Widget_Base; | |
| 9 | +use Elementor\Group_Control_Typography; | |
| 10 | + | |
| 11 | +if (!defined('ABSPATH')) { | |
| 12 | + exit; // Exit if accessed directly. | |
| 13 | +} | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | +class Page_List extends Widget_Base | |
| 18 | +{ | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + public function get_name(): string | |
| 23 | + { | |
| 24 | + return 'king-addons-page-list'; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public function get_title(): string | |
| 28 | + { | |
| 29 | + return esc_html__('Page List', 'king-addons'); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public function get_icon(): string | |
| 33 | + { | |
| 34 | + return 'king-addons-icon king-addons-page-list'; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public function get_style_depends(): array | |
| 38 | + { | |
| 39 | + return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-page-list-style']; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public function get_categories(): array | |
| 43 | + { | |
| 44 | + return ['king-addons']; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public function get_keywords(): array | |
| 48 | + { | |
| 49 | + return ['page-list', 'list', 'page list', 'page', 'pages', 'items', 'navigation', 'nav', | |
| 50 | + 'king addons', 'king', 'addons', 'kingaddons', 'king-addons', 'item']; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public function get_custom_help_url() | |
| 54 | + { | |
| 55 | + return 'mailto:[email protected]?subject=Bug Report - King Addons&body=Please describe the issue'; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public function add_control_title_pointer_color_hr() | |
| 59 | + { | |
| 60 | + } | |
| 61 | + | |
| 62 | + public function add_control_title_pointer() | |
| 63 | + { | |
| 64 | + } | |
| 65 | + | |
| 66 | + public function add_control_title_pointer_height() | |
| 67 | + { | |
| 68 | + } | |
| 69 | + | |
| 70 | + public function add_control_title_pointer_animation() | |
| 71 | + { | |
| 72 | + } | |
| 73 | + | |
| 74 | + protected function register_controls() | |
| 75 | + { | |
| 76 | + $this->start_controls_section( | |
| 77 | + 'section_page_list_general', | |
| 78 | + [ | |
| 79 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('General', 'king-addons'), | |
| 80 | + 'tab' => Controls_Manager::TAB_CONTENT, | |
| 81 | + ] | |
| 82 | + ); | |
| 83 | + | |
| 84 | + $this->add_control( | |
| 85 | + 'taxonomy_list_layout', | |
| 86 | + [ | |
| 87 | + 'label' => esc_html__('Select Layout', 'king-addons'), | |
| 88 | + 'type' => Controls_Manager::CHOOSE, | |
| 89 | + 'default' => 'vertical', | |
| 90 | + 'options' => [ | |
| 91 | + 'vertical' => [ | |
| 92 | + 'title' => esc_html__('Vertical', 'king-addons'), | |
| 93 | + 'icon' => 'eicon-editor-list-ul', | |
| 94 | + ], | |
| 95 | + 'horizontal' => [ | |
| 96 | + 'title' => esc_html__('Horizontal', 'king-addons'), | |
| 97 | + 'icon' => 'eicon-ellipsis-h', | |
| 98 | + ], | |
| 99 | + ], | |
| 100 | + 'prefix_class' => 'king-addons-pl-page-list-', | |
| 101 | + 'label_block' => false, | |
| 102 | + ] | |
| 103 | + ); | |
| 104 | + | |
| 105 | + $repeater = new Repeater(); | |
| 106 | + | |
| 107 | + $repeater->add_control( | |
| 108 | + 'page_list_item_type', | |
| 109 | + [ | |
| 110 | + 'label' => esc_html__('Page Type', 'king-addons'), | |
| 111 | + 'type' => Controls_Manager::SELECT, | |
| 112 | + 'label_block' => false, | |
| 113 | + 'default' => 'custom', | |
| 114 | + 'options' => [ | |
| 115 | + 'custom' => esc_html__('Custom', 'king-addons'), | |
| 116 | + 'dynamic' => esc_html__('Dynamic', 'king-addons') | |
| 117 | + ] | |
| 118 | + ] | |
| 119 | + ); | |
| 120 | + | |
| 121 | + $repeater->add_control( | |
| 122 | + 'query_page_selection', | |
| 123 | + [ | |
| 124 | + 'label' => esc_html__('Select Page', 'king-addons'), | |
| 125 | + 'type' => 'king-addons-ajax-select2', | |
| 126 | + 'options' => 'ajaxselect2/getPostsByPostType', | |
| 127 | + 'query_slug' => 'page', | |
| 128 | + 'label_block' => true, | |
| 129 | + 'condition' => [ | |
| 130 | + 'page_list_item_type' => 'dynamic' | |
| 131 | + ] | |
| 132 | + ] | |
| 133 | + ); | |
| 134 | + | |
| 135 | + $repeater->add_control( | |
| 136 | + 'page_list_item_title', | |
| 137 | + [ | |
| 138 | + 'label' => esc_html__('Title', 'king-addons'), | |
| 139 | + 'type' => Controls_Manager::TEXT, | |
| 140 | + 'dynamic' => [ | |
| 141 | + 'active' => true, | |
| 142 | + ], | |
| 143 | + 'default' => esc_html__('New Page', 'king-addons'), | |
| 144 | + 'label_block' => true, | |
| 145 | + 'separator' => 'before', | |
| 146 | + 'condition' => [ | |
| 147 | + 'page_list_item_type' => 'custom' | |
| 148 | + ] | |
| 149 | + ] | |
| 150 | + ); | |
| 151 | + | |
| 152 | + $repeater->add_control( | |
| 153 | + 'page_list_item_sub_title', | |
| 154 | + [ | |
| 155 | + 'label' => esc_html__('Sub Title', 'king-addons'), | |
| 156 | + 'label_block' => true, | |
| 157 | + 'type' => Controls_Manager::TEXT, | |
| 158 | + 'dynamic' => [ | |
| 159 | + 'active' => true, | |
| 160 | + ], | |
| 161 | + 'default' => esc_html__('New Page Sub Title', 'king-addons'), | |
| 162 | + ] | |
| 163 | + ); | |
| 164 | + | |
| 165 | + $repeater->add_control( | |
| 166 | + 'page_list_item_title_url', | |
| 167 | + [ | |
| 168 | + 'label' => esc_html__('Title Link', 'king-addons'), | |
| 169 | + 'type' => Controls_Manager::URL, | |
| 170 | + 'dynamic' => [ | |
| 171 | + 'active' => true, | |
| 172 | + ], | |
| 173 | + 'placeholder' => esc_html__('https://example.com', 'king-addons'), | |
| 174 | + 'default' => [ | |
| 175 | + 'url' => '', | |
| 176 | + 'is_external' => true, | |
| 177 | + 'nofollow' => true, | |
| 178 | + 'custom_attributes' => '', | |
| 179 | + ], | |
| 180 | + 'condition' => [ | |
| 181 | + 'page_list_item_type' => 'custom' | |
| 182 | + ], | |
| 183 | + 'label_block' => true, | |
| 184 | + ] | |
| 185 | + ); | |
| 186 | + | |
| 187 | + $repeater->add_control( | |
| 188 | + 'open_in_new_page', | |
| 189 | + [ | |
| 190 | + 'label' => esc_html__('Open In New Page', 'king-addons'), | |
| 191 | + 'type' => Controls_Manager::SWITCHER, | |
| 192 | + 'render_type' => 'template', | |
| 193 | + 'default' => 'yes', | |
| 194 | + 'separator' => 'before', | |
| 195 | + 'condition' => [ | |
| 196 | + 'page_list_item_type' => 'dynamic' | |
| 197 | + ] | |
| 198 | + ] | |
| 199 | + ); | |
| 200 | + | |
| 201 | + $repeater->add_control( | |
| 202 | + 'page_list_item_icon', | |
| 203 | + [ | |
| 204 | + 'label' => esc_html__('Select Icon', 'king-addons'), | |
| 205 | + 'type' => Controls_Manager::ICONS, | |
| 206 | + 'skin' => 'inline', | |
| 207 | + 'label_block' => false, | |
| 208 | + 'separator' => 'before', | |
| 209 | + 'exclude_inline_options' => 'svg' | |
| 210 | + ] | |
| 211 | + ); | |
| 212 | + | |
| 213 | + $repeater->add_control( | |
| 214 | + 'show_page_list_item_badge', | |
| 215 | + [ | |
| 216 | + 'label' => esc_html__('Show Badge', 'king-addons'), | |
| 217 | + 'type' => Controls_Manager::SWITCHER, | |
| 218 | + 'return_value' => 'yes', | |
| 219 | + 'label_block' => false, | |
| 220 | + 'default' => '', | |
| 221 | + 'separator' => 'before' | |
| 222 | + ] | |
| 223 | + ); | |
| 224 | + | |
| 225 | + $repeater->add_control( | |
| 226 | + 'show_page_list_item_badge_animation', | |
| 227 | + [ | |
| 228 | + 'label' => esc_html__('Enable Animation', 'king-addons'), | |
| 229 | + 'type' => Controls_Manager::SWITCHER, | |
| 230 | + 'label_block' => false, | |
| 231 | + 'condition' => [ | |
| 232 | + 'show_page_list_item_badge' => 'yes' | |
| 233 | + ] | |
| 234 | + ] | |
| 235 | + ); | |
| 236 | + | |
| 237 | + $repeater->add_control( | |
| 238 | + 'page_list_item_badge_text', [ | |
| 239 | + 'label' => esc_html__('Badge Text', 'king-addons'), | |
| 240 | + 'type' => Controls_Manager::TEXT, | |
| 241 | + 'dynamic' => [ | |
| 242 | + 'active' => true, | |
| 243 | + ], | |
| 244 | + 'default' => esc_html__('Badge', 'king-addons'), | |
| 245 | + 'condition' => [ | |
| 246 | + 'show_page_list_item_badge' => 'yes' | |
| 247 | + ] | |
| 248 | + ] | |
| 249 | + ); | |
| 250 | + | |
| 251 | + $repeater->add_control( | |
| 252 | + 'badge_bg_color', | |
| 253 | + [ | |
| 254 | + 'label' => esc_html__('Background Color', 'king-addons'), | |
| 255 | + 'type' => Controls_Manager::COLOR, | |
| 256 | + 'default' => '#5B03FF', | |
| 257 | + 'selectors' => [ | |
| 258 | + '{{WRAPPER}} {{CURRENT_ITEM}} .king-addons-pl-page-list-item-badge' => 'background-color: {{VALUE}}', | |
| 259 | + ], | |
| 260 | + 'condition' => [ | |
| 261 | + 'show_page_list_item_badge' => 'yes' | |
| 262 | + ] | |
| 263 | + ] | |
| 264 | + ); | |
| 265 | + | |
| 266 | + $this->add_control( | |
| 267 | + 'page_list', | |
| 268 | + [ | |
| 269 | + 'label' => esc_html__('Repeater List', 'king-addons'), | |
| 270 | + 'type' => Controls_Manager::REPEATER, | |
| 271 | + 'fields' => $repeater->get_controls(), | |
| 272 | + 'default' => [ | |
| 273 | + [ | |
| 274 | + 'page_list_item_title' => esc_html__('New Page 1', 'king-addons'), | |
| 275 | + 'page_list_item_sub_title' => esc_html__('First Sub Title', 'king-addons'), | |
| 276 | + ], | |
| 277 | + [ | |
| 278 | + 'page_list_item_title' => esc_html__('New Page 2', 'king-addons'), | |
| 279 | + 'page_list_item_sub_title' => esc_html__('Second Sub Title', 'king-addons'), | |
| 280 | + ], | |
| 281 | + [ | |
| 282 | + 'page_list_item_title' => esc_html__('New Page 3', 'king-addons'), | |
| 283 | + 'page_list_item_sub_title' => esc_html__('Third Sub Title', 'king-addons'), | |
| 284 | + ], | |
| 285 | + ], | |
| 286 | + 'title_field' => '{{ page_list_item_title }}', | |
| 287 | + ] | |
| 288 | + ); | |
| 289 | + | |
| 290 | + $this->end_controls_section(); | |
| 291 | + | |
| 292 | + Core::renderProFeaturesSection($this, '', Controls_Manager::RAW_HTML, 'page-list', [ | |
| 293 | + 'Underline Page Title on Hover Animations', | |
| 294 | + ]); | |
| 295 | + | |
| 296 | + $this->start_controls_section( | |
| 297 | + 'section_style_page_list_general', | |
| 298 | + [ | |
| 299 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('List Items', 'king-addons'), | |
| 300 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 301 | + 'show_label' => false, | |
| 302 | + ] | |
| 303 | + ); | |
| 304 | + | |
| 305 | + $this->add_responsive_control( | |
| 306 | + 'page_list_item_padding', | |
| 307 | + [ | |
| 308 | + 'label' => esc_html__('Padding', 'king-addons'), | |
| 309 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 310 | + 'size_units' => ['px'], | |
| 311 | + 'default' => [ | |
| 312 | + 'top' => '5', | |
| 313 | + 'right' => 0, | |
| 314 | + 'bottom' => '5', | |
| 315 | + 'left' => 0, | |
| 316 | + 'isLinked' => '' | |
| 317 | + ], | |
| 318 | + 'selectors' => [ | |
| 319 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 320 | + ] | |
| 321 | + ] | |
| 322 | + ); | |
| 323 | + | |
| 324 | + $this->add_responsive_control( | |
| 325 | + 'page_list_item_margin', | |
| 326 | + [ | |
| 327 | + 'label' => esc_html__('Margin', 'king-addons'), | |
| 328 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 329 | + 'size_units' => ['px'], | |
| 330 | + 'default' => [ | |
| 331 | + 'top' => '5', | |
| 332 | + 'right' => '8', | |
| 333 | + 'bottom' => 0, | |
| 334 | + 'left' => 0, | |
| 335 | + 'unit' => 'px', | |
| 336 | + 'isLinked' => false | |
| 337 | + ], | |
| 338 | + 'selectors' => [ | |
| 339 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 340 | + ], | |
| 341 | + ] | |
| 342 | + ); | |
| 343 | + | |
| 344 | + $this->add_control( | |
| 345 | + 'page_list_item_border_type', | |
| 346 | + [ | |
| 347 | + 'label' => esc_html__('Border Type', 'king-addons'), | |
| 348 | + 'type' => Controls_Manager::SELECT, | |
| 349 | + 'options' => [ | |
| 350 | + 'none' => esc_html__('None', 'king-addons'), | |
| 351 | + 'solid' => esc_html__('Solid', 'king-addons'), | |
| 352 | + 'double' => esc_html__('Double', 'king-addons'), | |
| 353 | + 'dotted' => esc_html__('Dotted', 'king-addons'), | |
| 354 | + 'dashed' => esc_html__('Dashed', 'king-addons'), | |
| 355 | + 'groove' => esc_html__('Groove', 'king-addons'), | |
| 356 | + ], | |
| 357 | + 'default' => 'solid', | |
| 358 | + 'selectors' => [ | |
| 359 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'border-style: {{VALUE}};', | |
| 360 | + ], | |
| 361 | + 'separator' => 'before', | |
| 362 | + ] | |
| 363 | + ); | |
| 364 | + | |
| 365 | + $this->add_control( | |
| 366 | + 'page_list_item_border_width', | |
| 367 | + [ | |
| 368 | + 'label' => esc_html__('Border Width', 'king-addons'), | |
| 369 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 370 | + 'size_units' => ['px'], | |
| 371 | + 'default' => [ | |
| 372 | + 'top' => 0, | |
| 373 | + 'right' => 0, | |
| 374 | + 'bottom' => 1, | |
| 375 | + 'left' => 0, | |
| 376 | + ], | |
| 377 | + 'selectors' => [ | |
| 378 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 379 | + ], | |
| 380 | + 'condition' => [ | |
| 381 | + 'page_list_item_border_type!' => 'none', | |
| 382 | + ], | |
| 383 | + ] | |
| 384 | + ); | |
| 385 | + | |
| 386 | + $this->add_control( | |
| 387 | + 'page_list_item_radius', | |
| 388 | + [ | |
| 389 | + 'label' => esc_html__('Border Radius', 'king-addons'), | |
| 390 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 391 | + 'size_units' => ['px', '%'], | |
| 392 | + 'default' => [ | |
| 393 | + 'top' => 0, | |
| 394 | + 'right' => 0, | |
| 395 | + 'bottom' => 0, | |
| 396 | + 'left' => 0, | |
| 397 | + ], | |
| 398 | + 'selectors' => [ | |
| 399 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 400 | + ] | |
| 401 | + ] | |
| 402 | + ); | |
| 403 | + | |
| 404 | + $this->end_controls_section(); | |
| 405 | + | |
| 406 | + $this->start_controls_section( | |
| 407 | + 'section_style_page_list_title', | |
| 408 | + [ | |
| 409 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Title', 'king-addons'), | |
| 410 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 411 | + 'show_label' => false, | |
| 412 | + ] | |
| 413 | + ); | |
| 414 | + | |
| 415 | + $this->start_controls_tabs('list_item_style'); | |
| 416 | + | |
| 417 | + $this->start_controls_tab( | |
| 418 | + 'page_list_item_normal', | |
| 419 | + [ | |
| 420 | + 'label' => esc_html__('Normal', 'king-addons'), | |
| 421 | + ] | |
| 422 | + ); | |
| 423 | + | |
| 424 | + $this->add_control( | |
| 425 | + 'page_list_item_title_color', | |
| 426 | + [ | |
| 427 | + 'label' => esc_html__('Title Color', 'king-addons'), | |
| 428 | + 'type' => Controls_Manager::COLOR, | |
| 429 | + 'default' => '#5B03FF', | |
| 430 | + 'selectors' => [ | |
| 431 | + '{{WRAPPER}} .king-addons-pl-page-list-item a' => 'color: {{VALUE}}', | |
| 432 | + ], | |
| 433 | + ] | |
| 434 | + ); | |
| 435 | + | |
| 436 | + $this->add_control( | |
| 437 | + 'page_list_item_border_color', | |
| 438 | + [ | |
| 439 | + 'label' => esc_html__('Border Color', 'king-addons'), | |
| 440 | + 'type' => Controls_Manager::COLOR, | |
| 441 | + 'default' => '#E8E8E8', | |
| 442 | + 'selectors' => [ | |
| 443 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'border-color: {{VALUE}}', | |
| 444 | + ] | |
| 445 | + ] | |
| 446 | + ); | |
| 447 | + | |
| 448 | + $this->add_control( | |
| 449 | + 'page_list_item_transition_duration', | |
| 450 | + [ | |
| 451 | + 'label' => esc_html__('Transition Duration (ms)', 'king-addons'), | |
| 452 | + 'type' => Controls_Manager::NUMBER, | |
| 453 | + 'default' => 300, | |
| 454 | + 'min' => 0, | |
| 455 | + 'step' => 10, | |
| 456 | + 'selectors' => [ | |
| 457 | + '{{WRAPPER}} .king-addons-pl-page-list-item' => 'transition-duration: {{VALUE}}ms', | |
| 458 | + '{{WRAPPER}} .king-addons-pl-page-list-item a' => 'transition-duration: {{VALUE}}ms' | |
| 459 | + ] | |
| 460 | + ] | |
| 461 | + ); | |
| 462 | + | |
| 463 | + $this->add_group_control( | |
| 464 | + Group_Control_Typography::get_type(), | |
| 465 | + [ | |
| 466 | + 'name' => 'page_list_item_title_typo', | |
| 467 | + 'selector' => '{{WRAPPER}} .king-addons-pl-page-list-item a', | |
| 468 | + 'fields_options' => [ | |
| 469 | + 'typography' => [ | |
| 470 | + 'default' => 'custom', | |
| 471 | + ], | |
| 472 | + 'font_size' => [ | |
| 473 | + 'default' => [ | |
| 474 | + 'size' => '14', | |
| 475 | + 'unit' => 'px', | |
| 476 | + ], | |
| 477 | + ], | |
| 478 | + 'line_height' => [ | |
| 479 | + 'default' => [ | |
| 480 | + 'size' => '0.8', | |
| 481 | + 'unit' => 'em', | |
| 482 | + ] | |
| 483 | + ], | |
| 484 | + ] | |
| 485 | + ] | |
| 486 | + ); | |
| 487 | + | |
| 488 | + $this->end_controls_tab(); | |
| 489 | + | |
| 490 | + $this->start_controls_tab( | |
| 491 | + 'page_list_item_hover', | |
| 492 | + [ | |
| 493 | + 'label' => esc_html__('Hover', 'king-addons'), | |
| 494 | + ] | |
| 495 | + ); | |
| 496 | + | |
| 497 | + $this->add_control( | |
| 498 | + 'page_list_item_title_color_hr', | |
| 499 | + [ | |
| 500 | + 'label' => esc_html__('Title Color', 'king-addons'), | |
| 501 | + 'type' => Controls_Manager::COLOR, | |
| 502 | + 'default' => '#5B03FF', | |
| 503 | + 'selectors' => [ | |
| 504 | + '{{WRAPPER}} .king-addons-pl-page-list-item a:hover' => 'color: {{VALUE}}', | |
| 505 | + '{{WRAPPER}} li.king-addons-pl-page-list-item a:hover' => 'color: {{VALUE}}', | |
| 506 | + ], | |
| 507 | + ] | |
| 508 | + ); | |
| 509 | + | |
| 510 | + $this->add_control_title_pointer_color_hr(); | |
| 511 | + | |
| 512 | + $this->end_controls_tab(); | |
| 513 | + | |
| 514 | + $this->end_controls_tabs(); | |
| 515 | + | |
| 516 | + $this->add_control_title_pointer(); | |
| 517 | + | |
| 518 | + $this->add_control_title_pointer_animation(); | |
| 519 | + | |
| 520 | + $this->add_control_title_pointer_height(); | |
| 521 | + | |
| 522 | + $this->add_responsive_control( | |
| 523 | + 'title_distance', | |
| 524 | + [ | |
| 525 | + 'label' => esc_html__('Bottom Distance', 'king-addons'), | |
| 526 | + 'type' => Controls_Manager::SLIDER, | |
| 527 | + 'size_units' => ['px'], | |
| 528 | + 'range' => [ | |
| 529 | + 'px' => [ | |
| 530 | + 'min' => 0, | |
| 531 | + 'max' => 50, | |
| 532 | + ], | |
| 533 | + ], | |
| 534 | + 'default' => [ | |
| 535 | + 'unit' => 'px', | |
| 536 | + 'size' => 8, | |
| 537 | + ], | |
| 538 | + 'selectors' => [ | |
| 539 | + '{{WRAPPER}} .king-addons-pl-page-list-item div a' => 'margin-bottom: {{SIZE}}{{UNIT}};', | |
| 540 | + ], | |
| 541 | + 'separator' => 'before' | |
| 542 | + ] | |
| 543 | + ); | |
| 544 | + | |
| 545 | + $this->end_controls_section(); | |
| 546 | + | |
| 547 | + | |
| 548 | + $this->start_controls_section( | |
| 549 | + 'section_style_sub_title', | |
| 550 | + [ | |
| 551 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Sub Title', 'king-addons'), | |
| 552 | + 'tab' => Controls_Manager::TAB_STYLE | |
| 553 | + ] | |
| 554 | + ); | |
| 555 | + | |
| 556 | + $this->add_control( | |
| 557 | + 'page_list_item_sub_title_color', | |
| 558 | + [ | |
| 559 | + 'label' => esc_html__('Sub Title Color', 'king-addons'), | |
| 560 | + 'type' => Controls_Manager::COLOR, | |
| 561 | + 'default' => '#B6B6B6', | |
| 562 | + 'selectors' => [ | |
| 563 | + '{{WRAPPER}} .king-addons-pl-page-list-item p' => 'color: {{VALUE}}', | |
| 564 | + ], | |
| 565 | + ] | |
| 566 | + ); | |
| 567 | + | |
| 568 | + $this->add_group_control( | |
| 569 | + Group_Control_Typography::get_type(), | |
| 570 | + [ | |
| 571 | + 'name' => 'page_list_item_sub_title_typo', | |
| 572 | + 'selector' => '{{WRAPPER}} .king-addons-pl-page-list-item p', | |
| 573 | + 'fields_options' => [ | |
| 574 | + 'typography' => [ | |
| 575 | + 'default' => 'custom', | |
| 576 | + ], | |
| 577 | + 'font_size' => [ | |
| 578 | + 'default' => [ | |
| 579 | + 'size' => '12', | |
| 580 | + 'unit' => 'px', | |
| 581 | + ], | |
| 582 | + ], | |
| 583 | + 'line_height' => [ | |
| 584 | + 'default' => [ | |
| 585 | + 'size' => '0.8', | |
| 586 | + 'unit' => 'em', | |
| 587 | + ] | |
| 588 | + ] | |
| 589 | + ] | |
| 590 | + ] | |
| 591 | + ); | |
| 592 | + | |
| 593 | + $this->end_controls_section(); | |
| 594 | + | |
| 595 | + $this->start_controls_section( | |
| 596 | + 'section_style_badge', | |
| 597 | + [ | |
| 598 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Badge', 'king-addons'), | |
| 599 | + 'tab' => Controls_Manager::TAB_STYLE | |
| 600 | + ] | |
| 601 | + ); | |
| 602 | + | |
| 603 | + $this->add_control( | |
| 604 | + 'badge_color', | |
| 605 | + [ | |
| 606 | + 'label' => esc_html__('Color', 'king-addons'), | |
| 607 | + 'type' => Controls_Manager::COLOR, | |
| 608 | + 'default' => '#FFFFFF', | |
| 609 | + 'selectors' => [ | |
| 610 | + '{{WRAPPER}} .king-addons-pl-page-list-item-badge' => 'color: {{VALUE}}', | |
| 611 | + ], | |
| 612 | + ] | |
| 613 | + ); | |
| 614 | + | |
| 615 | + $this->add_control( | |
| 616 | + 'badge_bg_color', | |
| 617 | + [ | |
| 618 | + 'label' => esc_html__('Background Color', 'king-addons'), | |
| 619 | + 'type' => Controls_Manager::COLOR, | |
| 620 | + 'default' => '#5B03FF', | |
| 621 | + 'selectors' => [ | |
| 622 | + '{{WRAPPER}} .king-addons-pl-page-list-item-badge' => 'background-color: {{VALUE}}', | |
| 623 | + ], | |
| 624 | + ] | |
| 625 | + ); | |
| 626 | + | |
| 627 | + $this->add_control( | |
| 628 | + 'badge_vertical_align', | |
| 629 | + [ | |
| 630 | + 'label' => esc_html__('Vertical Align', 'king-addons'), | |
| 631 | + 'type' => Controls_Manager::CHOOSE, | |
| 632 | + 'label_block' => false, | |
| 633 | + 'default' => 'center', | |
| 634 | + 'options' => [ | |
| 635 | + 'top' => [ | |
| 636 | + 'title' => esc_html__('Top', 'king-addons'), | |
| 637 | + 'icon' => 'eicon-v-align-top', | |
| 638 | + ], | |
| 639 | + 'center' => [ | |
| 640 | + 'title' => esc_html__('Middle', 'king-addons'), | |
| 641 | + 'icon' => 'eicon-v-align-middle', | |
| 642 | + ], | |
| 643 | + 'bottom' => [ | |
| 644 | + 'title' => esc_html__('Bottom', 'king-addons'), | |
| 645 | + 'icon' => 'eicon-v-align-bottom', | |
| 646 | + ] | |
| 647 | + ], | |
| 648 | + 'prefix_class' => 'king-addons-pl-pl-badge-', | |
| 649 | + 'render_type' => 'template', | |
| 650 | + 'separator' => 'before' | |
| 651 | + ] | |
| 652 | + ); | |
| 653 | + | |
| 654 | + $this->add_responsive_control( | |
| 655 | + 'badge_size', | |
| 656 | + [ | |
| 657 | + 'label' => esc_html__('Size', 'king-addons'), | |
| 658 | + 'type' => Controls_Manager::SLIDER, | |
| 659 | + 'size_units' => ['px'], | |
| 660 | + 'range' => [ | |
| 661 | + 'px' => [ | |
| 662 | + 'min' => 0, | |
| 663 | + 'max' => 50, | |
| 664 | + ], | |
| 665 | + ], | |
| 666 | + 'default' => [ | |
| 667 | + 'unit' => 'px', | |
| 668 | + 'size' => 12, | |
| 669 | + ], | |
| 670 | + 'selectors' => [ | |
| 671 | + '{{WRAPPER}} .king-addons-pl-page-list-item-badge' => 'font-size: {{SIZE}}{{UNIT}};', | |
| 672 | + ], | |
| 673 | + 'separator' => 'before' | |
| 674 | + ] | |
| 675 | + ); | |
| 676 | + | |
| 677 | + $this->add_responsive_control( | |
| 678 | + 'badge_distance', | |
| 679 | + [ | |
| 680 | + 'label' => esc_html__('Space (px)', 'king-addons'), | |
| 681 | + 'type' => Controls_Manager::SLIDER, | |
| 682 | + 'size_units' => ['px'], | |
| 683 | + 'range' => [ | |
| 684 | + 'px' => [ | |
| 685 | + 'min' => 0, | |
| 686 | + 'max' => 50, | |
| 687 | + ], | |
| 688 | + ], | |
| 689 | + 'default' => [ | |
| 690 | + 'unit' => 'px', | |
| 691 | + 'size' => 5, | |
| 692 | + ], | |
| 693 | + 'selectors' => [ | |
| 694 | + '{{WRAPPER}} .king-addons-pl-page-list-item-badge' => 'margin-left: {{SIZE}}{{UNIT}};', | |
| 695 | + ], | |
| 696 | + ] | |
| 697 | + ); | |
| 698 | + | |
| 699 | + $this->add_control( | |
| 700 | + 'badge_border_padding', | |
| 701 | + [ | |
| 702 | + 'label' => esc_html__('Padding', 'king-addons'), | |
| 703 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 704 | + 'size_units' => ['px', '%'], | |
| 705 | + 'default' => [ | |
| 706 | + 'top' => 2, | |
| 707 | + 'right' => 5, | |
| 708 | + 'bottom' => 2, | |
| 709 | + 'left' => 5, | |
| 710 | + ], | |
| 711 | + 'selectors' => [ | |
| 712 | + '{{WRAPPER}} .king-addons-pl-page-list-item-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 713 | + ] | |
| 714 | + ] | |
| 715 | + ); | |
| 716 | + | |
| 717 | + $this->add_control( | |
| 718 | + 'badge_border_radius', | |
| 719 | + [ | |
| 720 | + 'label' => esc_html__('Border Radius', 'king-addons'), | |
| 721 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 722 | + 'size_units' => ['px', '%'], | |
| 723 | + 'default' => [ | |
| 724 | + 'top' => 0, | |
| 725 | + 'right' => 0, | |
| 726 | + 'bottom' => 0, | |
| 727 | + 'left' => 0, | |
| 728 | + ], | |
| 729 | + 'selectors' => [ | |
| 730 | + '{{WRAPPER}} .king-addons-pl-page-list-item-badge' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 731 | + ] | |
| 732 | + ] | |
| 733 | + ); | |
| 734 | + | |
| 735 | + $this->end_controls_section(); | |
| 736 | + | |
| 737 | + $this->start_controls_section( | |
| 738 | + 'section_style_icon', | |
| 739 | + [ | |
| 740 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Icon', 'king-addons'), | |
| 741 | + 'tab' => Controls_Manager::TAB_STYLE | |
| 742 | + ] | |
| 743 | + ); | |
| 744 | + | |
| 745 | + $this->add_control( | |
| 746 | + 'icon_color', | |
| 747 | + [ | |
| 748 | + 'label' => esc_html__('Color', 'king-addons'), | |
| 749 | + 'type' => Controls_Manager::COLOR, | |
| 750 | + 'default' => '#5B03FF', | |
| 751 | + 'selectors' => [ | |
| 752 | + '{{WRAPPER}} .king-addons-pl-page-list i' => 'color: {{VALUE}}', | |
| 753 | + '{{WRAPPER}} .king-addons-pl-page-list svg' => 'fill: {{VALUE}}' | |
| 754 | + ], | |
| 755 | + ] | |
| 756 | + ); | |
| 757 | + | |
| 758 | + $this->add_control( | |
| 759 | + 'icon_vertical_align', | |
| 760 | + [ | |
| 761 | + 'label' => esc_html__('Vertical Align', 'king-addons'), | |
| 762 | + 'type' => Controls_Manager::CHOOSE, | |
| 763 | + 'label_block' => false, | |
| 764 | + 'default' => 'center', | |
| 765 | + 'options' => [ | |
| 766 | + 'top' => [ | |
| 767 | + 'title' => esc_html__('Top', 'king-addons'), | |
| 768 | + 'icon' => 'eicon-v-align-top', | |
| 769 | + ], | |
| 770 | + 'center' => [ | |
| 771 | + 'title' => esc_html__('Middle', 'king-addons'), | |
| 772 | + 'icon' => 'eicon-v-align-middle', | |
| 773 | + ], | |
| 774 | + 'bottom' => [ | |
| 775 | + 'title' => esc_html__('Bottom', 'king-addons'), | |
| 776 | + 'icon' => 'eicon-v-align-bottom', | |
| 777 | + ] | |
| 778 | + ], | |
| 779 | + 'prefix_class' => 'king-addons-pl-pl-icon-', | |
| 780 | + 'render_type' => 'template', | |
| 781 | + 'separator' => 'before' | |
| 782 | + ] | |
| 783 | + ); | |
| 784 | + | |
| 785 | + $this->add_responsive_control( | |
| 786 | + 'icon_size', | |
| 787 | + [ | |
| 788 | + 'label' => esc_html__('Size', 'king-addons'), | |
| 789 | + 'type' => Controls_Manager::SLIDER, | |
| 790 | + 'size_units' => ['px'], | |
| 791 | + 'range' => [ | |
| 792 | + 'px' => [ | |
| 793 | + 'min' => 0, | |
| 794 | + 'max' => 50, | |
| 795 | + ], | |
| 796 | + ], | |
| 797 | + 'default' => [ | |
| 798 | + 'unit' => 'px', | |
| 799 | + 'size' => 15, | |
| 800 | + ], | |
| 801 | + 'selectors' => [ | |
| 802 | + '{{WRAPPER}} .king-addons-pl-page-list i' => 'font-size: {{SIZE}}{{UNIT}}; max-height: {{SIZE}}{{UNIT}};', | |
| 803 | + '{{WRAPPER}} .king-addons-pl-page-list svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', | |
| 804 | + '{{WRAPPER}} .king-addons-pl-page-list i:before' => 'max-height: {{SIZE}}{{UNIT}};', | |
| 805 | + '{{WRAPPER}} .king-addons-pl-page-list-item-icon' => 'max-height: {{SIZE}}{{UNIT}};', | |
| 806 | + ], | |
| 807 | + 'separator' => 'before' | |
| 808 | + ] | |
| 809 | + ); | |
| 810 | + | |
| 811 | + $this->add_responsive_control( | |
| 812 | + 'icon_distance', | |
| 813 | + [ | |
| 814 | + 'label' => esc_html__('Space (px)', 'king-addons'), | |
| 815 | + 'type' => Controls_Manager::SLIDER, | |
| 816 | + 'size_units' => ['px'], | |
| 817 | + 'range' => [ | |
| 818 | + 'px' => [ | |
| 819 | + 'min' => 0, | |
| 820 | + 'max' => 50, | |
| 821 | + ], | |
| 822 | + ], | |
| 823 | + 'default' => [ | |
| 824 | + 'unit' => 'px', | |
| 825 | + 'size' => 5, | |
| 826 | + ], | |
| 827 | + 'selectors' => [ | |
| 828 | + '{{WRAPPER}} .king-addons-pl-page-list .king-addons-pl-page-list-item-icon' => 'margin-right: {{SIZE}}{{UNIT}};', | |
| 829 | + ], | |
| 830 | + ] | |
| 831 | + ); | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | +$this->end_controls_section(); | |
| 837 | + | |
| 838 | + | |
| 839 | + } | |
| 840 | + | |
| 841 | + protected function render() | |
| 842 | + { | |
| 843 | + $settings = $this->get_settings_for_display(); | |
| 844 | + | |
| 845 | + $class = ' king-addons-pl-pointer-' . | |
| 846 | + (!king_addons_freemius()->can_use_premium_code__premium_only() ? 'none' : $settings['title_pointer']) . | |
| 847 | + ' king-addons-pl-pointer-line-anim king-addons-pl-pointer-anim-' . | |
| 848 | + (!king_addons_freemius()->can_use_premium_code__premium_only() ? 'fade' : $settings['title_pointer_animation']); | |
| 849 | + | |
| 850 | + $pointer_item_class = isset($settings['title_pointer']) && 'none' !== $settings['title_pointer'] | |
| 851 | + ? 'king-addons-pl-pointer-item' | |
| 852 | + : 'king-addons-pl-no-pointer'; | |
| 853 | + | |
| 854 | + echo '<div class="king-addons-pl-page-list-wrap"><ul class="king-addons-pl-page-list">'; | |
| 855 | + | |
| 856 | + foreach ($settings['page_list'] as $key => $item) { | |
| 857 | + $target = $item['open_in_new_page'] === 'yes' ? '_blank' : '_self'; | |
| 858 | + $badge_anim_class = $item['show_page_list_item_badge_animation'] === 'yes' ? ' king-addons-pl-pl-badge-anim-yes' : ''; | |
| 859 | + $this->add_render_attribute('page_list_item' . $key, 'class', 'king-addons-pl-page-list-item elementor-repeater-item-' . $item['_id'] . $class . $badge_anim_class); | |
| 860 | + | |
| 861 | + $icon = ''; | |
| 862 | + if (!empty($item['page_list_item_icon']['value'])) { | |
| 863 | + ob_start(); | |
| 864 | + Icons_Manager::render_icon($item['page_list_item_icon'], ['aria-hidden' => 'true']); | |
| 865 | + $icon = ob_get_clean(); | |
| 866 | + } | |
| 867 | + | |
| 868 | + $link_content = !empty($icon) ? '<span class="king-addons-pl-page-list-item-icon">' . $icon . '</span>' : ''; | |
| 869 | + $link_content .= '<div><a class="' . $pointer_item_class . '" href="' . | |
| 870 | + ($item['page_list_item_type'] === 'dynamic' ? get_the_permalink($item['query_page_selection']) : '#') . | |
| 871 | + '" target="' . $target . '">' . | |
| 872 | + ($item['page_list_item_type'] === 'dynamic' ? get_the_title($item['query_page_selection']) : $item['page_list_item_title']) . | |
| 873 | + '</a>'; | |
| 874 | + if (!empty($item['page_list_item_sub_title'])) { | |
| 875 | + $link_content .= '<p>' . $item['page_list_item_sub_title'] . '</p>'; | |
| 876 | + } | |
| 877 | + $link_content .= '</div>'; | |
| 878 | + | |
| 879 | + echo '<li ' . $this->get_render_attribute_string('page_list_item' . $key) . '>'; | |
| 880 | + echo $link_content; | |
| 881 | + if ($item['show_page_list_item_badge'] === 'yes') { | |
| 882 | + echo '<span class="king-addons-pl-page-list-item-badge">' . $item['page_list_item_badge_text'] . '</span>'; | |
| 883 | + } | |
| 884 | + echo '</li>'; | |
| 885 | + } | |
| 886 | + | |
| 887 | + echo '</ul></div>'; | |
| 888 | + } | |
| 889 | +} | |