start_controls_section(
'general_section',
[
'label' => __( 'General', 'aihub-core' ),
]
);
$this->add_control(
'width',
[
'label' => esc_html__( 'Width', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => 'px',
'size' => 300,
],
'selectors' => [
'{{WRAPPER}}' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'height',
[
'label' => esc_html__( 'Height', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => 'px',
'size' => 300,
],
'selectors' => [
'{{WRAPPER}}' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'blur',
[
'label' => esc_html__( 'Blur', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}}' => '--glow-blur-value: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'opacity',
[
'label' => esc_html__( 'Opacity', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 1,
'step' => 0.05,
],
],
'selectors' => [
'{{WRAPPER}} svg' => 'opacity: {{SIZE}};',
],
]
);
$this->add_control( 'hr', [
'type' => Controls_Manager::DIVIDER,
] );
$this->add_control(
'start_options',
[
'label' => esc_html__( 'Start Options', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'duration_start',
[
'label' => esc_html__( 'Duration (seconds)', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 20,
'step' => 0.1,
],
],
'default' => [
'unit' => 'px',
'size' => 4.25,
],
]
);
$repeater_start = new Repeater();
$repeater_start->add_control(
'color',
[
'label' => esc_html__( 'Color', 'aihub-core' ),
'type' => 'liquid-color',
'types' => [ 'solid' ],
]
);
$this->add_control(
'colors_start',
[
'label' => esc_html__( 'Colors', 'aihub-core' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater_start->get_controls(),
'default' => [
[ 'color' => '#f8f7a1' ],
[ 'color' => '#b185fe' ],
[ 'color' => '#53fd87' ],
[ 'color' => '#f8f7a1' ],
],
'title_field' => ' {{{ color }}}',
]
);
$this->add_control( 'hr2', [
'type' => Controls_Manager::DIVIDER,
] );
$this->add_control(
'end_options',
[
'label' => esc_html__( 'End Options', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'duration_end',
[
'label' => esc_html__( 'Duration (seconds)', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 20,
'step' => 0.1,
],
],
'default' => [
'unit' => 'px',
'size' => 4.25,
],
]
);
$repeater_start = new Repeater();
$repeater_start->add_control(
'color',
[
'label' => esc_html__( 'Color', 'aihub-core' ),
'type' => 'liquid-color',
'types' => [ 'solid' ],
]
);
$this->add_control(
'colors_end',
[
'label' => esc_html__( 'Colors', 'aihub-core' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater_start->get_controls(),
'default' => [
[ 'color' => '#ff9c00' ],
[ 'color' => '#6ed5fb' ],
[ 'color' => '#ff7274' ],
[ 'color' => '#ff9c00' ],
],
'title_field' => ' {{{ color }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'glow_dark_section',
[
'label' => __( 'Dark 🌘', 'aihub-core' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'glow_dark_opacity',
[
'label' => esc_html__( 'Opacity', 'aihub-core' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 1,
'step' => 0.05,
],
],
'selectors' => [
$dark_selectors => 'opacity: {{SIZE}};',
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$filter_id = 'filter_' . $this->get_id();
$paint_id = 'paint_' . $this->get_id();
$duration = [
'start' => isset( $settings['duration_start']['size'] ) ? $settings['duration_start']['size'] . 's' : '4.25s',
'end' => isset( $settings['duration_end']['size'] ) ? $settings['duration_end']['size'] . 's' : '3s'
];
$colors = [
'start' => '',
'end' => '',
];
$start_first_color = '';
$end_first_color = '';
if ( !empty( $settings['colors_start'] ) ) {
$start_first_color = $settings['colors_start'][0]['color'];
foreach( $settings['colors_start'] as $colors_start ) {
$colors['start'] .= $colors_start['color'] . ';';
}
}
if ( !empty( $settings['colors_end'] ) ) {
$end_first_color = $settings['colors_end'][0]['color'];
foreach( $settings['colors_end'] as $colors_end ) {
$colors['end'] .= $colors_end['color'] . ';';
}
}
?>
widgets_manager->register( new LQD_Glow() );