| 1 |
<?php |
| 2 |
/** |
| 3 |
* Helper for rendering Elementor Icons in widgets |
| 4 |
* |
| 5 |
* Usage in widget render method: |
| 6 |
* \Elementor\Icons_Manager::render_icon( $settings['icon_field_name'], [ 'aria-hidden' => 'true' ] ); |
| 7 |
*/ |
| 8 |
|
| 9 |
// Example of how to properly render an icon in the widget's render_widget_content method: |
| 10 |
/* |
| 11 |
protected function render_widget_content($settings) { |
| 12 |
?> |
| 13 |
<div class="icon-holder"> |
| 14 |
<?php |
| 15 |
// Check if icon is set |
| 16 |
if ( ! empty( $settings['jltma_advanced_icons_28']['value'] ) ) { |
| 17 |
\Elementor\Icons_Manager::render_icon( $settings['jltma_advanced_icons_28'], [ 'aria-hidden' => 'true' ] ); |
| 18 |
} |
| 19 |
?> |
| 20 |
</div> |
| 21 |
<?php |
| 22 |
} |
| 23 |
*/ |
| 24 |
|
| 25 |
// Alternative method using the icon HTML directly: |
| 26 |
/* |
| 27 |
protected function render_widget_content($settings) { |
| 28 |
?> |
| 29 |
<div class="icon-holder"> |
| 30 |
<?php |
| 31 |
// Check if icon is set |
| 32 |
if ( ! empty( $settings['jltma_advanced_icons_28']['value'] ) ) { |
| 33 |
// For Font Awesome or other icon fonts |
| 34 |
if ( ! empty( $settings['jltma_advanced_icons_28']['library'] ) ) { |
| 35 |
echo '<i class="' . esc_attr( $settings['jltma_advanced_icons_28']['value'] ) . '" aria-hidden="true"></i>'; |
| 36 |
} |
| 37 |
} |
| 38 |
?> |
| 39 |
</div> |
| 40 |
<?php |
| 41 |
} |
| 42 |
*/ |