If you want to use any functionality or shortcode in map template or tooltip you can use Additional tags
This method allows you to define new custom tags.
1 |
Locate_And_Filter_Addon_Helper ::define_custom_tags($arr_tags,$scope,$getDataCallbackFn,$addon_name) |
Description : LocateAndFilter tags are pseudo-shortcodes of the form : |nameOfTag|
, ex : |place_tags|
They are used in the navlist and tooltip template editors. They symbolize a piece of data and will be substituted by their value at runtime.
Args :
[array] $arr_tags : array of tags. Form expected: $arr_tags = array(field name => Tagname);
[string] $scope : The scope of the filters : a post type, “user” or “all” [string] $getDataCallbackFn : callback function name, gets the datas for passed field and marker ID [string] $addon_name : Addon name, no space or special char
Example : This will create a tag |place_tags|. The new tag appears in the backoffice, in the “Tooltips & Navlist” tab. You can now, if you want to, define a filter on that tag using Locate_And_Filter_Addon_Helper :: define_filters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Locate_And_Filter_Addon_Helper::define_custom_tags( array( 'place_tags' =>'place_tags'), 'all', getDataCallbackFn_place_tags, 'place_tags' ); function getDataCallbackFn_place_tags( $field, $id){ $html = ''; ob_start(); ?> <div class="tags_wrap tooltip_tags"> <div class="cat_services tags_list"> <?php $cat_services = get_the_terms( $id, 'cat_services' ); foreach ($cat_services as $key => $cat_service) { echo '<span class="tags_element '.$cat_service->slug.'" title="'.$cat_service->name.'"></span>'; } ?> </div> </div> <?php $html .= ob_get_contents(); ob_end_clean(); return strval($html); } |
Example : This will create a tag for shortcode |custom_shortcode_filed|.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Locate_And_Filter_Addon_Helper::define_custom_tags( array( 'custom_shortcode_filed' =>'custom_shortcode_filed'), 'all', getDataCallbackFn_custom_shortcode_filed, 'custom_shortcode_filed' ); function getDataCallbackFn_custom_shortcode_filed( $field, $id){ $html = ''; ob_start(); $num = get_post_meta( $id, 'usr', true ); echo do_shortcode( "[usr ".$num ."]" ); $html .= ob_get_contents(); ob_end_clean(); return $html; } |
Example : This will create a tag for ACF |advanced_custom_field|.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Locate_And_Filter_Addon_Helper::define_custom_tags( array( 'advanced_custom_field' =>'advanced_custom_field'), 'all', getDataCallbackFn_acf_tags, 'advanced_custom_field' ); function getDataCallbackFn_acf_tags( $field, $id){ $html = ''; ob_start(); $advanced_custom_field = get_field('advanced_custom_field', $id); echo $advanced_custom_field; $html .= ob_get_contents(); ob_end_clean(); return $html; } |
Example :you can add Custom tag via plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
add_action('plugins_loaded', 'init_tags_for_locate_and_filter_plugin'); function init_tags_for_locate_and_filter_plugin() { if ( class_exists('Locate_And_Filter_Addon_Helper') ) { //new Locate_And_Filter_Addon_Helper; Locate_And_Filter_Addon_Helper::define_custom_tags( array( 'project_image' =>'project_image'), 'all', getDataCallbackFn_place_tags, 'project_image' ); function getDataCallbackFn_place_tags( $field, $id){ $html = ''; ob_start(); $project_image = get_field('project_image', $id); echo '<a href="'.$project_image.'"><img src="'.$project_image.'" style="width:300px;">'; $html .= ob_get_contents(); ob_end_clean(); return $html; } } else { add_action('admin_notices', 'wc_not_loaded'); } } function wc_not_loaded() { printf( '<div class="error"><p>%s</p></div>', __('Sorry cannot create tag because Locate_And_Filter is not loaded') ); } |