112 lines
2.9 KiB
PHP
112 lines
2.9 KiB
PHP
<?php
|
|
use Elementor\Controls_Manager;
|
|
use Elementor\Utils;
|
|
use Elementor\Icons_Manager;
|
|
// use Elementor\Group_Control_Text_Shadow;
|
|
// use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
|
// use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
|
// use Elementor\Group_Control_Text_Stroke;
|
|
// use Elementor\Group_Control_Typography;
|
|
class Elementor_Audio_Handler extends \Elementor\Widget_Base {
|
|
|
|
public function get_name() {
|
|
return 'audio_handler';
|
|
}
|
|
|
|
public function get_title() {
|
|
return esc_html__( 'Audio handler', 'elementor-addon' );
|
|
}
|
|
|
|
public function get_icon() {
|
|
return 'eicon-code';
|
|
}
|
|
|
|
public function get_categories() {
|
|
return [ 'basic' ];
|
|
}
|
|
|
|
public function get_keywords() {
|
|
return [ 'audio', 'music',];
|
|
}
|
|
|
|
protected function register_controls() {
|
|
$this->start_controls_section(
|
|
'section_audio',
|
|
[
|
|
'label' => esc_html__( 'Audio settings', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'choice_audio',
|
|
[
|
|
'label' => esc_html__( 'Choice audio', 'elementor-addon' ),
|
|
'type' => Controls_Manager::MEDIA,
|
|
'default' => [],
|
|
'dynamic' => [
|
|
'active' => true,
|
|
],
|
|
'media_types' => ['audio', 'video'],
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
|
|
$this->start_controls_section(
|
|
'section_icon',
|
|
[
|
|
'label' => esc_html__( 'Icon settings', 'elementor' ),
|
|
]
|
|
);
|
|
$this->add_control(
|
|
'active_icon',
|
|
[
|
|
'label' => esc_html__( 'Active icon', 'elementor' ),
|
|
'type' => Controls_Manager::ICONS,
|
|
'fa4compatibility' => 'icon',
|
|
'default' => [
|
|
'value' => 'fas fa-star',
|
|
'library' => 'fa-solid',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'inactive_icon',
|
|
[
|
|
'label' => esc_html__( 'Inactive', 'elementor' ),
|
|
'type' => Controls_Manager::ICONS,
|
|
'fa4compatibility' => 'icon',
|
|
'default' => [
|
|
'value' => 'fas fa-star',
|
|
'library' => 'fa-solid',
|
|
],
|
|
]
|
|
);
|
|
$this->end_controls_section();
|
|
}
|
|
|
|
protected function render() {
|
|
$settings = $this->get_settings_for_display();
|
|
$active_icon = ! empty( $settings['active_icon']['value'] );
|
|
$inactive_icon = ! empty( $settings['inactive_icon']['value'] );
|
|
?>
|
|
<div id="audio-box">
|
|
<div id="audio-handler">
|
|
<span class="audio-active">
|
|
<?php if ( $active_icon ) : ?>
|
|
<?php Icons_Manager::render_icon( $settings['active_icon'], [ 'aria-hidden' => 'true' ] ); ?>
|
|
<?php endif; ?>
|
|
</span>
|
|
<span class="audio-inactive active">
|
|
<?php if ( $inactive_icon ) : ?>
|
|
<?php Icons_Manager::render_icon( $settings['inactive_icon'], [ 'aria-hidden' => 'true' ] ); ?>
|
|
<?php endif; ?>
|
|
</span>
|
|
</div>
|
|
|
|
<audio id="audio-player" src="<?php echo esc_url( $settings['choice_audio']['url'] ); ?>"></audio>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|