| @@ -41,9 +41,9 @@ | ||
| 41 | 41 | * |
| 42 | 42 | * @return string Widget title. |
| 43 | 43 | */ |
| 44 | 44 | public function get_title() { |
| 45 | - return esc_html__( 'Progress Bar', 'elementor' ); | |
| 45 | + return __( 'Progress Bar', 'elementor' ); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Get widget icon. |
| @@ -72,31 +72,9 @@ | ||
| 72 | 72 | public function get_keywords() { |
| 73 | 73 | return [ 'progress', 'bar' ]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - protected function is_dynamic_content(): bool { | |
| 77 | - return false; | |
| 78 | - } | |
| 79 | - | |
| 80 | 76 | /** |
| 81 | - * Get style dependencies. | |
| 82 | - * | |
| 83 | - * Retrieve the list of style dependencies the widget requires. | |
| 84 | - * | |
| 85 | - * @since 3.24.0 | |
| 86 | - * @access public | |
| 87 | - * | |
| 88 | - * @return array Widget style dependencies. | |
| 89 | - */ | |
| 90 | - public function get_style_depends(): array { | |
| 91 | - return [ 'widget-progress' ]; | |
| 92 | - } | |
| 93 | - | |
| 94 | - public function has_widget_inner_wrapper(): bool { | |
| 95 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | 77 | * Register progress widget controls. |
| 100 | 78 | * |
| 101 | 79 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 102 | 80 | * |
| @@ -106,9 +84,9 @@ | ||
| 106 | 84 | protected function register_controls() { |
| 107 | 85 | $this->start_controls_section( |
| 108 | 86 | 'section_progress', |
| 109 | 87 | [ |
| 110 | - 'label' => esc_html__( 'Progress Bar', 'elementor' ), | |
| 88 | + 'label' => __( 'Progress Bar', 'elementor' ), | |
| 111 | 89 | ] |
| 112 | 90 | ); |
| 113 | 91 | |
| 114 | 92 | $this->add_control( |
| @@ -113,73 +91,32 @@ | ||
| 113 | 91 | |
| 114 | 92 | $this->add_control( |
| 115 | 93 | 'title', |
| 116 | 94 | [ |
| 117 | - 'label' => esc_html__( 'Title', 'elementor' ), | |
| 95 | + 'label' => __( 'Title', 'elementor' ), | |
| 118 | 96 | 'type' => Controls_Manager::TEXT, |
| 119 | 97 | 'dynamic' => [ |
| 120 | 98 | 'active' => true, |
| 121 | 99 | ], |
| 122 | - 'placeholder' => esc_html__( 'Enter your title', 'elementor' ), | |
| 123 | - 'default' => esc_html__( 'My Skill', 'elementor' ), | |
| 100 | + 'placeholder' => __( 'Enter your title', 'elementor' ), | |
| 101 | + 'default' => __( 'My Skill', 'elementor' ), | |
| 124 | 102 | 'label_block' => true, |
| 125 | 103 | ] |
| 126 | 104 | ); |
| 127 | 105 | |
| 128 | 106 | $this->add_control( |
| 129 | - 'title_tag', | |
| 130 | - [ | |
| 131 | - 'label' => esc_html__( 'Title HTML Tag', 'elementor' ), | |
| 132 | - 'type' => Controls_Manager::SELECT, | |
| 133 | - 'options' => [ | |
| 134 | - 'h1' => 'H1', | |
| 135 | - 'h2' => 'H2', | |
| 136 | - 'h3' => 'H3', | |
| 137 | - 'h4' => 'H4', | |
| 138 | - 'h5' => 'H5', | |
| 139 | - 'h6' => 'H6', | |
| 140 | - 'div' => 'div', | |
| 141 | - 'span' => 'span', | |
| 142 | - 'p' => 'p', | |
| 143 | - ], | |
| 144 | - 'default' => 'span', | |
| 145 | - 'condition' => [ | |
| 146 | - 'title!' => '', | |
| 147 | - ], | |
| 148 | - ] | |
| 149 | - ); | |
| 150 | - | |
| 151 | - $this->add_control( | |
| 152 | - 'title_display', | |
| 153 | - [ | |
| 154 | - 'label' => esc_html__( 'Display Title', 'elementor' ), | |
| 155 | - 'type' => Controls_Manager::SWITCHER, | |
| 156 | - 'label_on' => esc_html__( 'Show', 'elementor' ), | |
| 157 | - 'label_off' => esc_html__( 'Hide', 'elementor' ), | |
| 158 | - 'default' => 'yes', | |
| 159 | - 'condition' => [ | |
| 160 | - 'title!' => '', | |
| 161 | - ], | |
| 162 | - ] | |
| 163 | - ); | |
| 164 | - | |
| 165 | - $this->add_control( | |
| 166 | 107 | 'progress_type', |
| 167 | 108 | [ |
| 168 | - 'label' => esc_html__( 'Type', 'elementor' ), | |
| 109 | + 'label' => __( 'Type', 'elementor' ), | |
| 169 | 110 | 'type' => Controls_Manager::SELECT, |
| 111 | + 'default' => '', | |
| 170 | 112 | 'options' => [ |
| 171 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 172 | - 'info' => esc_html__( 'Info', 'elementor' ), | |
| 173 | - 'success' => esc_html__( 'Success', 'elementor' ), | |
| 174 | - 'warning' => esc_html__( 'Warning', 'elementor' ), | |
| 175 | - 'danger' => esc_html__( 'Danger', 'elementor' ), | |
| 113 | + '' => __( 'Default', 'elementor' ), | |
| 114 | + 'info' => __( 'Info', 'elementor' ), | |
| 115 | + 'success' => __( 'Success', 'elementor' ), | |
| 116 | + 'warning' => __( 'Warning', 'elementor' ), | |
| 117 | + 'danger' => __( 'Danger', 'elementor' ), | |
| 176 | 118 | ], |
| 177 | - 'default' => '', | |
| 178 | - 'condition' => [ | |
| 179 | - 'progress_type!' => '', // a workaround to hide the control, unless it's in use (not default). | |
| 180 | - ], | |
| 181 | - 'separator' => 'before', | |
| 182 | 119 | ] |
| 183 | 120 | ); |
| 184 | 121 | |
| 185 | 122 | $this->add_control( |
| @@ -184,9 +121,9 @@ | ||
| 184 | 121 | |
| 185 | 122 | $this->add_control( |
| 186 | 123 | 'percent', |
| 187 | 124 | [ |
| 188 | - 'label' => esc_html__( 'Percentage', 'elementor' ), | |
| 125 | + 'label' => __( 'Percentage', 'elementor' ), | |
| 189 | 126 | 'type' => Controls_Manager::SLIDER, |
| 190 | 127 | 'default' => [ |
| 191 | 128 | 'size' => 50, |
| 192 | 129 | 'unit' => '%', |
| @@ -193,118 +130,58 @@ | ||
| 193 | 130 | ], |
| 194 | 131 | 'dynamic' => [ |
| 195 | 132 | 'active' => true, |
| 196 | 133 | ], |
| 197 | - 'separator' => 'before', | |
| 198 | 134 | ] |
| 199 | 135 | ); |
| 200 | 136 | |
| 201 | - $this->add_control( | |
| 202 | - 'display_percentage', | |
| 203 | - [ | |
| 204 | - 'label' => esc_html__( 'Display Percentage', 'elementor' ), | |
| 205 | - 'type' => Controls_Manager::SWITCHER, | |
| 206 | - 'label_on' => esc_html__( 'Show', 'elementor' ), | |
| 207 | - 'label_off' => esc_html__( 'Hide', 'elementor' ), | |
| 208 | - 'return_value' => 'show', | |
| 209 | - 'default' => 'show', | |
| 210 | - 'condition' => [ | |
| 211 | - 'percent!' => '', | |
| 212 | - ], | |
| 213 | - ] | |
| 214 | - ); | |
| 137 | + $this->add_control( 'display_percentage', [ | |
| 138 | + 'label' => __( 'Display Percentage', 'elementor' ), | |
| 139 | + 'type' => Controls_Manager::SELECT, | |
| 140 | + 'default' => 'show', | |
| 141 | + 'options' => [ | |
| 142 | + 'show' => __( 'Show', 'elementor' ), | |
| 143 | + 'hide' => __( 'Hide', 'elementor' ), | |
| 144 | + ], | |
| 145 | + ] ); | |
| 215 | 146 | |
| 216 | 147 | $this->add_control( |
| 217 | 148 | 'inner_text', |
| 218 | 149 | [ |
| 219 | - 'label' => esc_html__( 'Inner Text', 'elementor' ), | |
| 150 | + 'label' => __( 'Inner Text', 'elementor' ), | |
| 220 | 151 | 'type' => Controls_Manager::TEXT, |
| 221 | 152 | 'dynamic' => [ |
| 222 | 153 | 'active' => true, |
| 223 | 154 | ], |
| 224 | - 'placeholder' => esc_html__( 'e.g. Web Designer', 'elementor' ), | |
| 225 | - 'default' => esc_html__( 'Web Designer', 'elementor' ), | |
| 155 | + 'placeholder' => __( 'e.g. Web Designer', 'elementor' ), | |
| 156 | + 'default' => __( 'Web Designer', 'elementor' ), | |
| 226 | 157 | 'label_block' => true, |
| 227 | - 'separator' => 'before', | |
| 228 | 158 | ] |
| 229 | 159 | ); |
| 230 | 160 | |
| 231 | - $this->end_controls_section(); | |
| 232 | - | |
| 233 | - $this->start_controls_section( | |
| 234 | - 'section_progress_style', | |
| 235 | - [ | |
| 236 | - 'label' => esc_html__( 'Progress Bar', 'elementor' ), | |
| 237 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 238 | - ] | |
| 239 | - ); | |
| 240 | - | |
| 241 | 161 | $this->add_control( |
| 242 | - 'title_heading', | |
| 162 | + 'view', | |
| 243 | 163 | [ |
| 244 | - 'label' => esc_html__( 'Title', 'elementor' ), | |
| 245 | - 'type' => Controls_Manager::HEADING, | |
| 246 | - 'condition' => [ | |
| 247 | - 'title!' => '', | |
| 248 | - ], | |
| 164 | + 'label' => __( 'View', 'elementor' ), | |
| 165 | + 'type' => Controls_Manager::HIDDEN, | |
| 166 | + 'default' => 'traditional', | |
| 249 | 167 | ] |
| 250 | 168 | ); |
| 251 | 169 | |
| 252 | - $this->add_control( | |
| 253 | - 'title_color', | |
| 254 | - [ | |
| 255 | - 'label' => esc_html__( 'Text Color', 'elementor' ), | |
| 256 | - 'type' => Controls_Manager::COLOR, | |
| 257 | - 'selectors' => [ | |
| 258 | - '{{WRAPPER}} .elementor-title' => 'color: {{VALUE}};', | |
| 259 | - ], | |
| 260 | - 'global' => [ | |
| 261 | - 'default' => Global_Colors::COLOR_PRIMARY, | |
| 262 | - ], | |
| 263 | - 'condition' => [ | |
| 264 | - 'title!' => '', | |
| 265 | - ], | |
| 266 | - ] | |
| 267 | - ); | |
| 170 | + $this->end_controls_section(); | |
| 268 | 171 | |
| 269 | - $this->add_group_control( | |
| 270 | - Group_Control_Typography::get_type(), | |
| 172 | + $this->start_controls_section( | |
| 173 | + 'section_progress_style', | |
| 271 | 174 | [ |
| 272 | - 'name' => 'typography', | |
| 273 | - 'selector' => '{{WRAPPER}} .elementor-title', | |
| 274 | - 'global' => [ | |
| 275 | - 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 276 | - ], | |
| 277 | - 'condition' => [ | |
| 278 | - 'title!' => '', | |
| 279 | - ], | |
| 175 | + 'label' => __( 'Progress Bar', 'elementor' ), | |
| 176 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 280 | 177 | ] |
| 281 | 178 | ); |
| 282 | 179 | |
| 283 | - $this->add_group_control( | |
| 284 | - Group_Control_Text_Shadow::get_type(), | |
| 285 | - [ | |
| 286 | - 'name' => 'title_shadow', | |
| 287 | - 'selector' => '{{WRAPPER}} .elementor-title', | |
| 288 | - 'condition' => [ | |
| 289 | - 'title!' => '', | |
| 290 | - ], | |
| 291 | - ] | |
| 292 | - ); | |
| 293 | - | |
| 294 | 180 | $this->add_control( |
| 295 | - 'percentage_heading', | |
| 296 | - [ | |
| 297 | - 'label' => esc_html__( 'Percentage', 'elementor' ), | |
| 298 | - 'type' => Controls_Manager::HEADING, | |
| 299 | - 'separator' => 'before', | |
| 300 | - ] | |
| 301 | - ); | |
| 302 | - | |
| 303 | - $this->add_control( | |
| 304 | 181 | 'bar_color', |
| 305 | 182 | [ |
| 306 | - 'label' => esc_html__( 'Color', 'elementor' ), | |
| 183 | + 'label' => __( 'Color', 'elementor' ), | |
| 307 | 184 | 'type' => Controls_Manager::COLOR, |
| 308 | 185 | 'global' => [ |
| 309 | 186 | 'default' => Global_Colors::COLOR_PRIMARY, |
| 310 | 187 | ], |
| @@ -316,9 +193,9 @@ | ||
| 316 | 193 | |
| 317 | 194 | $this->add_control( |
| 318 | 195 | 'bar_bg_color', |
| 319 | 196 | [ |
| 320 | - 'label' => esc_html__( 'Background Color', 'elementor' ), | |
| 197 | + 'label' => __( 'Background Color', 'elementor' ), | |
| 321 | 198 | 'type' => Controls_Manager::COLOR, |
| 322 | 199 | 'selectors' => [ |
| 323 | 200 | '{{WRAPPER}} .elementor-progress-wrapper' => 'background-color: {{VALUE}};', |
| 324 | 201 | ], |
| @@ -327,11 +204,10 @@ | ||
| 327 | 204 | |
| 328 | 205 | $this->add_control( |
| 329 | 206 | 'bar_height', |
| 330 | 207 | [ |
| 331 | - 'label' => esc_html__( 'Height', 'elementor' ), | |
| 208 | + 'label' => __( 'Height', 'elementor' ), | |
| 332 | 209 | 'type' => Controls_Manager::SLIDER, |
| 333 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 334 | 210 | 'selectors' => [ |
| 335 | 211 | '{{WRAPPER}} .elementor-progress-bar' => 'height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};', |
| 336 | 212 | ], |
| 337 | 213 | ] |
| @@ -339,11 +215,11 @@ | ||
| 339 | 215 | |
| 340 | 216 | $this->add_control( |
| 341 | 217 | 'bar_border_radius', |
| 342 | 218 | [ |
| 343 | - 'label' => esc_html__( 'Border Radius', 'elementor' ), | |
| 219 | + 'label' => __( 'Border Radius', 'elementor' ), | |
| 344 | 220 | 'type' => Controls_Manager::SLIDER, |
| 345 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 221 | + 'size_units' => [ 'px', '%' ], | |
| 346 | 222 | 'selectors' => [ |
| 347 | 223 | '{{WRAPPER}} .elementor-progress-wrapper' => 'border-radius: {{SIZE}}{{UNIT}}; overflow: hidden;', |
| 348 | 224 | ], |
| 349 | 225 | ] |
| @@ -351,14 +227,11 @@ | ||
| 351 | 227 | |
| 352 | 228 | $this->add_control( |
| 353 | 229 | 'inner_text_heading', |
| 354 | 230 | [ |
| 355 | - 'label' => esc_html__( 'Inner Text', 'elementor' ), | |
| 231 | + 'label' => __( 'Inner Text', 'elementor' ), | |
| 356 | 232 | 'type' => Controls_Manager::HEADING, |
| 357 | 233 | 'separator' => 'before', |
| 358 | - 'condition' => [ | |
| 359 | - 'inner_text!' => '', | |
| 360 | - ], | |
| 361 | 234 | ] |
| 362 | 235 | ); |
| 363 | 236 | |
| 364 | 237 | $this->add_control( |
| @@ -363,16 +236,13 @@ | ||
| 363 | 236 | |
| 364 | 237 | $this->add_control( |
| 365 | 238 | 'bar_inline_color', |
| 366 | 239 | [ |
| 367 | - 'label' => esc_html__( 'Color', 'elementor' ), | |
| 240 | + 'label' => __( 'Color', 'elementor' ), | |
| 368 | 241 | 'type' => Controls_Manager::COLOR, |
| 369 | 242 | 'selectors' => [ |
| 370 | 243 | '{{WRAPPER}} .elementor-progress-bar' => 'color: {{VALUE}};', |
| 371 | 244 | ], |
| 372 | - 'condition' => [ | |
| 373 | - 'inner_text!' => '', | |
| 374 | - ], | |
| 375 | 245 | ] |
| 376 | 246 | ); |
| 377 | 247 | |
| 378 | 248 | $this->add_group_control( |
| @@ -382,21 +252,42 @@ | ||
| 382 | 252 | 'selector' => '{{WRAPPER}} .elementor-progress-bar', |
| 383 | 253 | 'exclude' => [ |
| 384 | 254 | 'line_height', |
| 385 | 255 | ], |
| 386 | - 'condition' => [ | |
| 387 | - 'inner_text!' => '', | |
| 256 | + ] | |
| 257 | + ); | |
| 258 | + | |
| 259 | + $this->end_controls_section(); | |
| 260 | + | |
| 261 | + $this->start_controls_section( | |
| 262 | + 'section_title', | |
| 263 | + [ | |
| 264 | + 'label' => __( 'Title Style', 'elementor' ), | |
| 265 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 266 | + ] | |
| 267 | + ); | |
| 268 | + | |
| 269 | + $this->add_control( | |
| 270 | + 'title_color', | |
| 271 | + [ | |
| 272 | + 'label' => __( 'Text Color', 'elementor' ), | |
| 273 | + 'type' => Controls_Manager::COLOR, | |
| 274 | + 'selectors' => [ | |
| 275 | + '{{WRAPPER}} .elementor-title' => 'color: {{VALUE}};', | |
| 388 | 276 | ], |
| 277 | + 'global' => [ | |
| 278 | + 'default' => Global_Colors::COLOR_PRIMARY, | |
| 279 | + ], | |
| 389 | 280 | ] |
| 390 | 281 | ); |
| 391 | 282 | |
| 392 | 283 | $this->add_group_control( |
| 393 | - Group_Control_Text_Shadow::get_type(), | |
| 284 | + Group_Control_Typography::get_type(), | |
| 394 | 285 | [ |
| 395 | - 'name' => 'bar_inner_shadow', | |
| 396 | - 'selector' => '{{WRAPPER}} .elementor-progress-bar', | |
| 397 | - 'condition' => [ | |
| 398 | - 'inner_text!' => '', | |
| 286 | + 'name' => 'typography', | |
| 287 | + 'selector' => '{{WRAPPER}} .elementor-title', | |
| 288 | + 'global' => [ | |
| 289 | + 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 399 | 290 | ], |
| 400 | 291 | ] |
| 401 | 292 | ); |
| 402 | 293 | |
| @@ -414,84 +305,52 @@ | ||
| 414 | 305 | */ |
| 415 | 306 | protected function render() { |
| 416 | 307 | $settings = $this->get_settings_for_display(); |
| 417 | 308 | |
| 418 | - if ( empty( $settings['title'] ) && empty( $settings['percent']['size'] ) ) { | |
| 419 | - return; | |
| 420 | - } | |
| 421 | - | |
| 422 | - $progressbar_id = 'elementor-progress-bar-' . $this->get_id(); | |
| 423 | - | |
| 424 | 309 | $progress_percentage = is_numeric( $settings['percent']['size'] ) ? $settings['percent']['size'] : '0'; |
| 425 | 310 | if ( 100 < $progress_percentage ) { |
| 426 | 311 | $progress_percentage = 100; |
| 427 | 312 | } |
| 428 | 313 | |
| 429 | - if ( ! Utils::is_empty( $settings['title'] ) ) { | |
| 314 | + $this->add_render_attribute( 'title', [ | |
| 315 | + 'class' => 'elementor-title', | |
| 316 | + ]); | |
| 430 | 317 | |
| 431 | - if ( 'yes' === $settings['title_display'] ) { | |
| 318 | + $this->add_inline_editing_attributes( 'title' ); | |
| 432 | 319 | |
| 433 | - $this->add_render_attribute( | |
| 434 | - 'title', | |
| 435 | - [ | |
| 436 | - 'class' => 'elementor-title', | |
| 437 | - 'id' => $progressbar_id, | |
| 438 | - ] | |
| 439 | - ); | |
| 320 | + $this->add_render_attribute( 'wrapper', [ | |
| 321 | + 'class' => 'elementor-progress-wrapper', | |
| 322 | + 'role' => 'progressbar', | |
| 323 | + 'aria-valuemin' => '0', | |
| 324 | + 'aria-valuemax' => '100', | |
| 325 | + 'aria-valuenow' => $progress_percentage, | |
| 326 | + 'aria-valuetext' => $settings['inner_text'], | |
| 327 | + ] ); | |
| 440 | 328 | |
| 441 | - $this->add_inline_editing_attributes( 'title' ); | |
| 442 | - | |
| 443 | - $this->add_render_attribute( 'wrapper', 'aria-labelledby', $progressbar_id ); | |
| 444 | - | |
| 445 | - } else { | |
| 446 | - | |
| 447 | - $this->add_render_attribute( 'wrapper', 'aria-label', $settings['title'] ); | |
| 448 | - | |
| 449 | - } | |
| 450 | - } | |
| 451 | - | |
| 452 | - $this->add_render_attribute( | |
| 453 | - 'wrapper', | |
| 454 | - [ | |
| 455 | - 'class' => 'elementor-progress-wrapper', | |
| 456 | - 'role' => 'progressbar', | |
| 457 | - 'aria-valuemin' => '0', | |
| 458 | - 'aria-valuemax' => '100', | |
| 459 | - 'aria-valuenow' => $progress_percentage, | |
| 460 | - ] | |
| 461 | - ); | |
| 462 | - | |
| 463 | - if ( ! empty( $settings['inner_text'] ) ) { | |
| 464 | - $this->add_render_attribute( 'wrapper', 'aria-valuetext', "{$progress_percentage}% ({$settings['inner_text']})" ); | |
| 465 | - } | |
| 466 | - | |
| 467 | 329 | if ( ! empty( $settings['progress_type'] ) ) { |
| 468 | 330 | $this->add_render_attribute( 'wrapper', 'class', 'progress-' . $settings['progress_type'] ); |
| 469 | 331 | } |
| 470 | 332 | |
| 471 | - $this->add_render_attribute( | |
| 472 | - 'progress-bar', | |
| 473 | - [ | |
| 474 | - 'class' => 'elementor-progress-bar', | |
| 475 | - 'data-max' => $progress_percentage, | |
| 476 | - ] | |
| 477 | - ); | |
| 333 | + $this->add_render_attribute( 'progress-bar', [ | |
| 334 | + 'class' => 'elementor-progress-bar', | |
| 335 | + 'data-max' => $progress_percentage, | |
| 336 | + ] ); | |
| 478 | 337 | |
| 479 | - $this->add_render_attribute( 'inner_text', 'class', 'elementor-progress-text' ); | |
| 338 | + $this->add_render_attribute( 'inner_text', [ | |
| 339 | + 'class' => 'elementor-progress-text', | |
| 340 | + ] ); | |
| 480 | 341 | |
| 481 | 342 | $this->add_inline_editing_attributes( 'inner_text' ); |
| 482 | 343 | |
| 483 | - if ( ! Utils::is_empty( $settings['title'] ) && 'yes' === $settings['title_display'] ) { ?> | |
| 484 | - <<?php Utils::print_validated_html_tag( $settings['title_tag'] ); ?> <?php $this->print_render_attribute_string( 'title' ); ?>> | |
| 485 | - <?php echo wp_kses_post( $settings['title'] ); ?> | |
| 486 | - </<?php Utils::print_validated_html_tag( $settings['title_tag'] ); ?>> | |
| 344 | + if ( ! Utils::is_empty( $settings['title'] ) ) { ?> | |
| 345 | + <span <?php echo $this->get_render_attribute_string( 'title' ); ?>><?php echo $settings['title']; ?></span> | |
| 487 | 346 | <?php } ?> |
| 488 | 347 | |
| 489 | - <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>> | |
| 490 | - <div <?php $this->print_render_attribute_string( 'progress-bar' ); ?>> | |
| 491 | - <span <?php $this->print_render_attribute_string( 'inner_text' ); ?>><?php echo wp_kses_post( $settings['inner_text'] ); ?></span> | |
| 492 | - <?php if ( 'show' === $settings['display_percentage'] ) { ?> | |
| 493 | - <span class="elementor-progress-percentage"><?php echo $progress_percentage; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>%</span> | |
| 348 | + <div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>> | |
| 349 | + <div <?php echo $this->get_render_attribute_string( 'progress-bar' ); ?>> | |
| 350 | + <span <?php echo $this->get_render_attribute_string( 'inner_text' ); ?>><?php echo $settings['inner_text']; ?></span> | |
| 351 | + <?php if ( 'hide' !== $settings['display_percentage'] ) { ?> | |
| 352 | + <span class="elementor-progress-percentage"><?php echo $progress_percentage; ?>%</span> | |
| 494 | 353 | <?php } ?> |
| 495 | 354 | </div> |
| 496 | 355 | </div> |
| 497 | 356 | <?php |
| @@ -507,101 +366,44 @@ | ||
| 507 | 366 | */ |
| 508 | 367 | protected function content_template() { |
| 509 | 368 | ?> |
| 510 | 369 | <# |
| 511 | - if ( '' === settings.title && '' === settings.percent.size ) { | |
| 512 | - return; | |
| 513 | - } | |
| 514 | - | |
| 515 | - const title_tag = elementor.helpers.validateHTMLTag( settings.title_tag ); | |
| 516 | - const progressbar_id = 'elementor-progress-bar-<?php echo esc_attr( $this->get_id() ); ?>'; | |
| 517 | - | |
| 518 | 370 | let progress_percentage = 0; |
| 519 | 371 | if ( ! isNaN( settings.percent.size ) ) { |
| 520 | 372 | progress_percentage = 100 < settings.percent.size ? 100 : settings.percent.size; |
| 521 | 373 | } |
| 522 | 374 | |
| 523 | - if ( settings.title ) { | |
| 375 | + view.addRenderAttribute( 'title', { | |
| 376 | + 'class': 'elementor-title' | |
| 377 | + } ); | |
| 524 | 378 | |
| 525 | - if ( 'yes' === settings.title_display ) { | |
| 379 | + view.addInlineEditingAttributes( 'title' ); | |
| 526 | 380 | |
| 527 | - view.addRenderAttribute( | |
| 528 | - 'title', | |
| 529 | - { | |
| 530 | - 'class': 'elementor-title', | |
| 531 | - 'id': progressbar_id, | |
| 532 | - } | |
| 533 | - ); | |
| 381 | + view.addRenderAttribute( 'progressWrapper', { | |
| 382 | + 'class': [ 'elementor-progress-wrapper', 'progress-' + settings.progress_type ], | |
| 383 | + 'role': 'progressbar', | |
| 384 | + 'aria-valuemin': '0', | |
| 385 | + 'aria-valuemax': '100', | |
| 386 | + 'aria-valuenow': progress_percentage, | |
| 387 | + 'aria-valuetext': settings.inner_text | |
| 388 | + } ); | |
| 534 | 389 | |
| 535 | - view.addInlineEditingAttributes( 'title' ); | |
| 390 | + view.addRenderAttribute( 'inner_text', { | |
| 391 | + 'class': 'elementor-progress-text' | |
| 392 | + } ); | |
| 536 | 393 | |
| 537 | - view.addRenderAttribute( 'progressWrapper', 'aria-labelledby', progressbar_id ); | |
| 538 | - | |
| 539 | - } else { | |
| 540 | - | |
| 541 | - view.addRenderAttribute( 'progressWrapper', 'aria-label', settings.title ); | |
| 542 | - | |
| 543 | - } | |
| 544 | - } | |
| 545 | - | |
| 546 | - view.addRenderAttribute( | |
| 547 | - 'progressWrapper', | |
| 548 | - { | |
| 549 | - 'class': [ 'elementor-progress-wrapper', 'progress-' + settings.progress_type ], | |
| 550 | - 'role': 'progressbar', | |
| 551 | - 'aria-valuemin': '0', | |
| 552 | - 'aria-valuemax': '100', | |
| 553 | - 'aria-valuenow': progress_percentage, | |
| 554 | - } | |
| 555 | - ); | |
| 556 | - | |
| 557 | - if ( '' !== settings.inner_text ) { | |
| 558 | - view.addRenderAttribute( 'progressWrapper', 'aria-valuetext', progress_percentage + '% (' + settings.inner_text + ')' ); | |
| 559 | - } | |
| 560 | - | |
| 561 | - view.addRenderAttribute( 'inner_text', 'class', 'elementor-progress-text' ); | |
| 562 | - | |
| 563 | 394 | view.addInlineEditingAttributes( 'inner_text' ); |
| 564 | 395 | #> |
| 565 | - <# if ( settings.title && 'yes' === settings.title_display ) { #> | |
| 566 | - <{{ title_tag }} {{{ view.getRenderAttributeString( 'title' ) }}}>{{ settings.title }}</{{ title_tag }}> | |
| 567 | - <# } #> | |
| 396 | + <# if ( settings.title ) { #> | |
| 397 | + <span {{{ view.getRenderAttributeString( 'title' ) }}}>{{{ settings.title }}}</span><# | |
| 398 | + } #> | |
| 568 | 399 | <div {{{ view.getRenderAttributeString( 'progressWrapper' ) }}}> |
| 569 | 400 | <div class="elementor-progress-bar" data-max="{{ progress_percentage }}"> |
| 570 | - <span {{{ view.getRenderAttributeString( 'inner_text' ) }}}>{{ settings.inner_text }}</span> | |
| 571 | - <# if ( 'show' === settings.display_percentage ) { #> | |
| 401 | + <span {{{ view.getRenderAttributeString( 'inner_text' ) }}}>{{{ settings.inner_text }}}</span> | |
| 402 | + <# if ( 'hide' !== settings.display_percentage ) { #> | |
| 572 | 403 | <span class="elementor-progress-percentage">{{{ progress_percentage }}}%</span> |
| 573 | 404 | <# } #> |
| 574 | 405 | </div> |
| 575 | 406 | </div> |
| 576 | 407 | <?php |
| 577 | - } | |
| 578 | - | |
| 579 | - public function render_markdown(): string { | |
| 580 | - $settings = $this->get_settings_for_display(); | |
| 581 | - $title = Utils::html_to_plain_text( $settings['title'] ?? '' ); | |
| 582 | - $inner_text = Utils::html_to_plain_text( $settings['inner_text'] ?? '' ); | |
| 583 | - $percent = $settings['percent']['size'] ?? ( $settings['percent'] ?? '' ); | |
| 584 | - | |
| 585 | - $parts = []; | |
| 586 | - | |
| 587 | - if ( ! empty( $title ) ) { | |
| 588 | - $parts[] = $title; | |
| 589 | - } | |
| 590 | - | |
| 591 | - if ( ! empty( $inner_text ) ) { | |
| 592 | - $parts[] = $inner_text; | |
| 593 | - } | |
| 594 | - | |
| 595 | - if ( empty( $parts ) && empty( $percent ) ) { | |
| 596 | - return ''; | |
| 597 | - } | |
| 598 | - | |
| 599 | - $label = implode( ' - ', $parts ); | |
| 600 | - | |
| 601 | - if ( ! empty( $percent ) ) { | |
| 602 | - return ! empty( $label ) ? $label . ': ' . $percent . '%' : $percent . '%'; | |
| 603 | - } | |
| 604 | - | |
| 605 | - return $label; | |
| 606 | 408 | } |
| 607 | 409 | } |