Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alamgircsebd/5efc2dadaed4e3134bcf1785488899d9 to your computer and use it in GitHub Desktop.
Save alamgircsebd/5efc2dadaed4e3134bcf1785488899d9 to your computer and use it in GitHub Desktop.
Vendor category box hide by click out of box on dokan store listing page
/**
* Vendor category box hide by click outofbox on dokan store listing page
*
* Use this code on main/child theme functions.php file
* or use custom plugin for add scripts on footer area
*/
function add_custom_scripts_for_store_listing_dokan_category_on_footer() {
if ( function_exists( 'dokan_is_store_listing' ) && dokan_is_store_listing() ) {
?>
<script>
(function($) {
var Dokan_Vendor_Category_Customized = {
init: function() {
$( 'body' ).on( 'click', this.hideCategory );
},
/**
* Hide category
*
* @return void
*/
hideCategory: function(event) {
const item = $( event.target );
if( ! item.is('div.store_category') && ! item.is('span.dokan-icon') && ! item.is('div.store-lists-category') && ! item.is('li.dokan-btn-theme') && ! item.is('div.category-input') && ! item.is('span.category-label') && ! item.is('span.category-items') ){
$( '.store-lists-category .category-box' ).hide();
$( '.store-lists-category .category-input .dokan-icon' ).addClass( 'dashicons-arrow-down-alt2' );
}
}
};
$(function() {
Dokan_Vendor_Category_Customized.init();
});
})(jQuery);
</script>
<?php
}
}
add_action( 'wp_footer', 'add_custom_scripts_for_store_listing_dokan_category_on_footer' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment