admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'ab_veh_take_nonce' ), ); wp_localize_script( 'abvt-frontend', 'ABVT_DATA', $data ); } public function maybe_enqueue() { global $post; if ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'ab_veh_take_form' ) ) { $this->enqueue_assets(); } } public function enqueue_assets() { $this->register_assets(); wp_enqueue_style( 'abvt-frontend' ); wp_enqueue_script( 'abvt-frontend' ); } public function get_effective_settings( $overrides = array() ) { $settings = AB_Veh_Take_Settings::get_all(); foreach ( (array) $overrides as $key => $value ) { if ( is_scalar( $value ) && '' !== $value && array_key_exists( $key, $settings ) ) { $settings[ $key ] = sanitize_text_field( (string) $value ); } } foreach ( AB_Veh_Take_Settings::color_fields() as $key => $field ) { $color = is_scalar( $settings[ $key ] ) ? sanitize_hex_color( (string) $settings[ $key ] ) : false; $settings[ $key ] = $color ?: $field['default']; } foreach ( array_merge( AB_Veh_Take_Settings::text_fields(), AB_Veh_Take_Settings::content_fields() ) as $key => $field ) { $value = is_scalar( $settings[ $key ] ) ? (string) $settings[ $key ] : ''; $settings[ $key ] = sanitize_text_field( $value ); if ( '' === $settings[ $key ] ) { $settings[ $key ] = $field['default']; } } foreach ( AB_Veh_Take_Settings::layout_fields() as $key => $field ) { $value = is_scalar( $settings[ $key ] ) ? (int) $settings[ $key ] : (int) $field['default']; $settings[ $key ] = max( $field['min'], min( $field['max'], $value ) ); } foreach ( AB_Veh_Take_Settings::typography_fields() as $key => $field ) { $value = is_scalar( $settings[ $key ] ) ? sanitize_text_field( (string) $settings[ $key ] ) : ''; if ( 'font_family' === $key ) { $settings[ $key ] = preg_replace( '/[^a-zA-Z0-9 ,_-]/', '', $value ); } elseif ( false !== strpos( $key, 'weight' ) ) { $settings[ $key ] = in_array( $value, array( '300', '400', '500', '600', '700', '800', '900' ), true ) ? $value : $field['default']; } else { $settings[ $key ] = max( $field['min'], min( $field['max'], (float) $value ) ); } } $settings['notification_email'] = is_scalar( $settings['notification_email'] ) && is_email( $settings['notification_email'] ) ? $settings['notification_email'] : get_option( 'admin_email' ); return $settings; } public function get_effective_vehicle_types( $overrides = array() ) { if ( ! empty( $overrides['vehicle_types'] ) && is_array( $overrides['vehicle_types'] ) ) { $types = array_values( array_unique( array_filter( array_map( 'trim', array_map( 'sanitize_text_field', array_filter( $overrides['vehicle_types'], 'is_scalar' ) ) ) ) ) ); if ( ! empty( $types ) ) { return $types; } } return AB_Veh_Take_Settings::get_vehicle_types(); } private function build_scoped_color_css( $settings ) { $map = array( '--actb-bg' => $settings['color_bg'], '--actb-panel' => $settings['color_panel'], '--actb-panel-2' => $settings['color_panel_2'], '--actb-border' => $settings['color_border'], '--actb-text' => $settings['color_text'], '--actb-text-muted' => $settings['color_text_muted'], '--actb-accent' => $settings['color_accent'], '--actb-accent-light' => $settings['color_accent_light'], '--actb-accent-dark' => $settings['color_accent_dark'], '--actb-icon' => $settings['color_icon'], '--actb-success' => $settings['color_success'], '--actb-warning' => $settings['color_warning'], '--actb-danger' => $settings['color_danger'], '--actb-disabled' => $settings['color_disabled'], '--actb-btn-text' => $settings['color_button_text'], ); $css = ''; foreach ( $map as $var => $value ) { $css .= esc_attr( $var ) . ':' . esc_attr( $value ) . ';'; } $css .= '--actb-max-width:' . esc_attr( $settings['form_max_width'] ) . 'px;'; $css .= '--actb-card-padding:' . esc_attr( $settings['card_padding'] ) . 'px;'; $css .= '--actb-field-gap:' . esc_attr( $settings['field_gap'] ) . 'px;'; $css .= '--actb-input-font-size:' . esc_attr( $settings['input_font_size'] ) . 'px;'; $css .= '--actb-border-radius:' . esc_attr( $settings['border_radius'] ) . 'px;'; $css .= '--actb-font-family:' . esc_attr( $settings['font_family'] ) . ';'; $css .= '--actb-font-size:' . esc_attr( $settings['font_size'] ) . 'px;'; $css .= '--actb-font-weight:' . esc_attr( $settings['font_weight'] ) . ';'; $css .= '--actb-heading-size:' . esc_attr( $settings['heading_size'] ) . 'px;'; $css .= '--actb-heading-weight:' . esc_attr( $settings['heading_weight'] ) . ';'; $css .= '--actb-label-size:' . esc_attr( $settings['label_size'] ) . 'px;'; $css .= '--actb-label-weight:' . esc_attr( $settings['label_weight'] ) . ';'; $css .= '--actb-button-size:' . esc_attr( $settings['button_size'] ) . 'px;'; $css .= '--actb-button-weight:' . esc_attr( $settings['button_weight'] ) . ';'; $css .= '--actb-letter-spacing:' . esc_attr( $settings['letter_spacing'] ) . 'px;'; $css .= '--actb-heading-spacing:' . esc_attr( $settings['heading_spacing'] ) . 'px;'; $css .= '--actb-line-height:' . esc_attr( $settings['line_height'] ) . ';'; return $css; } public function render( $atts ) { return $this->render_form( array() ); } public function render_form( $overrides = array() ) { $this->enqueue_assets(); $settings = $this->get_effective_settings( $overrides ); $vehicle_types = $this->get_effective_vehicle_types( $overrides ); $instance_id = substr( md5( wp_generate_uuid4() ), 0, 10 ); ob_start(); ?>
1
2
3
'; } private static function allowed_svg_html() { return array( 'span' => array( 'class' => true, 'aria-hidden' => true, ), 'svg' => array( 'viewBox' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'width' => true, 'height' => true, ), 'path' => array( 'd' => true ), 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true ), 'rect' => array( 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true ), ); } private function icon_pin() { return ''; } private function icon_target() { return ''; } private function icon_plus() { return ''; } private function icon_calendar() { return ''; } private function icon_chevron_left() { return ''; } private function icon_chevron_right() { return ''; } private function icon_clock() { return ''; } private function icon_user() { return ''; } private function icon_check() { return ''; } }