'product_cat', 'hide_empty' => false, ) ); $cats_array = []; foreach( $categories_list as $cat ) : $cats_array[] = array( 'value' => esc_html( $cat->slug ), 'label' => esc_html(str_replace(array('\'', '"'), '', $cat->name)) . ' (' .absint( $cat->count ). ')' ); endforeach; return $cats_array; } endif; if( ! function_exists( 'becommerce_store_get_categories_array' ) ) : /** * Return array of categories prepended with "*" key. * */ function becommerce_store_get_categories_array() { $categories_list = get_categories( ); $cats_array = []; foreach( $categories_list as $cat ) : $cats_array[] = array( 'value' => esc_html( $cat->slug ), 'label' => esc_html(str_replace(array('\'', '"'), '', $cat->name)) . ' (' .absint( $cat->count ). ')' ); endforeach; return $cats_array; } endif; if( ! function_exists( 'becommerce_store_get_posts_array' ) ) : /** * Return array of posts prepended with "*" key. * */ function becommerce_store_get_posts_array() { $posts_list = get_posts(array('numberposts'=>7)); $posts_array = []; foreach( $posts_list as $postItem ) : $posts_array[] = array( 'value' => esc_html( $postItem->post_name ), 'label' => esc_html(str_replace(array('\'', '"'), '', $postItem->post_title)) ); endforeach; return $posts_array; } endif; function becommerce_store_sanitize_checkbox( $checked ){ //returns true if checkbox is checked return ( ( isset( $checked ) && true == $checked ) ? true : false ); }