Alex Reservations widget ID=' . $atts['id'] . ' will be displayed here.'; } $atts = shortcode_atts( array( 'id' => 0, // Widget id 'booking_uuid' => false, // Booking uuid to change 'button' => __eva('Book now'), 'mode' => 'service', 'embed' => 'no', 'hide_button' => 'no', // mode = time => user selects party,date,time // mode = service => user selects party,date,service, ), $atts); // Sanitize all attributes $id = absint($atts['id']); $booking_uuid = sanitize_text_field($atts['booking_uuid']); $button = esc_html($atts['button']); $mode = in_array($atts['mode'], array('service', 'time')) ? $atts['mode'] : 'service'; $embed = in_array(strtolower($atts['embed']), array('yes', 'no')) ? strtolower($atts['embed']) : 'no'; $hide_button = in_array(strtolower($atts['hide_button']), array('yes', 'no')) ? strtolower($atts['hide_button']) : 'no'; $w_form = \Alexr\Settings\WidgetForm::where('id', $id)->first(); $restaurant_id = $w_form ? absint($w_form->restaurant_id) : 0; // Add some random number to generate unique identifier for the button // so can put the same buttons 2 times in the same page $form_id = $id.'-'.\Evavel\Support\Str::upper(\Evavel\Support\Str::random(8)); // Elegir entre div y span segĂșn el valor de embed $element_tag = ($embed === 'yes') ? 'div' : 'span'; // Agregar clase adicional segĂșn el valor de embed $additional_class = ($embed === 'yes') ? 'app-widget-embeded' : 'app-widget-button'; // Create secure HTML $html = sprintf( '<%1$s class="alexr-widget-wrap app-restaurant-form %11$s" id="app-restaurant-form-%2$s" data-embed="%3$s" data-nonce="%4$s" data-widget="%5$s" data-restaurant="%6$s" data-hide_button="%7$s" data-button="%8$s" data-mode="%9$s" data-booking_uuid="%10$s">', esc_attr($element_tag), esc_attr($form_id), esc_attr($embed), esc_attr(evavel_tenant_create_nonce($restaurant_id)), esc_attr($id), esc_attr($restaurant_id), esc_attr($hide_button), esc_attr($button), esc_attr($mode), esc_attr($booking_uuid), esc_attr($additional_class) ); $widget_dir = ALEXR_PLUGIN_URL . 'assets/widget-mix/'; $widget_version = ALEXR_VERSION; if (defined('ALEXR_PRO_PLUGIN_URL')) { $widget_dir = ALEXR_PRO_PLUGIN_URL . 'assets/widget-mix/'; } if (defined('ALEXR_PRO_VERSION')) { $widget_version = ALEXR_PRO_VERSION; } $assets_url = ALEXR_PLUGIN_URL.'assets/'; wp_enqueue_style( 'restaurant-form', $widget_dir.'index.css' , array(), $widget_version ); alexr_enqueue_widget_custom_css($w_form, $widget_version); wp_enqueue_script('srr-windowsfet-js', $assets_url.'js/windowSfet.js', array(), ALEXR_VERSION, true); wp_enqueue_script('srr-crypto-js', $assets_url.'js/crypto-js.min.js', array(), ALEXR_VERSION, true); wp_enqueue_script( 'restaurant-form-main', $widget_dir . 'main.js', array('srr-windowsfet-js','srr-crypto-js'), $widget_version, true ); wp_localize_script('restaurant-form-main', 'rr_config', alexr_get_config()); wp_localize_script('restaurant-form-main', 'rr_translations', alexr_get_translations()); do_action('alexr-shortcode-after-scripts', $w_form); return $html; } function alexr_enqueue_widget_custom_css($w_form, $version) { if (!isset($w_form->form_config['custom_css'])) { return; } $custom_css = $w_form->form_config['custom_css']; if (is_string($custom_css) && strlen($custom_css) > 10) { wp_enqueue_style('restaurant-form-custom-css',$custom_css, array(), $version ); } } /* function alexr_restaurant_reservation_form_scripts() { global $wp_version, $post; if ( !isset($post->post_content) ) return; $widget_dir = ALEXR_PLUGIN_URL . 'assets/widget-mix/'; $widget_version = ALEXR_VERSION; if (defined('ALEXR_PRO_PLUGIN_URL')) { $widget_dir = ALEXR_PRO_PLUGIN_URL . 'assets/widget-mix/'; } if (defined('ALEXR_PRO_VERSION')) { $widget_version = ALEXR_PRO_VERSION; } if (has_shortcode($post->post_content, 'rr_form')) { wp_enqueue_style( 'restaurant-form', $widget_dir.'index.css' , array(), $widget_version ); wp_enqueue_script( 'restaurant-form-main', $widget_dir . 'main.js', array( ), $widget_version, true ); wp_localize_script('restaurant-form-main', 'rr_config', alexr_get_config()); wp_localize_script('restaurant-form-main', 'rr_translations', alexr_get_translations()); } } */