theme-elements
1 year ago
accordion.php
1 year ago
audio.php
4 years ago
before-after.php
3 years ago
button.php
1 year ago
carousel-navigation.php
4 years ago
circle-chart.php
1 year ago
contact-box.php
4 years ago
contact-form.php
1 year ago
custom-list.php
1 year ago
divider.php
4 years ago
gallery.php
1 year ago
gmap.php
4 years ago
heading-modern.php
1 year ago
icon.php
1 year ago
image.php
1 year ago
mailchimp.php
1 year ago
modern-button.php
1 year ago
products-grid.php
1 year ago
quote.php
1 year ago
recent-comments.php
1 year ago
recent-posts-grid-carousel.php
1 year ago
recent-posts-land-style.php
1 year ago
recent-posts-masonry.php
1 year ago
recent-posts-tiles-carousel.php
1 year ago
recent-posts-tiles.php
1 year ago
recent-posts-timeline.php
1 year ago
recent-products.php
1 year ago
responsive-table.php
1 year ago
search.php
4 years ago
staff.php
1 year ago
svg.php
1 year ago
tabs.php
1 year ago
testimonial.php
1 year ago
text.php
1 year ago
touch-slider.php
1 year ago
video.php
4 years ago
circle-chart.php
391 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Widget_Base; |
| 5 | use Elementor\Controls_Manager; |
| 6 | use Elementor\Group_Control_Typography; |
| 7 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; // Exit if accessed directly. |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Elementor 'CircleChart' widget. |
| 15 | * |
| 16 | * Elementor widget that displays an 'CircleChart' with lightbox. |
| 17 | * |
| 18 | * @since 1.0.0 |
| 19 | */ |
| 20 | class CircleChart extends Widget_Base { |
| 21 | |
| 22 | /** |
| 23 | * Get widget name. |
| 24 | * |
| 25 | * Retrieve 'CircleChart' widget name. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | * @access public |
| 29 | * |
| 30 | * @return string Widget name. |
| 31 | */ |
| 32 | public function get_name() { |
| 33 | return 'aux_circle_chart'; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get widget title. |
| 38 | * |
| 39 | * Retrieve 'CircleChart' widget title. |
| 40 | * |
| 41 | * @since 1.0.0 |
| 42 | * @access public |
| 43 | * |
| 44 | * @return string Widget title. |
| 45 | */ |
| 46 | public function get_title() { |
| 47 | return __('Circle Chart', 'auxin-elements' ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get widget icon. |
| 52 | * |
| 53 | * Retrieve 'CircleChart' widget icon. |
| 54 | * |
| 55 | * @since 1.0.0 |
| 56 | * @access public |
| 57 | * |
| 58 | * @return string Widget icon. |
| 59 | */ |
| 60 | public function get_icon() { |
| 61 | return 'eicon-counter-circle auxin-badge'; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get widget categories. |
| 66 | * |
| 67 | * Retrieve 'CircleChart' widget icon. |
| 68 | * |
| 69 | * @since 1.0.0 |
| 70 | * @access public |
| 71 | * |
| 72 | * @return string Widget icon. |
| 73 | */ |
| 74 | public function get_categories() { |
| 75 | return array( 'auxin-core' ); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Register 'CircleChart' widget controls. |
| 80 | * |
| 81 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 82 | * |
| 83 | * @since 1.0.0 |
| 84 | * @access protected |
| 85 | */ |
| 86 | protected function register_controls() { |
| 87 | |
| 88 | /*-----------------------------------------------------------------------------------*/ |
| 89 | /* Contact Info section |
| 90 | /*-----------------------------------------------------------------------------------*/ |
| 91 | |
| 92 | $this->start_controls_section( |
| 93 | 'chart_info_section', |
| 94 | array( |
| 95 | 'label' => __('Chart Info', 'auxin-elements' ) |
| 96 | ) |
| 97 | ); |
| 98 | |
| 99 | $this->add_control( |
| 100 | 'percentage', |
| 101 | array( |
| 102 | 'label' => __('Percentage','auxin-elements' ), |
| 103 | 'type' => Controls_Manager::SLIDER, |
| 104 | 'size_units' => array('%'), |
| 105 | 'range' => array( |
| 106 | '%' => array( |
| 107 | 'min' => 1, |
| 108 | 'max' => 100, |
| 109 | 'step' => 1 |
| 110 | ), |
| 111 | ), |
| 112 | 'selectors' => array( |
| 113 | '{{WRAPPER}} .aux-circle-chart-wrapper' => '--aux-chart-percentage:{{SIZE}};' |
| 114 | ), |
| 115 | 'default' => array( |
| 116 | 'size' => 20, |
| 117 | ), |
| 118 | ) |
| 119 | ); |
| 120 | |
| 121 | $this->add_control( |
| 122 | 'title', |
| 123 | array( |
| 124 | 'label' => __('Title','auxin-elements'), |
| 125 | 'type' => Controls_Manager::TEXT |
| 126 | ) |
| 127 | ); |
| 128 | |
| 129 | $this->add_control( |
| 130 | 'subtitle', |
| 131 | array( |
| 132 | 'label' => __('Subtitle','auxin-elements'), |
| 133 | 'type' => Controls_Manager::TEXT |
| 134 | ) |
| 135 | ); |
| 136 | |
| 137 | $this->add_responsive_control( |
| 138 | 'alignment', |
| 139 | array( |
| 140 | 'label' => __('Alignment', 'auxin-elements'), |
| 141 | 'type' => Controls_Manager::CHOOSE, |
| 142 | 'default' => 'center', |
| 143 | 'options' => array( |
| 144 | 'left' => array( |
| 145 | 'title' => __( 'Left', 'auxin-elements' ), |
| 146 | 'icon' => 'eicon-text-align-left', |
| 147 | ), |
| 148 | 'center' => array( |
| 149 | 'title' => __( 'Center', 'auxin-elements' ), |
| 150 | 'icon' => 'eicon-text-align-center', |
| 151 | ), |
| 152 | 'right' => array( |
| 153 | 'title' => __( 'Right', 'auxin-elements' ), |
| 154 | 'icon' => 'eicon-text-align-right', |
| 155 | ) |
| 156 | ), |
| 157 | 'selectors_dictionary' => [ |
| 158 | 'left' => '', |
| 159 | 'center' => 'text-align:center;margin-left:auto !important;margin-right:auto !important;', |
| 160 | 'right' => 'text-align:right;margin-left:auto !important;' |
| 161 | ], |
| 162 | 'selectors' => [ |
| 163 | '{{WRAPPER}} .aux-chart-title, {{WRAPPER}} .aux-circle-chart-wrapper' => '{{value}}' |
| 164 | ] |
| 165 | ) |
| 166 | ); |
| 167 | |
| 168 | $this->end_controls_section(); |
| 169 | |
| 170 | |
| 171 | /*-----------------------------------------------------------------------------------*/ |
| 172 | /* Style Tab |
| 173 | /*-----------------------------------------------------------------------------------*/ |
| 174 | |
| 175 | /* Color Section |
| 176 | /*-------------------------------------*/ |
| 177 | |
| 178 | $this->start_controls_section( |
| 179 | 'chart_style_section', |
| 180 | array( |
| 181 | 'label' => __( 'Chart Style', 'auxin-elements' ), |
| 182 | 'tab' => Controls_Manager::TAB_STYLE |
| 183 | ) |
| 184 | ); |
| 185 | |
| 186 | $this->add_responsive_control( |
| 187 | 'circle-width', |
| 188 | array( |
| 189 | 'label' => __('Chart Width','auxin-elements' ), |
| 190 | 'type' => Controls_Manager::SLIDER, |
| 191 | 'size_units' => array('px'), |
| 192 | 'range' => array( |
| 193 | 'px' => array( |
| 194 | 'min' => 1, |
| 195 | 'max' => 1000, |
| 196 | 'step' => 1 |
| 197 | ), |
| 198 | ), |
| 199 | 'default' => array( |
| 200 | 'size' => 150, |
| 201 | ), |
| 202 | 'selectors' => array( |
| 203 | '{{WRAPPER}} .aux-circle-chart-wrapper' => '--aux-chart-width:{{SIZE}}{{UNIT}};' |
| 204 | ) |
| 205 | ) |
| 206 | ); |
| 207 | |
| 208 | $this->add_responsive_control( |
| 209 | 'bg-circle-border-width', |
| 210 | array( |
| 211 | 'label' => __('Border Thickness','auxin-elements' ), |
| 212 | 'type' => Controls_Manager::SLIDER, |
| 213 | 'size_units' => array('px'), |
| 214 | 'range' => array( |
| 215 | 'px' => array( |
| 216 | 'min' => 1, |
| 217 | 'max' => 1000, |
| 218 | 'step' => 1 |
| 219 | ), |
| 220 | ), |
| 221 | 'selectors' => array( |
| 222 | '{{WRAPPER}} .aux-bg-circle' => 'border-width:{{SIZE}}{{UNIT}};', |
| 223 | '{{WRAPPER}} .aux-circle-chart-wrapper' => '--aux-chart-border-width:{{SIZE}}{{UNIT}};' |
| 224 | ) |
| 225 | ) |
| 226 | ); |
| 227 | |
| 228 | $this->add_control( |
| 229 | 'bg-circle-color', |
| 230 | [ |
| 231 | 'label' => __( 'Default Circle Color', 'auxin-elements' ), |
| 232 | 'type' => Controls_Manager::COLOR, |
| 233 | 'selectors' => [ |
| 234 | '{{WRAPPER}} .aux-bg-circle' => 'border-color: {{VALUE}};' |
| 235 | ] |
| 236 | ] |
| 237 | ); |
| 238 | |
| 239 | $this->add_control( |
| 240 | 'circle-color', |
| 241 | [ |
| 242 | 'label' => __( 'Active Circle Color', 'auxin-elements' ), |
| 243 | 'type' => Controls_Manager::COLOR, |
| 244 | 'selectors' => [ |
| 245 | '{{WRAPPER}} .aux-circle-chart-wrapper' => '--aux-chart-color: {{VALUE}};' |
| 246 | ] |
| 247 | ] |
| 248 | ); |
| 249 | |
| 250 | $this->end_controls_section(); |
| 251 | |
| 252 | $this->start_controls_section( |
| 253 | 'text_style_section', |
| 254 | array( |
| 255 | 'label' => __( 'Text Style', 'auxin-elements' ), |
| 256 | 'tab' => Controls_Manager::TAB_STYLE |
| 257 | ) |
| 258 | ); |
| 259 | |
| 260 | $this->add_control( |
| 261 | 'title_style', |
| 262 | [ |
| 263 | 'label' => esc_html__( 'Title Style', 'auxin-elements' ), |
| 264 | 'type' => Controls_Manager::HEADING, |
| 265 | 'separator' => 'before', |
| 266 | ] |
| 267 | ); |
| 268 | |
| 269 | $this->add_group_control( |
| 270 | Group_Control_Typography::get_type(), |
| 271 | array( |
| 272 | 'name' => 'title_typography', |
| 273 | 'global' => [ |
| 274 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 275 | ], |
| 276 | 'selector' => '{{WRAPPER}} .aux-chart-title' |
| 277 | ) |
| 278 | ); |
| 279 | |
| 280 | $this->add_control( |
| 281 | 'title_color', |
| 282 | array( |
| 283 | 'label' => __( 'Color', 'auxin-elements' ), |
| 284 | 'type' => Controls_Manager::COLOR, |
| 285 | 'selectors' => array( |
| 286 | '{{WRAPPER}} .aux-chart-title' => 'color: {{VALUE}};', |
| 287 | ) |
| 288 | ) |
| 289 | ); |
| 290 | |
| 291 | $this->add_control( |
| 292 | 'number_style', |
| 293 | [ |
| 294 | 'label' => esc_html__( 'Number Style', 'auxin-elements' ), |
| 295 | 'type' => Controls_Manager::HEADING, |
| 296 | 'separator' => 'before', |
| 297 | ] |
| 298 | ); |
| 299 | |
| 300 | $this->add_group_control( |
| 301 | Group_Control_Typography::get_type(), |
| 302 | array( |
| 303 | 'name' => 'number_typography', |
| 304 | 'global' => [ |
| 305 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 306 | ], |
| 307 | 'selector' => '{{WRAPPER}} .aux-number' |
| 308 | ) |
| 309 | ); |
| 310 | |
| 311 | $this->add_control( |
| 312 | 'number_color', |
| 313 | array( |
| 314 | 'label' => __( 'Color', 'auxin-elements' ), |
| 315 | 'type' => Controls_Manager::COLOR, |
| 316 | 'selectors' => array( |
| 317 | '{{WRAPPER}} .aux-number' => 'color: {{VALUE}};', |
| 318 | ) |
| 319 | ) |
| 320 | ); |
| 321 | |
| 322 | $this->add_control( |
| 323 | 'subtitle_style', |
| 324 | [ |
| 325 | 'label' => esc_html__( 'Subtitle Style', 'auxin-elements' ), |
| 326 | 'type' => Controls_Manager::HEADING, |
| 327 | 'separator' => 'before', |
| 328 | ] |
| 329 | ); |
| 330 | |
| 331 | $this->add_group_control( |
| 332 | Group_Control_Typography::get_type(), |
| 333 | array( |
| 334 | 'name' => 'subtitle_typography', |
| 335 | 'global' => [ |
| 336 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 337 | ], |
| 338 | 'selector' => '{{WRAPPER}} .aux-chart-subtitle' |
| 339 | ) |
| 340 | ); |
| 341 | |
| 342 | $this->add_control( |
| 343 | 'subtitle_color', |
| 344 | array( |
| 345 | 'label' => __( 'Color', 'auxin-elements' ), |
| 346 | 'type' => Controls_Manager::COLOR, |
| 347 | 'selectors' => array( |
| 348 | '{{WRAPPER}} .aux-chart-subtitle' => 'color: {{VALUE}};', |
| 349 | ) |
| 350 | ) |
| 351 | ); |
| 352 | |
| 353 | $this->end_controls_section(); |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Render 'CircleChart' widget output on the frontend. |
| 358 | * |
| 359 | * @access protected |
| 360 | */ |
| 361 | protected function render() { |
| 362 | |
| 363 | $settings = $this->get_settings_for_display(); |
| 364 | |
| 365 | ?> |
| 366 | <span class='aux-chart-title'><?php echo esc_html( $settings['title'] );?></span> |
| 367 | <div class="aux-circle-chart-wrapper"> |
| 368 | <div class="aux-bg-circle"></div> |
| 369 | <div class="aux-circle-chart aux-animate"> |
| 370 | <span class='aux-number'><?php echo esc_html( $settings['percentage']['size'] );?><span>%</span></span> |
| 371 | <span class="aux-chart-subtitle"><?php echo esc_html( $settings['subtitle'] );?></span> |
| 372 | </div> |
| 373 | </div> |
| 374 | <?php |
| 375 | } |
| 376 | |
| 377 | protected function content_template() { |
| 378 | ?> |
| 379 | <span class='aux-chart-title'>{{{settings.title}}}</span> |
| 380 | <div class="aux-circle-chart-wrapper"> |
| 381 | <div class="aux-bg-circle"></div> |
| 382 | <div class="aux-circle-chart aux-animate"> |
| 383 | <span class='aux-number'>{{{settings.percentage.size}}}<span>%</span></span> |
| 384 | <span class="aux-chart-subtitle">{{{settings.subtitle}}}</span> |
| 385 | </div> |
| 386 | </div> |
| 387 | <?php |
| 388 | } |
| 389 | |
| 390 | } |
| 391 |