theme-elements
2 years ago
accordion.php
4 years ago
audio.php
4 years ago
before-after.php
3 years ago
button.php
4 years ago
carousel-navigation.php
4 years ago
circle-chart.php
3 years ago
contact-box.php
4 years ago
contact-form.php
4 years ago
custom-list.php
4 years ago
divider.php
4 years ago
gallery.php
2 years ago
gmap.php
4 years ago
heading-modern.php
3 years ago
icon.php
3 years ago
image.php
4 years ago
mailchimp.php
4 years ago
modern-button.php
4 years ago
products-grid.php
3 years ago
quote.php
4 years ago
recent-comments.php
3 years ago
recent-posts-grid-carousel.php
4 years ago
recent-posts-land-style.php
4 years ago
recent-posts-masonry.php
4 years ago
recent-posts-tiles-carousel.php
4 years ago
recent-posts-tiles.php
4 years ago
recent-posts-timeline.php
4 years ago
recent-products.php
4 years ago
responsive-table.php
3 years ago
search.php
4 years ago
staff.php
4 years ago
svg.php
3 years ago
tabs.php
3 years ago
testimonial.php
4 years ago
text.php
4 years ago
touch-slider.php
4 years ago
video.php
4 years ago
icon.php
455 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Core\Schemes\Color; |
| 8 | |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; // Exit if accessed directly. |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Elementor icon widget. |
| 16 | * |
| 17 | * Elementor widget that displays an icon from over 600+ icons. |
| 18 | * |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | class Icon extends Widget_Base { |
| 22 | |
| 23 | /** |
| 24 | * Get widget name. |
| 25 | * |
| 26 | * Retrieve icon widget name. |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | * @access public |
| 30 | * |
| 31 | * @return string Widget name. |
| 32 | */ |
| 33 | public function get_name() { |
| 34 | return 'aux_icon'; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get widget title. |
| 39 | * |
| 40 | * Retrieve icon widget title. |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | * @access public |
| 44 | * |
| 45 | * @return string Widget title. |
| 46 | */ |
| 47 | public function get_title() { |
| 48 | return __( 'Icon Picker', 'auxin-elements' ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get widget icon. |
| 53 | * |
| 54 | * Retrieve icon widget icon. |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | * @access public |
| 58 | * |
| 59 | * @return string Widget icon. |
| 60 | */ |
| 61 | public function get_icon() { |
| 62 | return 'eicon-favorite auxin-badge'; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get widget categories. |
| 67 | * |
| 68 | * Retrieve the list of categories the icon widget belongs to. |
| 69 | * |
| 70 | * Used to determine where to display the widget in the editor. |
| 71 | * |
| 72 | * @since 2.0.0 |
| 73 | * @access public |
| 74 | * |
| 75 | * @return array Widget categories. |
| 76 | */ |
| 77 | public function get_categories() { |
| 78 | return array( 'auxin-core' ); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Get widget keywords. |
| 83 | * |
| 84 | * Retrieve the list of keywords the widget belongs to. |
| 85 | * |
| 86 | * @since 2.1.0 |
| 87 | * @access public |
| 88 | * |
| 89 | * @return array Widget keywords. |
| 90 | */ |
| 91 | public function get_keywords() { |
| 92 | return array( 'icon' ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Register icon widget controls. |
| 97 | * |
| 98 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 99 | * |
| 100 | * @since 1.0.0 |
| 101 | * @access protected |
| 102 | */ |
| 103 | protected function register_controls() { |
| 104 | $this->start_controls_section( |
| 105 | 'section_icon', |
| 106 | array( |
| 107 | 'label' => __( 'Icon', 'elementor' ), |
| 108 | ) |
| 109 | ); |
| 110 | |
| 111 | $this->add_control( |
| 112 | 'aux_new_icon', |
| 113 | array( |
| 114 | 'label' => __( 'Icon', 'elementor' ), |
| 115 | 'type' => Controls_Manager::ICONS |
| 116 | ) |
| 117 | ); |
| 118 | |
| 119 | $this->add_control( |
| 120 | 'view', |
| 121 | array( |
| 122 | 'label' => __( 'View', 'elementor' ), |
| 123 | 'type' => Controls_Manager::SELECT, |
| 124 | 'options' => array( |
| 125 | 'default' => __( 'Default', 'elementor' ), |
| 126 | 'stacked' => __( 'Stacked', 'elementor' ), |
| 127 | 'framed' => __( 'Framed', 'elementor' ), |
| 128 | ), |
| 129 | 'default' => 'default', |
| 130 | 'prefix_class' => 'elementor-view-', |
| 131 | ) |
| 132 | ); |
| 133 | |
| 134 | $this->add_control( |
| 135 | 'shape', |
| 136 | array( |
| 137 | 'label' => __( 'Shape', 'elementor' ), |
| 138 | 'type' => Controls_Manager::SELECT, |
| 139 | 'options' => array( |
| 140 | 'circle' => __( 'Circle', 'elementor' ), |
| 141 | 'square' => __( 'Square', 'elementor' ), |
| 142 | ), |
| 143 | 'default' => 'circle', |
| 144 | 'condition' => array( |
| 145 | 'view!' => 'default', |
| 146 | ), |
| 147 | 'prefix_class' => 'elementor-shape-', |
| 148 | ) |
| 149 | ); |
| 150 | |
| 151 | $this->add_control( |
| 152 | 'link', |
| 153 | array( |
| 154 | 'label' => __( 'Link', 'elementor' ), |
| 155 | 'type' => Controls_Manager::URL, |
| 156 | 'dynamic' => array( |
| 157 | 'active' => true |
| 158 | ), |
| 159 | 'placeholder' => __( 'https://your-link.com', 'elementor' ), |
| 160 | ) |
| 161 | ); |
| 162 | |
| 163 | $this->add_responsive_control( |
| 164 | 'align', |
| 165 | array( |
| 166 | 'label' => __( 'Alignment', 'elementor' ), |
| 167 | 'type' => Controls_Manager::CHOOSE, |
| 168 | 'options' => array( |
| 169 | 'left' => array( |
| 170 | 'title' => __( 'Left', 'elementor' ), |
| 171 | 'icon' => 'eicon-text-align-left', |
| 172 | ), |
| 173 | 'center' => array( |
| 174 | 'title' => __( 'Center', 'elementor' ), |
| 175 | 'icon' => 'eicon-text-align-center', |
| 176 | ), |
| 177 | 'right' => array( |
| 178 | 'title' => __( 'Right', 'elementor' ), |
| 179 | 'icon' => 'eicon-text-align-right', |
| 180 | ), |
| 181 | ), |
| 182 | 'default' => 'center', |
| 183 | 'selectors' => array( |
| 184 | '{{WRAPPER}} .elementor-icon-wrapper' => 'text-align: {{VALUE}};', |
| 185 | ), |
| 186 | ) |
| 187 | ); |
| 188 | |
| 189 | $this->end_controls_section(); |
| 190 | |
| 191 | $this->start_controls_section( |
| 192 | 'section_style_icon', |
| 193 | array( |
| 194 | 'label' => __( 'Icon', 'elementor' ), |
| 195 | 'tab' => Controls_Manager::TAB_STYLE, |
| 196 | ) |
| 197 | ); |
| 198 | |
| 199 | $this->start_controls_tabs( 'icon_colors' ); |
| 200 | |
| 201 | $this->start_controls_tab( |
| 202 | 'icon_colors_normal', |
| 203 | array( |
| 204 | 'label' => __( 'Normal', 'elementor' ), |
| 205 | ) |
| 206 | ); |
| 207 | |
| 208 | $this->add_control( |
| 209 | 'primary_color', |
| 210 | array( |
| 211 | 'label' => __( 'Primary Color', 'elementor' ), |
| 212 | 'type' => Controls_Manager::COLOR, |
| 213 | 'default' => '', |
| 214 | 'selectors' => array( |
| 215 | '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'background-color: {{VALUE}};', |
| 216 | '{{WRAPPER}}.elementor-view-framed .elementor-icon, {{WRAPPER}}.elementor-view-default .elementor-icon' => 'color: {{VALUE}}; border-color: {{VALUE}};', |
| 217 | ), |
| 218 | 'scheme' => array( |
| 219 | 'type' => Color::get_type(), |
| 220 | 'value' => Color::COLOR_1, |
| 221 | ), |
| 222 | ) |
| 223 | ); |
| 224 | |
| 225 | $this->add_control( |
| 226 | 'secondary_color', |
| 227 | array( |
| 228 | 'label' => __( 'Secondary Color', 'elementor' ), |
| 229 | 'type' => Controls_Manager::COLOR, |
| 230 | 'default' => '', |
| 231 | 'condition' => array( |
| 232 | 'view!' => 'default', |
| 233 | ), |
| 234 | 'selectors' => array( |
| 235 | '{{WRAPPER}}.elementor-view-framed .elementor-icon' => 'background-color: {{VALUE}};', |
| 236 | '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'color: {{VALUE}};', |
| 237 | ), |
| 238 | ) |
| 239 | ); |
| 240 | |
| 241 | $this->end_controls_tab(); |
| 242 | |
| 243 | $this->start_controls_tab( |
| 244 | 'icon_colors_hover', |
| 245 | array( |
| 246 | 'label' => __( 'Hover', 'elementor' ), |
| 247 | ) |
| 248 | ); |
| 249 | |
| 250 | $this->add_control( |
| 251 | 'hover_primary_color', |
| 252 | array( |
| 253 | 'label' => __( 'Primary Color', 'elementor' ), |
| 254 | 'type' => Controls_Manager::COLOR, |
| 255 | 'default' => '', |
| 256 | 'selectors' => array( |
| 257 | '{{WRAPPER}}.elementor-view-stacked .elementor-icon:hover' => 'background-color: {{VALUE}};', |
| 258 | '{{WRAPPER}}.elementor-view-framed .elementor-icon:hover, {{WRAPPER}}.elementor-view-default .elementor-icon:hover' => 'color: {{VALUE}}; border-color: {{VALUE}};', |
| 259 | ), |
| 260 | ) |
| 261 | ); |
| 262 | |
| 263 | $this->add_control( |
| 264 | 'hover_secondary_color', |
| 265 | array( |
| 266 | 'label' => __( 'Secondary Color', 'elementor' ), |
| 267 | 'type' => Controls_Manager::COLOR, |
| 268 | 'default' => '', |
| 269 | 'condition' => array( |
| 270 | 'view!' => 'default', |
| 271 | ), |
| 272 | 'selectors' => array( |
| 273 | '{{WRAPPER}}.elementor-view-framed .elementor-icon:hover' => 'background-color: {{VALUE}};', |
| 274 | '{{WRAPPER}}.elementor-view-stacked .elementor-icon:hover' => 'color: {{VALUE}};', |
| 275 | ), |
| 276 | ) |
| 277 | ); |
| 278 | |
| 279 | $this->add_control( |
| 280 | 'hover_animation', |
| 281 | array( |
| 282 | 'label' => __( 'Hover Animation', 'elementor' ), |
| 283 | 'type' => Controls_Manager::HOVER_ANIMATION, |
| 284 | ) |
| 285 | ); |
| 286 | |
| 287 | $this->end_controls_tab(); |
| 288 | |
| 289 | $this->end_controls_tabs(); |
| 290 | |
| 291 | $this->add_control( |
| 292 | 'size', |
| 293 | array( |
| 294 | 'label' => __( 'Size', 'elementor' ), |
| 295 | 'type' => Controls_Manager::SLIDER, |
| 296 | 'range' => array( |
| 297 | 'px' => array( |
| 298 | 'min' => 6, |
| 299 | 'max' => 300, |
| 300 | ), |
| 301 | ), |
| 302 | 'selectors' => array( |
| 303 | '{{WRAPPER}} .elementor-icon' => 'font-size: {{SIZE}}{{UNIT}};', |
| 304 | ), |
| 305 | ) |
| 306 | ); |
| 307 | |
| 308 | $this->add_control( |
| 309 | 'icon_padding', |
| 310 | array( |
| 311 | 'label' => __( 'Padding', 'elementor' ), |
| 312 | 'type' => Controls_Manager::SLIDER, |
| 313 | 'selectors' => array( |
| 314 | '{{WRAPPER}} .elementor-icon' => 'padding: {{SIZE}}{{UNIT}};', |
| 315 | ), |
| 316 | 'range' => array( |
| 317 | 'em' => array( |
| 318 | 'min' => 0, |
| 319 | 'max' => 5, |
| 320 | ), |
| 321 | ), |
| 322 | 'condition' => array( |
| 323 | 'view!' => 'default', |
| 324 | ), |
| 325 | ) |
| 326 | ); |
| 327 | |
| 328 | $this->add_control( |
| 329 | 'rotate', |
| 330 | array( |
| 331 | 'label' => __( 'Rotate', 'elementor' ), |
| 332 | 'type' => Controls_Manager::SLIDER, |
| 333 | 'default' => array( |
| 334 | 'size' => 0, |
| 335 | 'unit' => 'deg', |
| 336 | ), |
| 337 | 'selectors' => array( |
| 338 | '{{WRAPPER}} .elementor-icon i' => 'transform: rotate({{SIZE}}{{UNIT}});', |
| 339 | ), |
| 340 | ) |
| 341 | ); |
| 342 | |
| 343 | $this->add_control( |
| 344 | 'border_width', |
| 345 | array( |
| 346 | 'label' => __( 'Border Width', 'elementor' ), |
| 347 | 'type' => Controls_Manager::DIMENSIONS, |
| 348 | 'selectors' => array( |
| 349 | '{{WRAPPER}} .elementor-icon' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 350 | ), |
| 351 | 'condition' => array( |
| 352 | 'view' => 'framed', |
| 353 | ), |
| 354 | ) |
| 355 | ); |
| 356 | |
| 357 | $this->add_control( |
| 358 | 'border_radius', |
| 359 | array( |
| 360 | 'label' => __( 'Border Radius', 'elementor' ), |
| 361 | 'type' => Controls_Manager::DIMENSIONS, |
| 362 | 'size_units' => array( 'px', '%' ), |
| 363 | 'selectors' => array( |
| 364 | '{{WRAPPER}} .elementor-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 365 | ), |
| 366 | 'condition' => array( |
| 367 | 'view!' => 'default', |
| 368 | ), |
| 369 | ) |
| 370 | ); |
| 371 | |
| 372 | $this->end_controls_section(); |
| 373 | } |
| 374 | |
| 375 | /** |
| 376 | * Render icon widget output on the frontend. |
| 377 | * |
| 378 | * Written in PHP and used to generate the final HTML. |
| 379 | * |
| 380 | * @since 1.0.0 |
| 381 | * @access protected |
| 382 | */ |
| 383 | protected function render() { |
| 384 | $settings = $this->get_settings_for_display(); |
| 385 | |
| 386 | $this->add_render_attribute( 'wrapper', 'class', 'elementor-icon-wrapper' ); |
| 387 | |
| 388 | $this->add_render_attribute( 'icon-wrapper', 'class', 'elementor-icon' ); |
| 389 | |
| 390 | if ( ! empty( $settings['hover_animation'] ) ) { |
| 391 | $this->add_render_attribute( 'icon-wrapper', 'class', 'elementor-animation-' . $settings['hover_animation'] ); |
| 392 | } |
| 393 | |
| 394 | $icon_tag = 'div'; |
| 395 | |
| 396 | if ( ! empty( $settings['link']['url'] ) ) { |
| 397 | $this->add_render_attribute( 'icon-wrapper', 'href', $settings['link']['url'] ); |
| 398 | $icon_tag = 'a'; |
| 399 | |
| 400 | if ( ! empty( $settings['link']['is_external'] ) ) { |
| 401 | $this->add_render_attribute( 'icon-wrapper', 'target', '_blank' ); |
| 402 | } |
| 403 | |
| 404 | if ( $settings['link']['nofollow'] ) { |
| 405 | $this->add_render_attribute( 'icon-wrapper', 'rel', 'nofollow' ); |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | ?> |
| 410 | <div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>> |
| 411 | <<?php echo esc_html( $icon_tag ) . ' ' . $this->get_render_attribute_string( 'icon-wrapper' ); ?>> |
| 412 | <?php |
| 413 | if ( ! empty( $settings['aux_new_icon']['value'] ) ) { |
| 414 | \Elementor\Icons_Manager::render_icon( $settings['aux_new_icon'], [ 'aria-hidden' => 'true' ] ); |
| 415 | } else { |
| 416 | if ( ! empty( $settings['icon'] ) ) { |
| 417 | $this->add_render_attribute( 'icon', 'class', $settings['icon'] ); |
| 418 | $this->add_render_attribute( 'icon', 'aria-hidden', 'true' ); |
| 419 | ?> |
| 420 | <i <?php echo $this->get_render_attribute_string( 'icon' ); ?>></i> |
| 421 | <?php |
| 422 | } |
| 423 | } |
| 424 | ?> |
| 425 | </<?php echo esc_html( $icon_tag ); ?>> |
| 426 | </div> |
| 427 | <?php |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Render icon widget output in the editor. |
| 432 | * |
| 433 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| 434 | * |
| 435 | * @since 1.0.0 |
| 436 | * @access protected |
| 437 | */ |
| 438 | protected function content_template() { |
| 439 | ?> |
| 440 | <# var link = settings.link.url ? 'href="' + settings.link.url + '"' : '', |
| 441 | iconHTML = elementor.helpers.renderIcon( view, settings.aux_new_icon, { 'aria-hidden': true }, 'i' , 'object' ), |
| 442 | iconTag = link ? 'a' : 'div'; #> |
| 443 | <div class="elementor-icon-wrapper"> |
| 444 | <{{{ iconTag }}} class="elementor-icon elementor-animation-{{ settings.hover_animation }}" {{{ link }}}> |
| 445 | <# if ( iconHTML && iconHTML.rendered && settings.aux_new_icon.value !== '' ) { #> |
| 446 | {{{ iconHTML.value }}} |
| 447 | <# } else if ( settings.icon !== '' ) { #> |
| 448 | <i class="{{ settings.icon }}" aria-hidden="true"></i> |
| 449 | <# } #> |
| 450 | </{{{ iconTag }}}> |
| 451 | </div> |
| 452 | <?php |
| 453 | } |
| 454 | } |
| 455 |