<?php
/**
 * WPBakery Page Builder Integration
 *
 * Registers the Business Hours element for WPBakery Page Builder.
 *
 * @package ID_Business_Listing
 * @license GPL-2.0-or-later
 */

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

class BLM_WPBakery {

    public function __construct() {
        if ( function_exists( 'vc_map' ) ) {
            add_action( 'vc_before_init', array( $this, 'register_element' ) );
        }
    }

    public function register_element() {
        vc_map( array(
            'name'        => __( 'Business Hours', 'id-business-listing' ),
            'base'        => 'business_hours',
            'description' => __( 'Display your business hours', 'id-business-listing' ),
            'category'    => __( 'Content', 'id-business-listing' ),
            'icon'        => 'dashicons dashicons-clock',
            'params'      => array(
                array(
                    'type'        => 'dropdown',
                    'heading'     => __( 'Show Closed Days', 'id-business-listing' ),
                    'param_name'  => 'show_closed',
                    'value'       => array(
                        __( 'Yes', 'id-business-listing' ) => 'yes',
                        __( 'No', 'id-business-listing' )  => 'no',
                    ),
                    'std'         => 'yes',
                    'description' => __( 'Show days the business is closed.', 'id-business-listing' ),
                ),
                array(
                    'type'        => 'dropdown',
                    'heading'     => __( 'Highlight Today', 'id-business-listing' ),
                    'param_name'  => 'highlight_today',
                    'value'       => array(
                        __( 'Yes', 'id-business-listing' ) => 'yes',
                        __( 'No', 'id-business-listing' )  => 'no',
                    ),
                    'std'         => 'yes',
                    'description' => __( 'Highlight the current day.', 'id-business-listing' ),
                ),
                array(
                    'type'        => 'dropdown',
                    'heading'     => __( 'Time Format', 'id-business-listing' ),
                    'param_name'  => 'time_format',
                    'value'       => array(
                        __( '12-hour (9:00 AM)', 'id-business-listing' ) => '12',
                        __( '24-hour (09:00)', 'id-business-listing' )   => '24',
                    ),
                    'std'         => '12',
                    'description' => __( 'Time display format.', 'id-business-listing' ),
                ),
                array(
                    'type'        => 'textfield',
                    'heading'     => __( 'CSS Class', 'id-business-listing' ),
                    'param_name'  => 'class',
                    'description' => __( 'Additional CSS class for styling.', 'id-business-listing' ),
                ),
            ),
        ) );
    }
}
