| 1 |
<?php |
| 2 |
|
| 3 |
namespace Borderless\Widgets; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 6 |
|
| 7 |
use \Elementor\Controls_Manager; |
| 8 |
use \Elementor\Group_Control_Background; |
| 9 |
use \Elementor\Group_Control_Box_Shadow; |
| 10 |
use \Elementor\Group_Control_Typography; |
| 11 |
use \Elementor\Core\Schemes\Typography; |
| 12 |
use \Elementor\Widget_Base; |
| 13 |
|
| 14 |
class Circular_Progress_Bar extends Widget_Base { |
| 15 |
|
| 16 |
public function get_name() { |
| 17 |
return 'borderless-circular-progress-bar'; |
| 18 |
} |
| 19 |
|
| 20 |
public function get_title() { |
| 21 |
return esc_html__( 'Circular Progress Bar', 'borderless'); |
| 22 |
} |
| 23 |
|
| 24 |
public function get_icon() { |
| 25 |
return 'fa fa-newspaper'; |
| 26 |
} |
| 27 |
|
| 28 |
public function get_categories() { |
| 29 |
return [ 'borderless' ]; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_keywords() |
| 33 |
{ |
| 34 |
return [ |
| 35 |
'circular progress bar', |
| 36 |
'progress bar', |
| 37 |
'bar', |
| 38 |
'borderless', |
| 39 |
'borderless circular progress bar', |
| 40 |
'borderless progress bar', |
| 41 |
'borderless bar' |
| 42 |
]; |
| 43 |
} |
| 44 |
|
| 45 |
public function get_custom_help_url() |
| 46 |
{ |
| 47 |
return 'https://wpborderless.com/'; |
| 48 |
} |
| 49 |
|
| 50 |
protected function _register_controls() { |
| 51 |
|
| 52 |
|
| 53 |
/*-----------------------------------------------------------------------------------*/ |
| 54 |
/* *. Layout |
| 55 |
/*-----------------------------------------------------------------------------------*/ |
| 56 |
|
| 57 |
$this->start_controls_section( |
| 58 |
'borderless_section_circular_progress_bar_layout', |
| 59 |
[ |
| 60 |
'label' => esc_html__( 'Layout', 'borderless' ), |
| 61 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 62 |
] |
| 63 |
); |
| 64 |
|
| 65 |
$this->add_control( |
| 66 |
'borderless_circular_progress_bar_title', |
| 67 |
[ |
| 68 |
'label' => esc_html__( 'Title', 'borderless'), |
| 69 |
'type' => Controls_Manager::TEXT, |
| 70 |
'dynamic' => [ |
| 71 |
'active' => true, |
| 72 |
], |
| 73 |
] |
| 74 |
); |
| 75 |
|
| 76 |
$this->add_control( |
| 77 |
'borderless_circular_progress_bar_counter_value', |
| 78 |
[ |
| 79 |
'label' => esc_html__( 'Counter Value', 'borderless'), |
| 80 |
'type' => Controls_Manager::SLIDER, |
| 81 |
'size_units' => ['%'], |
| 82 |
'range' => [ |
| 83 |
'%' => [ |
| 84 |
'min' => 1, |
| 85 |
'max' => 100, |
| 86 |
], |
| 87 |
], |
| 88 |
'default' => [ |
| 89 |
'unit' => '%', |
| 90 |
'size' => 50, |
| 91 |
], |
| 92 |
'separator' => 'before', |
| 93 |
] |
| 94 |
); |
| 95 |
|
| 96 |
$this->add_control( |
| 97 |
'borderless_circular_progress_bar_animation_duration', |
| 98 |
[ |
| 99 |
'label' => __('Animation Duration', 'borderless'), |
| 100 |
'type' => Controls_Manager::SLIDER, |
| 101 |
'size_units' => ['px'], |
| 102 |
'range' => [ |
| 103 |
'px' => [ |
| 104 |
'min' => 1000, |
| 105 |
'max' => 10000, |
| 106 |
'step' => 100, |
| 107 |
], |
| 108 |
], |
| 109 |
'default' => [ |
| 110 |
'unit' => 'px', |
| 111 |
'size' => 1500, |
| 112 |
], |
| 113 |
'separator' => 'before', |
| 114 |
] |
| 115 |
); |
| 116 |
|
| 117 |
$this->end_controls_section(); |
| 118 |
|
| 119 |
|
| 120 |
/*-----------------------------------------------------------------------------------*/ |
| 121 |
/* *. Layout - Style |
| 122 |
/*-----------------------------------------------------------------------------------*/ |
| 123 |
|
| 124 |
$this->start_controls_section( |
| 125 |
'borderless_section_circular_progress_bar_styles_general', |
| 126 |
[ |
| 127 |
'label' => esc_html__( 'General', 'borderless'), |
| 128 |
'tab' => Controls_Manager::TAB_STYLE |
| 129 |
] |
| 130 |
); |
| 131 |
|
| 132 |
$this->add_control( |
| 133 |
'borderless_circular_progress_bar_alignment', |
| 134 |
[ |
| 135 |
'label' => __('Alignment', 'borderless'), |
| 136 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 137 |
'options' => [ |
| 138 |
'borderless-circular-progress-bar-alignment-left' => [ |
| 139 |
'title' => __('Left', 'borderless'), |
| 140 |
'icon' => 'fa fa-align-left', |
| 141 |
], |
| 142 |
'borderless-circular-progress-bar-alignment-center' => [ |
| 143 |
'title' => __('Center', 'borderless'), |
| 144 |
'icon' => 'fa fa-align-center', |
| 145 |
], |
| 146 |
'borderless-circular-progress-bar-alignment-right' => [ |
| 147 |
'title' => __('Right', 'borderless'), |
| 148 |
'icon' => 'fa fa-align-right', |
| 149 |
], |
| 150 |
], |
| 151 |
'default' => 'borderless-circular-progress-bar-alignment-center', |
| 152 |
] |
| 153 |
); |
| 154 |
|
| 155 |
$this->add_control( |
| 156 |
'borderless_circular_progress_bar_size', |
| 157 |
[ |
| 158 |
'label' => __('Size', 'borderless'), |
| 159 |
'type' => Controls_Manager::SLIDER, |
| 160 |
'size_units' => ['px'], |
| 161 |
'range' => [ |
| 162 |
'px' => [ |
| 163 |
'min' => 50, |
| 164 |
'max' => 500, |
| 165 |
'step' => 1, |
| 166 |
], |
| 167 |
], |
| 168 |
'default' => [ |
| 169 |
'unit' => 'px', |
| 170 |
'size' => 200, |
| 171 |
], |
| 172 |
'selectors' => [ |
| 173 |
'{{WRAPPER}} .borderless-elementor-circular-progress-bar' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 174 |
], |
| 175 |
'separator' => 'before', |
| 176 |
] |
| 177 |
); |
| 178 |
|
| 179 |
$this->add_control( |
| 180 |
'borderless_circular_progress_bar_stroke_width', |
| 181 |
[ |
| 182 |
'label' => __('Stroke Width', 'borderless'), |
| 183 |
'type' => Controls_Manager::SLIDER, |
| 184 |
'size_units' => ['px'], |
| 185 |
'range' => [ |
| 186 |
'px' => [ |
| 187 |
'min' => 0, |
| 188 |
'max' => 100, |
| 189 |
'step' => 1, |
| 190 |
], |
| 191 |
], |
| 192 |
'default' => [ |
| 193 |
'unit' => 'px', |
| 194 |
'size' => 12, |
| 195 |
], |
| 196 |
'separator' => 'before', |
| 197 |
] |
| 198 |
); |
| 199 |
|
| 200 |
$this->add_control( |
| 201 |
'borderless_circular_progress_bar_stroke_color_style', |
| 202 |
[ |
| 203 |
'label' => __( 'Stroke Color Style', 'borderless' ), |
| 204 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 205 |
'default' => 'borderless-elementor-circular-progress-bar-stroke-solid-color', |
| 206 |
'options' => [ |
| 207 |
'borderless-elementor-circular-progress-bar-stroke-solid-color' => __( 'Solid', 'borderless' ), |
| 208 |
'borderless-elementor-circular-progress-bar-stroke-gradient-color' => __( 'Gradient', 'borderless' ), |
| 209 |
], |
| 210 |
] |
| 211 |
); |
| 212 |
|
| 213 |
$this->add_control( |
| 214 |
'borderless_circular_progress_bar_stroke_color', |
| 215 |
[ |
| 216 |
'label' => __('Stroke Color', 'borderless'), |
| 217 |
'type' => Controls_Manager::COLOR, |
| 218 |
'default' => '#000', |
| 219 |
'condition' => [ |
| 220 |
'borderless_circular_progress_bar_stroke_color_style' => 'borderless-elementor-circular-progress-bar-stroke-solid-color', |
| 221 |
], |
| 222 |
] |
| 223 |
); |
| 224 |
|
| 225 |
$this->add_control( |
| 226 |
'borderless_circular_progress_bar_stroke_color_from', |
| 227 |
[ |
| 228 |
'label' => __('Stroke Color From', 'borderless'), |
| 229 |
'type' => Controls_Manager::COLOR, |
| 230 |
'default' => '#000', |
| 231 |
'condition' => [ |
| 232 |
'borderless_circular_progress_bar_stroke_color_style' => 'borderless-elementor-circular-progress-bar-stroke-gradient-color', |
| 233 |
], |
| 234 |
] |
| 235 |
); |
| 236 |
|
| 237 |
$this->add_control( |
| 238 |
'borderless_circular_progress_bar_stroke_color_to', |
| 239 |
[ |
| 240 |
'label' => __('Stroke Color To', 'borderless'), |
| 241 |
'type' => Controls_Manager::COLOR, |
| 242 |
'default' => '#000', |
| 243 |
'condition' => [ |
| 244 |
'borderless_circular_progress_bar_stroke_color_style' => 'borderless-elementor-circular-progress-bar-stroke-gradient-color', |
| 245 |
], |
| 246 |
] |
| 247 |
); |
| 248 |
|
| 249 |
$this->add_control( |
| 250 |
'borderless_circular_progress_bar_trail_width', |
| 251 |
[ |
| 252 |
'label' => __('Trail Width', 'borderless'), |
| 253 |
'type' => Controls_Manager::SLIDER, |
| 254 |
'size_units' => ['px'], |
| 255 |
'range' => [ |
| 256 |
'px' => [ |
| 257 |
'min' => 0, |
| 258 |
'max' => 100, |
| 259 |
'step' => 1, |
| 260 |
], |
| 261 |
], |
| 262 |
'default' => [ |
| 263 |
'unit' => 'px', |
| 264 |
'size' => 12, |
| 265 |
], |
| 266 |
'separator' => 'before', |
| 267 |
] |
| 268 |
); |
| 269 |
|
| 270 |
$this->add_control( |
| 271 |
'borderless_circular_progress_bar_trail_color', |
| 272 |
[ |
| 273 |
'label' => __('Trail Color', 'borderless'), |
| 274 |
'type' => Controls_Manager::COLOR, |
| 275 |
'default' => '#eee', |
| 276 |
] |
| 277 |
); |
| 278 |
|
| 279 |
$this->add_control( |
| 280 |
'borderless_circular_progress_bar_shape', |
| 281 |
[ |
| 282 |
'label' => __( 'Shape', 'borderless' ), |
| 283 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 284 |
'default' => 'borderless-elementor-circular-progress-bar--round', |
| 285 |
'options' => [ |
| 286 |
'borderless-elementor-circular-progress-bar--square' => __( 'Square', 'borderless' ), |
| 287 |
'borderless-elementor-circular-progress-bar--round' => __( 'Round', 'borderless' ), |
| 288 |
], |
| 289 |
'separator' => 'before', |
| 290 |
] |
| 291 |
); |
| 292 |
|
| 293 |
$this->add_control( |
| 294 |
'borderless_circular_progress_bar_background_color', |
| 295 |
[ |
| 296 |
'label' => __('Background Color', 'borderless'), |
| 297 |
'type' => Controls_Manager::COLOR, |
| 298 |
'default' => '#fff', |
| 299 |
'selectors' => [ |
| 300 |
'{{WRAPPER}} .borderless-elementor-circular-progress-bar' => 'background-color: {{VALUE}}', |
| 301 |
], |
| 302 |
] |
| 303 |
); |
| 304 |
|
| 305 |
$this->add_group_control( |
| 306 |
Group_Control_Box_Shadow::get_type(), |
| 307 |
[ |
| 308 |
'name' => 'borderless_circular_progress_bar_box_shadow', |
| 309 |
'label' => __('Box Shadow', 'borderless'), |
| 310 |
'selector' => '{{WRAPPER}} .borderless-elementor-circular-progress-bar', |
| 311 |
'separator' => 'before', |
| 312 |
] |
| 313 |
); |
| 314 |
|
| 315 |
$this->end_controls_section(); |
| 316 |
|
| 317 |
/*-----------------------------------------------------------------------------------*/ |
| 318 |
/* *. Typography - Style |
| 319 |
/*-----------------------------------------------------------------------------------*/ |
| 320 |
|
| 321 |
$this->start_controls_section( |
| 322 |
'borderless_section_circular_progress_bar_typography', |
| 323 |
[ |
| 324 |
'label' => __('Typography', 'borderless'), |
| 325 |
'tab' => Controls_Manager::TAB_STYLE, |
| 326 |
] |
| 327 |
); |
| 328 |
|
| 329 |
$this->add_group_control( |
| 330 |
Group_Control_Typography::get_type(), |
| 331 |
[ |
| 332 |
'name' => 'borderless_circular_progress_bar_title_typography', |
| 333 |
'label' => __('Title', 'borderless'), |
| 334 |
'scheme' => Typography::TYPOGRAPHY_1, |
| 335 |
'selector' => '{{WRAPPER}} .borderless-elementor-circular-progress-bar .progressbar-text .borderless-elementor-circular-progress-bar-title', |
| 336 |
] |
| 337 |
); |
| 338 |
|
| 339 |
$this->add_control( |
| 340 |
'borderless_circular_progress_bar_title_color', |
| 341 |
[ |
| 342 |
'label' => __('Title Color', 'borderless'), |
| 343 |
'type' => Controls_Manager::COLOR, |
| 344 |
'default' => '', |
| 345 |
'selectors' => [ |
| 346 |
'{{WRAPPER}} .borderless-elementor-circular-progress-bar .progressbar-text .borderless-elementor-circular-progress-bar-title' => 'color: {{VALUE}}', |
| 347 |
], |
| 348 |
'separator' => 'after', |
| 349 |
] |
| 350 |
); |
| 351 |
|
| 352 |
$this->add_group_control( |
| 353 |
Group_Control_Typography::get_type(), |
| 354 |
[ |
| 355 |
'name' => 'borderless_circular_progress_bar_counter_typography', |
| 356 |
'label' => __('Counter', 'borderless'), |
| 357 |
'scheme' => Typography::TYPOGRAPHY_1, |
| 358 |
'selector' => '{{WRAPPER}} .borderless-elementor-circular-progress-bar .progressbar-text .borderless-elementor-circular-progress-bar-counter-value', |
| 359 |
] |
| 360 |
); |
| 361 |
|
| 362 |
$this->add_control( |
| 363 |
'borderless_circular_progress_bar_counter_color', |
| 364 |
[ |
| 365 |
'label' => __('Counter Color', 'borderless'), |
| 366 |
'type' => Controls_Manager::COLOR, |
| 367 |
'default' => '', |
| 368 |
'separator' => 'after', |
| 369 |
] |
| 370 |
); |
| 371 |
|
| 372 |
$this->add_group_control( |
| 373 |
Group_Control_Typography::get_type(), |
| 374 |
[ |
| 375 |
'name' => 'borderless_circular_progress_bar_postfix_typography', |
| 376 |
'label' => __('Postfix', 'borderless'), |
| 377 |
'scheme' => Typography::TYPOGRAPHY_1, |
| 378 |
'selector' => '{{WRAPPER}} .borderless-elementor-circular-progress-bar-counter-postfix', |
| 379 |
] |
| 380 |
); |
| 381 |
|
| 382 |
$this->add_control( |
| 383 |
'borderless_circular_progress_bar_postfix_color', |
| 384 |
[ |
| 385 |
'label' => __('Postfix Color', 'borderless'), |
| 386 |
'type' => Controls_Manager::COLOR, |
| 387 |
'default' => '', |
| 388 |
'selectors' => [ |
| 389 |
'{{WRAPPER}} .borderless-elementor-circular-progress-bar-counter-postfix' => 'color: {{VALUE}}', |
| 390 |
], |
| 391 |
] |
| 392 |
); |
| 393 |
|
| 394 |
$this->end_controls_section(); |
| 395 |
|
| 396 |
} |
| 397 |
|
| 398 |
/*-----------------------------------------------------------------------------------*/ |
| 399 |
/* *. Render |
| 400 |
/*-----------------------------------------------------------------------------------*/ |
| 401 |
|
| 402 |
protected function render() { |
| 403 |
$settings = $this->get_settings_for_display(); |
| 404 |
|
| 405 |
if ($settings['borderless_circular_progress_bar_stroke_color_style'] == 'borderless-elementor-circular-progress-bar-stroke-solid-color' ) { |
| 406 |
$borderless_circular_progress_bar_stroke_color_style = 'stroke_color_mode="solid" stroke_color="'.$settings['borderless_circular_progress_bar_stroke_color'].'"'; |
| 407 |
|
| 408 |
} else { |
| 409 |
$borderless_circular_progress_bar_stroke_color_style = 'stroke_color_mode="gradient" stroke_color="'.$settings['borderless_circular_progress_bar_stroke_color'].'" stroke_color_from="'.$settings['borderless_circular_progress_bar_stroke_color_from'].'" stroke_color_to="'.$settings['borderless_circular_progress_bar_stroke_color_to'].'"'; |
| 410 |
} |
| 411 |
|
| 412 |
echo'<div class="borderless-elementor-circular-progress-bar-widget '.$settings['borderless_circular_progress_bar_alignment'].'"><div class="borderless-elementor-circular-progress-bar '.$settings['borderless_circular_progress_bar_shape'].'" title="'.$settings['borderless_circular_progress_bar_title'].'" counter_value="'.$settings['borderless_circular_progress_bar_counter_value']['size'].'" '.$borderless_circular_progress_bar_stroke_color_style.' trail_color="'.$settings['borderless_circular_progress_bar_trail_color'].'" counter_color="'.$settings['borderless_circular_progress_bar_counter_color'].'" stroke_width="'.$settings['borderless_circular_progress_bar_stroke_width']['size'].'" trail_width="'.$settings['borderless_circular_progress_bar_trail_width']['size'].'" animation_duration="'.$settings['borderless_circular_progress_bar_animation_duration']['size'].'"> |
| 413 |
</div></div>'; |
| 414 |
|
| 415 |
} |
| 416 |
|
| 417 |
protected function _content_template() { |
| 418 |
|
| 419 |
} |
| 420 |
|
| 421 |
|
| 422 |
} |