';
// $output .= '';
return $output;
}
}
/**
* @action wp_ajax_vc_get_autocomplete_suggestion - since 4.4 used to hook ajax requests for autocomplete suggestions
*/
//add_action( 'wp_ajax_vc_get_autocomplete_suggestion', 'vc_get_autocomplete_suggestion' );
/**
* Function for rendering param in edit form (add element)
* Parse settings from vc_map and entered values.
*
* @param $settings
* @param $value
* @param $tag
*
* @since 4.4
* vc_filter: vc_autocomplete_render_filter - hook to override output of edit for field "autocomplete"
* @return mixed|void rendered template for params in edit form
*/
function vc_autocomplete_form_field( $settings, $value, $tag=false ) {
$auto_complete = new Vc_AutoComplete( $settings, $value, $tag );
return $auto_complete->render();
// return apply_filters( 'vc_autocomplete_render_filter', $auto_complete->render() );
}
// Some examples
/* vc_map(
array(
'name' => __( 'Check autocomplete', 'js_composer' ),
'base' => 'vc_some_autocomplete',
'icon' => 'icon-wpb-empty_space',
'category' => __( 'New Elements', 'js_composer' ),
'description' => __( 'Something cool and best', 'js_composer' ),
'params' => array(
array(
'type' => 'autocomplete',
'heading' => __( 'Type a for example', 'js_composer' ),
'param_name' => 'ids',
'settings' => array(
'multiple' => true,
'sortable' => true,
'min_length' => 1,
'no_hide' => true, // In UI after select doesn't hide an select list
'groups' => true, // In UI show results grouped by groups
'unique_values' => true, // In UI show results except selected. NB! You should manually check values in backend
'display_inline' => true, // In UI show results inline view
'values' => array( // Using key 'values' will disable an AJAX requests on autocomplete input and also any filter for suggestions
array( 'label' => 'Abrams', 'value' => 1, 'group' => 'category' ),
array( 'label' => 'Brama', 'value' => 2, 'group' => 'category' ),
array( 'label' => 'Dron', 'value' => 3, 'group' => 'tags' ),
array( 'label' => 'Akelloam', 'value' => 4, 'group' => 'tags' ),
// Label will show when adding
// Value will saved in input
// Group only used if groups=>true, this will group data in select dropdown by groups
),
),
'description' => __( '', 'js_composer' ),
),
),
)
);
// Or with AJAX suggester:
See \js_composer\include\classes\vendors\plugins\class-vc-vendor-woocommerce.php
vc_map( array(
'name' => __( 'Product', 'js_composer' ),
'base' => 'product',
'icon' => 'icon-wpb-woocommerce',
'category' => __( 'WooCommerce', 'js_composer' ),
'description' => __( 'Show a single product by ID or SKU', 'js_composer' ),
'params' => array(
array(
'type' => 'autocomplete',
'heading' => __( 'Select identificator', 'js_composer' ),
'param_name' => 'id',
'description' => __( 'Input product ID or product SKU or product title to see suggestions', 'js_composer' ),
),
array(
'type' => 'hidden',
// This will not show on render, but will be used when defining value for autocomplete
'param_name' => 'sku',
),
)
) );
//Filters For autocomplete param:
//For suggestion: vc_autocomplete_[shortcode_name]_[param_name]_callback
add_filter( 'vc_autocomplete_product_id_callback', array(
&$this,
'productIdAutocompleteSuggester'
), 10, 1 ); // Get suggestion(find). Must return an array
add_filter( 'vc_autocomplete_product_id_render', array(
&$this,
'productIdAutocompleteRender'
), 10, 1 ); // Render exact item. Must return an array (label,value)
function productIdAutocompleteSuggester($query) -> should proccess your request, and return an multi-dimension associative array with keys 'label', 'value' and if necessary 'group'
function productIdAutocompleteRender($value) -> should proccess your request (for 1 exact item from "value") and return an associative array with keys 'label','value' and if necessary 'group'
*/