function cost_calculator_input_box_shortcode($atts) { extract(shortcode_atts(array( "id" => "input-box", "name" => "input-box", "label" => "", "hide_label" => 0, "default_value" => "", "type" => "text", "checked" => "1", "checkbox_type" => "type-button", "checkbox_yes" => __("checked", 'cost-calculator'), "checkbox_no" => __("not checked", 'cost-calculator'), "group_label" => "", "placeholder" => "", "required" => 0, "required_message" => __("This field is required", 'cost-calculator'), "after_pseudo" => "", "top_margin" => "none", "el_class" => "", "aria_description" => "", "aria_label" => "" // Ny parameter för aria-label ), $atts)); $checked = (isset($_POST[$name]) && $_POST[$name]==$default_value ? 1 : $checked); $input_value = (isset($_POST[$name]) ? $_POST[$name] : $default_value); $output = ""; // Skapa unikt ID för att undvika duplicering $unique_id = esc_attr($id) . '-' . uniqid(); // Förbättrade accessibility attribut $required_attr = (int)$required ? ' required aria-required="true"' : ''; $aria_invalid = ' aria-invalid="false"'; // Förbättrad aria-label hantering - prioritera explicit aria-label, sedan vanlig label $aria_label_attr = ''; if (!empty($aria_label)) { $aria_label_attr = ' aria-label="' . esc_attr($aria_label) . '"'; } elseif ($label && ((int)$hide_label || $type == "radio" || ($type == "checkbox" && $checkbox_type == "type-button"))) { $aria_label_attr = ' aria-label="' . esc_attr($label) . '"'; } // Lägg till aria-describedby om beskrivning finns $aria_describedby = $aria_description ? ' aria-describedby="' . esc_attr($aria_description) . '"' : ''; if($type!="hidden" && $type!="submit") $output .= '
'; // Förbättrad label-hantering - alltid generera label för tillgänglighet if($type!="hidden" && $type!="submit") { if($label!="" && ($type!="checkbox" || ($type=="checkbox" && $checkbox_type=="default"))) { $label_class = (int)$hide_label || $type=="radio" ? 'cost-calculator-hidden' : ''; $output .= ''; } // För dolda labels, se till att aria-label finns if($label!="" && (int)$hide_label && $type!="checkbox" && $type!="radio" && empty($aria_label)) { $aria_label_attr = ' aria-label="' . esc_attr($label) . '"'; } } if($label!="" && $type!="submit") $output .= ''; if($type=="date") $output .= '
'; if($type=="submit") $output .= '
'; // Uppdaterad input med förbättrade accessibility-attribut $output .= ''; // Förbättrad checkbox/radio label if($type=="checkbox") { $checkbox_label_class = 'cost-calculator-checkbox-label' . ($checkbox_type=="default" ? ' cost-calculator-checkbox-default' : '') . ($el_class!="" ? ' ' . esc_attr($el_class) : ''); $output .= ''; } if($type=="radio") { $radio_label_class = 'cost-calculator-radio-label' . ($el_class!="" ? ' ' . esc_attr($el_class) : ''); $output .= ''; } if($type=="checkbox") $output .= ''; if($type=="radio" && $label!="") $output .= ''; if(!empty($after_pseudo)) { $output .= ''; } if($type=="date" || $type=="submit") $output .= '
'; if($type!="hidden" && $type!="submit") $output .= '
'; return $output; } add_shortcode("cost_calculator_input_box", "cost_calculator_input_box_shortcode"); if(is_plugin_active($js_composer_path) && function_exists('vc_map')) { //visual composer vc_map( array( "name" => __("Cost calculator input box", 'cost-calculator'), "base" => "cost_calculator_input_box", "class" => "", "controls" => "full", "show_settings_on_create" => true, "icon" => "icon-wpb-layer-cost-calculator-input-box", "category" => __('Cost Calculator', 'cost-calculator'), "params" => array( array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => __("Id", 'cost-calculator'), "param_name" => "id", "value" => "input-box", "description" => __("Please provide unique id for each 'Cost calculator input box' on your page.", 'cost-calculator') ), array( "type" => "textfield", "class" => "", "heading" => __("Input name", 'cost-calculator'), "param_name" => "name", "value" => "input-box" ), array( "type" => "dropdown", "class" => "", "heading" => __("Type", 'cost-calculator'), "param_name" => "type", "value" => array(__("text", 'cost-calculator') => "text", __("number", 'cost-calculator') => "number", __("date", 'cost-calculator') => "date", __("email", 'cost-calculator') => "email", __("checkbox", 'cost-calculator') => "checkbox", __("radio", 'cost-calculator') => "radio", __("hidden", 'cost-calculator') => "hidden", __("submit", 'cost-calculator') => "submit") ), array( "type" => "textfield", "class" => "", "heading" => __("Label", 'cost-calculator'), "param_name" => "label", "value" => "" ), array( "type" => "dropdown", "class" => "", "heading" => __("Hide label", 'cost-calculator'), "param_name" => "hide_label", "value" => array(__("No", 'cost-calculator') => 0, __("Yes", 'cost-calculator') => 1), "description" => __("Set to 'Yes' if you won't like to display label in the frontend but you still like to receive field value via email", 'cost-calculator'), "dependency" => Array('element' => "type", 'value' => array("text", "number", "date", "email")) ), array( "type" => "textfield", "class" => "", "heading" => __("Group label", 'cost-calculator'), "param_name" => "group_label", "value" => "", "dependency" => Array('element' => "type", 'value' => "radio") ), array( "type" => "textfield", "class" => "", "heading" => __("Default value", 'cost-calculator'), "param_name" => "default_value", "value" => "" ), array( "type" => "dropdown", "class" => "", "heading" => __("Is checked", 'cost-calculator'), "param_name" => "checked", "value" => array(__("yes", 'cost-calculator') => "1", __("no", 'cost-calculator') => "0"), "dependency" => Array('element' => "type", 'value' => array("checkbox", "radio")), "std" => 0 ), array( "type" => "dropdown", "class" => "", "heading" => __("Checkbox type", 'cost-calculator'), "param_name" => "checkbox_type", "value" => array(__("Button", 'cost-calculator') => "type-button", __("Default", 'cost-calculator') => "default"), "dependency" => Array('element' => "type", 'value' => "checkbox") ), array( "type" => "textfield", "class" => "", "heading" => __("Checked hidden text", 'cost-calculator'), "param_name" => "checkbox_yes", "value" => __("checked", 'cost-calculator'), "dependency" => Array('element' => "type", 'value' => "checkbox") ), array( "type" => "textfield", "class" => "", "heading" => __("Not checked hidden text", 'cost-calculator'), "param_name" => "checkbox_no", "value" => __("not checked", 'cost-calculator'), "dependency" => Array('element' => "type", 'value' => "checkbox") ), array( "type" => "textfield", "class" => "", "heading" => __("Placeholder", 'cost-calculator'), "param_name" => "placeholder", "value" => "" ), array( "type" => "dropdown", "class" => "", "heading" => __("Required", 'cost-calculator'), "param_name" => "required", "value" => array(__("Yes", 'cost-calculator') => 1, __("No", 'cost-calculator') => 0), "std" => 0, "dependency" => Array('element' => "type", 'value' => array("text", "number", "date", "email", "checkbox")) ), array( "type" => "textfield", "class" => "", "heading" => __("Required field message", 'cost-calculator'), "param_name" => "required_message", "value" => __("This field is required", 'cost-calculator'), "dependency" => Array('element' => "required", 'value' => "1") ), array( "type" => "textfield", "class" => "", "heading" => __("After pseudo element css class", 'cost-calculator'), "param_name" => "after_pseudo", "value" => "" ), array( "type" => "dropdown", "class" => "", "heading" => __("Top margin", 'cost-calculator'), "param_name" => "top_margin", "value" => array(__("None", 'cost-calculator') => "none", __("Small", 'cost-calculator') => "page-margin-top", __("Large", 'cost-calculator') => "page-margin-top-section") ), array( 'type' => 'textfield', 'heading' => __( 'Extra class name', 'cost-calculator' ), 'param_name' => 'el_class', 'description' => __( 'If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'cost-calculator' ) ) ) )); } ?> Noggrann städning Göteborg - Flyttstädning Expert | Hestia