'Please Select Category' ) );
}
$terms = stm_get_category_by_slug( $_POST['selected_taxonomy'] );
if ( ! empty( $terms ) ) {
$terms_array = array();
foreach ( $terms as $term ) {
if ( is_object( $term ) && ! empty( $term->slug ) ) {
$terms_array[ $term->slug ] = $term->slug;
}
}
wp_send_json( $terms_array );
}
wp_send_json( array( 'message' => 'Terms not exist' ) );
}
add_action( 'wp_ajax_stm_mm_get_terms_by_taxonomy', 'stm_mm_get_terms_by_taxonomy' );
add_action( 'wp_ajax_nopriv_stm_mm_get_terms_by_taxonomy', 'stm_mm_get_terms_by_taxonomy' );
function stm_mm_categories_for_select() {
$categories = get_categories(
array(
'child_of' => 0,
'current_category' => 0,
'depth' => 0,
'echo' => 1,
'exclude' => '',
'exclude_tree' => '',
'feed' => '',
'feed_image' => '',
'feed_type' => '',
'hide_empty' => 0,
'hide_title_if_empty' => false,
'hierarchical' => true,
'order' => 'ASC',
'orderby' => 'name',
'separator' => '
',
'show_count' => 0,
'show_option_all' => '',
'show_option_none' => __( 'No categories' ),
'style' => 'list',
'taxonomy' => 'category',
'title_li' => __( 'Categories' ),
'use_desc_for_title' => 1,
)
);
$cat_array_walker = new Stm_MM_Array_Walker();
$cat_array_walker->walk( $categories, 4 );
$catOpt = $cat_array_walker->optList;
return( $catOpt );
}
class Stm_MM_Array_Walker extends Walker {
public $tree_type = 'category';
public $db_fields = array(
'parent' => 'parent',
'id' => 'term_id',
);
public $optList = array( 0 => 'Default' );
public function start_lvl( &$output, $depth = 0, $args = array() ) {}
public function end_lvl( &$output, $depth = 0, $args = array() ) {}
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
$sep = '';
for ( $q = 0;$q < $depth;$q++ ) {
$sep .= ' - ';
}
$this->optList[ $category->term_id ] = $sep . $category->name . '[id:' . $category->term_id . ']';
}
public function end_el( &$output, $page, $depth = 0, $args = array() ) {}
}
if ( function_exists( 'vc_add_shortcode_param' ) ) {
function stm_mm_top_categories_vc( $settings, $value ) {
//phpcs:disable
return '