register_countdown_section(); $this->register_display_section(); $this->register_expiry_section(); $this->register_style_section(); $this->register_style_labels_section(); $this->eppro_register_entrance_animation_controls(); } // ── Countdown Settings ──────────────────────────────────────────────────── private function register_countdown_section(): void { $this->start_controls_section( 'section_countdown', [ 'label' => __( 'Countdown', 'admore-widgets-suite' ), ] ); $this->add_control( 'countdown_type', [ 'label' => __( 'Type', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'fixed', 'options' => [ 'fixed' => __( 'Fixed Date', 'admore-widgets-suite' ), 'evergreen' => __( 'Evergreen', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'due_date', [ 'label' => __( 'Due Date', 'admore-widgets-suite' ), 'type' => Controls_Manager::DATE_TIME, 'default' => gmdate( 'Y-m-d H:i', strtotime( '+7 days' ) ), 'condition' => [ 'countdown_type' => 'fixed' ], ] ); $this->add_control( 'evergreen_hours', [ 'label' => __( 'Hours', 'admore-widgets-suite' ), 'type' => Controls_Manager::NUMBER, 'default' => 47, 'min' => 0, 'condition' => [ 'countdown_type' => 'evergreen' ], ] ); $this->add_control( 'evergreen_minutes', [ 'label' => __( 'Minutes', 'admore-widgets-suite' ), 'type' => Controls_Manager::NUMBER, 'default' => 59, 'min' => 0, 'max' => 59, 'condition' => [ 'countdown_type' => 'evergreen' ], ] ); $this->add_control( 'evergreen_restart', [ 'label' => __( 'Restart After Expiry', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'condition' => [ 'countdown_type' => 'evergreen' ], 'description' => __( 'Resets the countdown for each visitor after it ends.', 'admore-widgets-suite' ), ] ); $this->end_controls_section(); } // ── Display ─────────────────────────────────────────────────────────────── private function register_display_section(): void { $this->start_controls_section( 'section_display', [ 'label' => __( 'Display', 'admore-widgets-suite' ), ] ); $this->add_control( 'countdown_style', [ 'label' => __( 'Style', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'boxes', 'options' => [ 'boxes' => __( 'Boxes', 'admore-widgets-suite' ), 'inline' => __( 'Inline', 'admore-widgets-suite' ), 'circle' => __( 'Circles', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'show_days', [ 'label' => __( 'Show Days', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->add_control( 'show_hours', [ 'label' => __( 'Show Hours', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->add_control( 'show_minutes', [ 'label' => __( 'Show Minutes', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->add_control( 'show_seconds', [ 'label' => __( 'Show Seconds', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->add_control( 'label_days', [ 'label' => __( 'Days Label', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Days', 'admore-widgets-suite' ), 'condition' => [ 'show_days' => 'yes' ], ] ); $this->add_control( 'label_hours', [ 'label' => __( 'Hours Label', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Hours', 'admore-widgets-suite' ), 'condition' => [ 'show_hours' => 'yes' ], ] ); $this->add_control( 'label_minutes', [ 'label' => __( 'Minutes Label', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Minutes', 'admore-widgets-suite' ), 'condition' => [ 'show_minutes' => 'yes' ], ] ); $this->add_control( 'label_seconds', [ 'label' => __( 'Seconds Label', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Seconds', 'admore-widgets-suite' ), 'condition' => [ 'show_seconds' => 'yes' ], ] ); $this->add_control( 'separator', [ 'label' => __( 'Separator', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => ':', ] ); $this->add_responsive_control( 'alignment', [ 'label' => __( 'Alignment', 'admore-widgets-suite' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'flex-start' => [ 'title' => __( 'Left', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-left' ], 'center' => [ 'title' => __( 'Center', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-center' ], 'flex-end' => [ 'title' => __( 'Right', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-right' ], ], 'default' => 'center', 'selectors' => [ '{{WRAPPER}} .eppro-cd-wrap' => 'justify-content: {{VALUE}};' ], ] ); $this->end_controls_section(); } // ── Expiry Action ───────────────────────────────────────────────────────── private function register_expiry_section(): void { $this->start_controls_section( 'section_expiry', [ 'label' => __( 'On Expiry', 'admore-widgets-suite' ), ] ); $this->add_control( 'expiry_action', [ 'label' => __( 'Action', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'hide', 'options' => [ 'none' => __( 'Keep Showing 00:00', 'admore-widgets-suite' ), 'hide' => __( 'Hide Countdown', 'admore-widgets-suite' ), 'message' => __( 'Show Message', 'admore-widgets-suite' ), 'redirect' => __( 'Redirect', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'expiry_message', [ 'label' => __( 'Message', 'admore-widgets-suite' ), 'type' => Controls_Manager::WYSIWYG, 'default' => __( 'This offer has expired!', 'admore-widgets-suite' ), 'condition' => [ 'expiry_action' => 'message' ], ] ); $this->add_control( 'expiry_redirect_url', [ 'label' => __( 'Redirect URL', 'admore-widgets-suite' ), 'type' => Controls_Manager::URL, 'condition' => [ 'expiry_action' => 'redirect' ], ] ); $this->end_controls_section(); } // ── Style: Digits ───────────────────────────────────────────────────────── private function register_style_section(): void { $this->start_controls_section( 'style_digits', [ 'label' => __( 'Digits', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'digit_typography', 'selector' => '{{WRAPPER}} .eppro-cd-digit', ] ); $this->add_control( 'digit_color', [ 'label' => __( 'Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#1f2937', 'selectors' => [ '{{WRAPPER}} .eppro-cd-digit' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'box_bg', [ 'label' => __( 'Box Background', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#f3f4f6', 'selectors' => [ '{{WRAPPER}} .eppro-cd-block' => 'background: {{VALUE}};' ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'box_border', 'selector' => '{{WRAPPER}} .eppro-cd-block', ] ); $this->add_responsive_control( 'box_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-block' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'box_shadow', 'selector' => '{{WRAPPER}} .eppro-cd-block', ] ); $this->add_responsive_control( 'box_padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'default' => [ 'top' => '16', 'right' => '20', 'bottom' => '16', 'left' => '20', 'unit' => 'px', 'isLinked' => false ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-block' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->add_responsive_control( 'box_gap', [ 'label' => __( 'Gap Between Blocks', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 60 ] ], 'default' => [ 'size' => 16 ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-wrap' => 'gap: {{SIZE}}{{UNIT}};' ], ] ); $this->add_control( 'separator_color', [ 'label' => __( 'Separator Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-cd-sep' => 'color: {{VALUE}};' ], 'separator' => 'before', ] ); $this->add_responsive_control( 'separator_size', [ 'label' => __( 'Separator Size', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 10, 'max' => 60 ] ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-sep' => 'font-size: {{SIZE}}{{UNIT}};' ], ] ); $this->add_responsive_control( 'box_min_width', [ 'label' => __( 'Block Min Width', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 40, 'max' => 200 ] ], 'default' => [ 'size' => 80 ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-block' => 'min-width: {{SIZE}}{{UNIT}};' ], 'separator' => 'before', ] ); $this->add_responsive_control( 'circle_size', [ 'label' => __( 'Circle Size', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 60, 'max' => 200 ] ], 'default' => [ 'size' => 100 ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-style-circle .eppro-cd-block' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ], 'condition' => [ 'countdown_style' => 'circle' ], ] ); $this->add_control( 'circle_border_color', [ 'label' => __( 'Circle Border Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#e5e7eb', 'selectors' => [ '{{WRAPPER}} .eppro-cd-style-circle .eppro-cd-block' => 'border: 3px solid {{VALUE}};' ], 'condition' => [ 'countdown_style' => 'circle' ], ] ); $this->end_controls_section(); } // ── Style: Labels ───────────────────────────────────────────────────────── private function register_style_labels_section(): void { $this->start_controls_section( 'style_labels', [ 'label' => __( 'Labels', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'label_typography', 'selector' => '{{WRAPPER}} .eppro-cd-label', ] ); $this->add_control( 'label_color', [ 'label' => __( 'Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#6b7280', 'selectors' => [ '{{WRAPPER}} .eppro-cd-label' => 'color: {{VALUE}};' ], ] ); $this->add_responsive_control( 'label_spacing', [ 'label' => __( 'Top Spacing', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 24 ] ], 'default' => [ 'size' => 4 ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-label' => 'margin-top: {{SIZE}}{{UNIT}};' ], ] ); $this->add_control( 'hide_labels', [ 'label' => __( 'Hide Labels', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'selectors' => [ '{{WRAPPER}} .eppro-cd-label' => 'display: none;' ], ] ); $this->end_controls_section(); // ── Style: Expiry Message ───────────────────────────────────────────── $this->start_controls_section( 'style_expiry_message', [ 'label' => __( 'Expiry Message', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'expiry_action' => 'message' ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'expiry_msg_typography', 'selector' => '{{WRAPPER}} .eppro-cd-expiry-message', ] ); $this->add_control( 'expiry_msg_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-cd-expiry-message' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'expiry_msg_bg', [ 'label' => __( 'Background', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-cd-expiry-message' => 'background: {{VALUE}};' ], ] ); $this->add_responsive_control( 'expiry_msg_padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-expiry-message' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->add_responsive_control( 'expiry_msg_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px' ], 'selectors' => [ '{{WRAPPER}} .eppro-cd-expiry-message' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->end_controls_section(); } // ========================================================================= // Render // ========================================================================= protected function render(): void { $s = $this->get_settings_for_display(); $type = $s['countdown_type'] ?? 'fixed'; $style = sanitize_key( $s['countdown_style'] ?? 'boxes' ); $show_days = 'yes' === ( $s['show_days'] ?? 'yes' ); $show_hours = 'yes' === ( $s['show_hours'] ?? 'yes' ); $show_minutes = 'yes' === ( $s['show_minutes'] ?? 'yes' ); $show_seconds = 'yes' === ( $s['show_seconds'] ?? 'yes' ); $separator = (string) ( $s['separator'] ?? ':' ); $expiry = sanitize_key( $s['expiry_action'] ?? 'hide' ); // Calculate target timestamp. The date picker stores local site time, // so parse it in the site's timezone (strtotime() would assume UTC). $target_ts = 0; // Evergreen: the script handles it via localStorage. if ( 'fixed' === $type && ! empty( $s['due_date'] ) ) { try { $target_ts = ( new \DateTimeImmutable( (string) $s['due_date'], wp_timezone() ) )->getTimestamp(); } catch ( \Exception $e ) { $target_ts = 0; } } $data = wp_json_encode( [ 'type' => $type, 'targetTs' => $target_ts, 'evHours' => absint( $s['evergreen_hours'] ?? 47 ), 'evMinutes' => absint( $s['evergreen_minutes'] ?? 59 ), 'evRestart' => 'yes' === ( $s['evergreen_restart'] ?? '' ), 'expiry' => $expiry, // Only http(s) URLs — a "javascript:" URL here would run when the timer ends. 'redirectUrl' => esc_url_raw( (string) ( $s['expiry_redirect_url']['url'] ?? '' ), [ 'http', 'https' ] ), ], JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); $units = []; if ( $show_days ) $units[] = [ 'key' => 'days', 'label' => $s['label_days'] ?? __( 'Days', 'admore-widgets-suite' ) ]; if ( $show_hours ) $units[] = [ 'key' => 'hours', 'label' => $s['label_hours'] ?? __( 'Hours', 'admore-widgets-suite' ) ]; if ( $show_minutes ) $units[] = [ 'key' => 'minutes', 'label' => $s['label_minutes'] ?? __( 'Minutes', 'admore-widgets-suite' ) ]; if ( $show_seconds ) $units[] = [ 'key' => 'seconds', 'label' => $s['label_seconds'] ?? __( 'Seconds', 'admore-widgets-suite' ) ]; ?>
$unit ) : ?> 0 && $separator ) : ?>
00