<?php
/**
 * Widget Name: Sticky Promo Bar
 * Description: A site-wide announcement / promotion bar that can stick to the
 *              top or bottom of the viewport, optionally push the page content
 *              so nothing is covered, and be dismissed by the visitor ( with a
 *              configurable "stay hidden" period stored in localStorage ).
 *              Ships with selectable visual styles — classic solid, gradient
 *              glow, minimal outline, floating pill and a scrolling marquee.
 *              Only the selected style CSS file is loaded on the frontend.
 *
 * @package    captain-widgets-kit
 * @subpackage captain-widgets-kit/includes
 * @since      1.7.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Icons_Manager;

/**
 * Class Captwiki_Sticky_Promo_Bar
 *
 * @since 1.7.0
 */
class Captwiki_Sticky_Promo_Bar extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * @since 1.7.0
	 * @return string
	 */
	public function get_name(): string {
		return 'captwiki-sticky-promo-bar';
	}

	/**
	 * Get widget title.
	 *
	 * @since 1.7.0
	 * @return string
	 */
	public function get_title(): string {
		return esc_html__( 'Sticky Promo Bar', 'captain-widgets-kit' );
	}

	/**
	 * Get widget icon.
	 *
	 * @since 1.7.0
	 * @return string
	 */
	public function get_icon(): string {
		return 'eicon-banner captwiki-el-logo';
	}

	/**
	 * Get widget categories.
	 *
	 * @since 1.7.0
	 * @return array
	 */
	public function get_categories(): array {
		return array( 'captwiki-essential' );
	}

	/**
	 * Get widget keywords.
	 *
	 * @since 1.7.0
	 * @return array
	 */
	public function get_keywords(): array {
		return array( 'promo', 'bar', 'sticky', 'announcement', 'notification', 'banner', 'sale', 'captain-widgets-kit' );
	}

	/**
	 * Frontend script dependency.
	 *
	 * @since 1.7.0
	 * @return array
	 */
	public function get_script_depends(): array {
		return array( 'captwiki-sticky-promo-bar' );
	}

	/**
	 * Common stylesheet dependency.
	 *
	 * @since 1.7.0
	 * @return array
	 */
	public function get_style_depends(): array {
		return array( 'captwiki_sticky_promo_bar' );
	}

	/**
	 * Disable Elementor's default inner wrapper.
	 *
	 * @since 1.7.0
	 * @return bool
	 */
	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}

	/**
	 * Selectable visual styles.
	 *
	 * @since 1.7.0
	 * @return array
	 */
	private function captwiki_style_options(): array {
		return array(
			'style-1' => esc_html__( 'Style 1 – Classic Solid', 'captain-widgets-kit' ),
			'style-2' => esc_html__( 'Style 2 – Gradient Glow', 'captain-widgets-kit' ),
			'style-3' => esc_html__( 'Style 3 – Minimal Outline', 'captain-widgets-kit' ),
			'style-4' => esc_html__( 'Style 4 – Floating Pill', 'captain-widgets-kit' ),
			'style-5' => esc_html__( 'Style 5 – Marquee Scroll', 'captain-widgets-kit' ),
		);
	}

	/**
	 * Register widget controls.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	protected function register_controls(): void {
		$this->register_content_controls();
		$this->register_behaviour_controls();

		$this->register_bar_style_controls();
		$this->register_text_style_controls();
		$this->register_button_style_controls();
		$this->register_close_style_controls();
	}

	/**
	 * Content tab — message & button.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function register_content_controls(): void {

		$this->start_controls_section(
			'section_content',
			array(
				'label' => esc_html__( 'Promo Bar', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$this->add_control(
			'widget_style',
			array(
				'label'   => esc_html__( 'Style', 'captain-widgets-kit' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'style-1',
				'options' => $this->captwiki_style_options(),
			)
		);

		$this->add_control(
			'badge_text',
			array(
				'label'   => esc_html__( 'Badge Text', 'captain-widgets-kit' ),
				'type'    => Controls_Manager::TEXT,
				'default' => esc_html__( 'SALE', 'captain-widgets-kit' ),
				'dynamic' => array( 'active' => true ),
			)
		);

		$this->add_control(
			'promo_icon',
			array(
				'label' => esc_html__( 'Icon (optional)', 'captain-widgets-kit' ),
				'type'  => Controls_Manager::ICONS,
				'skin'  => 'inline',
			)
		);

		$this->add_control(
			'promo_text',
			array(
				'label'       => esc_html__( 'Message', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Summer sale is live — get up to 50% off everything for a limited time!', 'captain-widgets-kit' ),
				'label_block' => true,
				'dynamic'     => array( 'active' => true ),
			)
		);

		$this->add_control(
			'button_text',
			array(
				'label'   => esc_html__( 'Button Text', 'captain-widgets-kit' ),
				'type'    => Controls_Manager::TEXT,
				'default' => esc_html__( 'Shop Now', 'captain-widgets-kit' ),
				'dynamic' => array( 'active' => true ),
			)
		);

		$this->add_control(
			'button_link',
			array(
				'label'     => esc_html__( 'Button Link', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::URL,
				'dynamic'   => array( 'active' => true ),
				'default'   => array( 'url' => '' ),
				'condition' => array( 'button_text!' => '' ),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Content tab — position & dismiss behaviour.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function register_behaviour_controls(): void {

		$this->start_controls_section(
			'section_behaviour',
			array(
				'label' => esc_html__( 'Behaviour', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$this->add_control(
			'sticky_enabled',
			array(
				'label'        => esc_html__( 'Stick to Viewport', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'No', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'yes',
				'description'  => esc_html__( 'Inside the editor the bar always shows in place; on the frontend it sticks.', 'captain-widgets-kit' ),
			)
		);

		$this->add_control(
			'bar_position',
			array(
				'label'     => esc_html__( 'Position', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'top',
				'options'   => array(
					'top'    => esc_html__( 'Top', 'captain-widgets-kit' ),
					'bottom' => esc_html__( 'Bottom', 'captain-widgets-kit' ),
				),
				'condition' => array( 'sticky_enabled' => 'yes' ),
			)
		);

		$this->add_control(
			'push_content',
			array(
				'label'        => esc_html__( 'Push Page Content', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'No', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'yes',
				'description'  => esc_html__( 'Adds body padding equal to the bar height so the bar never covers content.', 'captain-widgets-kit' ),
				'condition'    => array( 'sticky_enabled' => 'yes' ),
			)
		);

		$this->add_control(
			'z_index',
			array(
				'label'     => esc_html__( 'Z-Index', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::NUMBER,
				'min'       => 1,
				'max'       => 999999,
				'default'   => 9999,
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo' => '--captwiki-promo-z: {{VALUE}};',
				),
				'condition' => array( 'sticky_enabled' => 'yes' ),
			)
		);

		$this->add_control(
			'dismissible',
			array(
				'label'        => esc_html__( 'Show Close Button', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'Hide', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'yes',
				'separator'    => 'before',
			)
		);

		$this->add_control(
			'remember_days',
			array(
				'label'       => esc_html__( 'Stay Hidden (days)', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::NUMBER,
				'min'         => 0,
				'max'         => 365,
				'step'        => 1,
				'default'     => 1,
				'description' => esc_html__( 'After dismissing, hide the bar for this many days. 0 = show again on the next page load.', 'captain-widgets-kit' ),
				'condition'   => array( 'dismissible' => 'yes' ),
			)
		);

		$this->add_control(
			'marquee_speed',
			array(
				'label'       => esc_html__( 'Marquee Duration (s)', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::SLIDER,
				'range'       => array(
					'px' => array(
						'min'  => 5,
						'max'  => 60,
						'step' => 1,
					),
				),
				'default'     => array( 'size' => 18 ),
				'selectors'   => array(
					'{{WRAPPER}} .captwiki-promo' => '--captwiki-promo-speed: {{SIZE}}s;',
				),
				'condition'   => array( 'widget_style' => 'style-5' ),
				'description' => esc_html__( 'Time for one full scroll loop — lower is faster.', 'captain-widgets-kit' ),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Style tab — bar.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function register_bar_style_controls(): void {

		$this->start_controls_section(
			'section_bar_style',
			array(
				'label' => esc_html__( 'Bar', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'bar_background',
				'label'    => esc_html__( 'Background', 'captain-widgets-kit' ),
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .captwiki-promo__bar',
			)
		);

		$this->add_control(
			'accent_color',
			array(
				'label'       => esc_html__( 'Accent Color', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::COLOR,
				'default'     => '',
				'selectors'   => array(
					'{{WRAPPER}} .captwiki-promo' => '--captwiki-promo-accent: {{VALUE}};',
				),
				'description' => esc_html__( 'Drives the badge, button and per-style highlights.', 'captain-widgets-kit' ),
			)
		);

		$this->add_responsive_control(
			'bar_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .captwiki-promo__bar' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'bar_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .captwiki-promo__bar' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'bar_box_shadow',
				'label'    => esc_html__( 'Box Shadow', 'captain-widgets-kit' ),
				'selector' => '{{WRAPPER}} .captwiki-promo__bar',
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Style tab — text & badge.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function register_text_style_controls(): void {

		$this->start_controls_section(
			'section_text_style',
			array(
				'label' => esc_html__( 'Text & Badge', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__text'     => 'color: {{VALUE}};',
					'{{WRAPPER}} .captwiki-promo__icon'     => 'color: {{VALUE}};',
					'{{WRAPPER}} .captwiki-promo__icon svg' => 'fill: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'text_typography',
				'label'    => esc_html__( 'Text Typography', 'captain-widgets-kit' ),
				'selector' => '{{WRAPPER}} .captwiki-promo__text',
			)
		);

		$this->add_control(
			'badge_color',
			array(
				'label'     => esc_html__( 'Badge Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__badge' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'badge_bg_color',
			array(
				'label'     => esc_html__( 'Badge Background Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__badge' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'badge_typography',
				'label'    => esc_html__( 'Badge Typography', 'captain-widgets-kit' ),
				'selector' => '{{WRAPPER}} .captwiki-promo__badge',
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Style tab — button.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function register_button_style_controls(): void {

		$this->start_controls_section(
			'section_button_style',
			array(
				'label'     => esc_html__( 'Button', 'captain-widgets-kit' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'button_text!' => '' ),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'button_typography',
				'selector' => '{{WRAPPER}} .captwiki-promo__btn',
			)
		);

		$this->start_controls_tabs( 'tabs_button_style' );

		$this->start_controls_tab(
			'tab_button_normal',
			array( 'label' => esc_html__( 'Normal', 'captain-widgets-kit' ) )
		);

		$this->add_control(
			'button_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__btn' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__btn' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_button_hover',
			array( 'label' => esc_html__( 'Hover', 'captain-widgets-kit' ) )
		);

		$this->add_control(
			'button_text_color_hover',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__btn:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_bg_color_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__btn:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_responsive_control(
			'button_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em' ),
				'separator'  => 'before',
				'selectors'  => array(
					'{{WRAPPER}} .captwiki-promo__btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'button_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .captwiki-promo__btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Style tab — close button.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function register_close_style_controls(): void {

		$this->start_controls_section(
			'section_close_style',
			array(
				'label'     => esc_html__( 'Close Button', 'captain-widgets-kit' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'dismissible' => 'yes' ),
			)
		);

		$this->add_control(
			'close_color',
			array(
				'label'     => esc_html__( 'Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__close' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'close_color_hover',
			array(
				'label'     => esc_html__( 'Hover Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-promo__close:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'close_size',
			array(
				'label'      => esc_html__( 'Size', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 10,
						'max' => 36,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .captwiki-promo' => '--captwiki-promo-close: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Capture an Elementor icon as an HTML string.
	 *
	 * @since 1.7.0
	 * @param array $icon Icon control value.
	 * @return string
	 */
	private function captwiki_get_icon_html( array $icon ): string {
		ob_start();
		Icons_Manager::render_icon( $icon, array( 'aria-hidden' => 'true' ) );
		return (string) ob_get_clean();
	}

	/**
	 * Render the badge + icon + message group.
	 *
	 * The marquee style prints this group twice ( the copy aria-hidden ) so the
	 * scroll loop is seamless.
	 *
	 * @since 1.7.0
	 * @param array $settings Widget settings.
	 * @param bool  $is_copy  Whether this is the duplicated marquee copy.
	 * @return void
	 */
	private function captwiki_render_message( array $settings, bool $is_copy = false ): void {

		$badge = isset( $settings['badge_text'] ) ? trim( (string) $settings['badge_text'] ) : '';
		$text  = isset( $settings['promo_text'] ) ? trim( (string) $settings['promo_text'] ) : '';
		$icon  = isset( $settings['promo_icon'] ) ? (array) $settings['promo_icon'] : array();

		echo '<span class="captwiki-promo__message"' . ( $is_copy ? ' aria-hidden="true"' : '' ) . '>';

		if ( '' !== $badge ) {
			echo '<span class="captwiki-promo__badge">' . esc_html( $badge ) . '</span>';
		}

		if ( ! empty( $icon['value'] ) ) {
			echo '<span class="captwiki-promo__icon" aria-hidden="true">' . $this->captwiki_get_icon_html( $icon ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}

		if ( '' !== $text ) {
			echo '<span class="captwiki-promo__text">' . esc_html( $text ) . '</span>';
		}

		echo '</span>';
	}

	/**
	 * Render the optional CTA button.
	 *
	 * @since 1.7.0
	 * @param array $settings Widget settings.
	 * @return void
	 */
	private function captwiki_render_button( array $settings ): void {

		$text = isset( $settings['button_text'] ) ? trim( (string) $settings['button_text'] ) : '';

		if ( '' === $text ) {
			return;
		}

		if ( ! empty( $settings['button_link']['url'] ) ) {
			$this->add_link_attributes( 'promo_button', $settings['button_link'] );
			$this->add_render_attribute( 'promo_button', 'class', 'captwiki-promo__btn' );

			echo '<a ' . $this->get_render_attribute_string( 'promo_button' ) . '>' . esc_html( $text ) . '</a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			return;
		}

		echo '<span class="captwiki-promo__btn">' . esc_html( $text ) . '</span>';
	}

	/**
	 * Render the dismiss button.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	private function captwiki_render_close(): void {

		echo '<button type="button" class="captwiki-promo__close" aria-label="' . esc_attr__( 'Dismiss this promotion', 'captain-widgets-kit' ) . '">'
			. '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="18" y1="6" x2="6" y2="18"></line></svg>'
			. '</button>';
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * @since 1.7.0
	 * @return void
	 */
	protected function render(): void {
		$settings = $this->get_settings_for_display();

		$allowed_styles = array_keys( $this->captwiki_style_options() );
		$style          = in_array( $settings['widget_style'], $allowed_styles, true ) ? $settings['widget_style'] : 'style-1';
		$is_editor      = \Elementor\Plugin::$instance->editor->is_edit_mode();
		$is_sticky      = 'yes' === $settings['sticky_enabled'];
		$position       = 'bottom' === $settings['bar_position'] ? 'bottom' : 'top';
		$push           = $is_sticky && 'yes' === $settings['push_content'] ? 'yes' : 'no';
		$dismissible    = 'yes' === $settings['dismissible'];
		$remember       = $dismissible ? absint( $settings['remember_days'] ) : 0;
		$is_marquee     = 'style-5' === $style;

		// Load only the active style stylesheet, depending on the common one.
		wp_enqueue_style(
			'captwiki-sticky-promo-bar-' . $style,
			CAPTWIKI_URL . 'assets/css/widgets/sticky-promo-bar/captwiki-sticky-promo-bar-' . $style . '.css',
			array( 'captwiki_sticky_promo_bar' ),
			CAPTWIKI_VERSION
		);

		$classes = 'captwiki-promo captwiki-' . $style . ' captwiki-promo--' . $position;

		if ( $is_sticky ) {
			$classes .= ' captwiki-promo--fixed';
		}

		if ( $is_editor ) {
			$classes .= ' captwiki-promo--editor';
		}

		if ( $dismissible ) {
			$classes .= ' captwiki-promo--dismissible';
		}

		printf(
			'<div class="%1$s" data-promo-id="%2$s" data-push="%3$s" data-remember="%4$d" role="region" aria-label="%5$s">',
			esc_attr( $classes ),
			esc_attr( $this->get_id() ),
			esc_attr( $push ),
			esc_attr( $remember ),
			esc_attr__( 'Promotion', 'captain-widgets-kit' )
		);

		echo '<div class="captwiki-promo__bar">';

		if ( $is_marquee ) {
			echo '<div class="captwiki-promo__marquee"><div class="captwiki-promo__marquee-track">';
			$this->captwiki_render_message( $settings );
			$this->captwiki_render_message( $settings, true );
			echo '</div></div>';
		} else {
			$this->captwiki_render_message( $settings );
		}

		$this->captwiki_render_button( $settings );

		if ( $dismissible ) {
			$this->captwiki_render_close();
		}

		echo '</div>';
		echo '</div>';
	}
}
