$insta_data['image_num'] ) {
break;
}
$i++;
if ( $insta_data['resolution'] == 'low_resolution' || $insta_data['resolution'] == 'low_resolution_crop' || $insta_data['resolution'] == 'standard_resolution' || $insta_data['image_resolution'] == 'standard_resolution_crop' ) {
$image = $item['large'];
} else {
$image = $item[ $insta_data['resolution'] ];
}
$media_tag = "
";
$content = '
';
if ( $search_post_type == 'product' ) {
foreach ( $all_search_results as $post ) :
setup_postdata( $post );
$product = wc_get_product( get_the_ID() );
$main_cat = kite_get_post_primary_category( get_the_ID(), 'product_cat' )['primary_category'];
$results[] = sprintf( '
', get_permalink(), ( ( has_post_thumbnail() ) ? woocommerce_get_product_thumbnail( 'shop_thumbnail' ) : '' ), $product->get_title(), $main_cat->name, $product->get_price_html() );
endforeach;
} else {
foreach ( $all_search_results as $post ) :
setup_postdata( $post );
$main_cat = kite_get_post_primary_category( get_the_ID(), 'category' )['primary_category'];
$results[] = sprintf( '
', get_permalink(), ( ( '' == $featured_image = get_the_post_thumbnail() ) ? '' : '
' . $featured_image . '
' ), get_the_title() );
endforeach;
}
$results[] = '
';
}
/**
* Search results filter
*
* @hooked - kite_append_dokan_vendors_list_to_ajax_search - 1
*/
$results = apply_filters( 'kite_ajax_search_results', $results, $all_search_results );
/**
* Kite after search items loop
*
* @hooked - kite_revert_back_price_style_after_ajax_search
*/
do_action( 'kite_after_ajax_search_items_loop', $search_post_type );
$result = implode( $results );
echo wp_kses( $result, kite_allowed_html() );
} else {
if ( ! empty( $results ) ) {
$result = implode( $results );
echo wp_kses( $result, kite_allowed_html() );
} else {
echo "" . esc_html__( 'Nothing Found For : ', 'teta-lite' ) . '
';
}
}
wp_reset_postdata();
die();
}
}
add_action( 'wp_ajax_kite_ajax_search_action', 'kite_ajax_search' );
add_action( 'wp_ajax_nopriv_kite_ajax_search_action', 'kite_ajax_search' );
function kite_format_price_range( $price, $from, $to ) {
$price = sprintf( _x( '%1$s %2$s', 'Price range: from-to', 'teta-lite' ), is_numeric( $from ) ? wc_price( $from ) : $from, is_numeric( $to ) ? wc_price( $to ) : $to );
return $price;
}
//
// ─── DISCONNECT INSTAGRAM ACCOUNT ───────────────────────────────────────────────
//
function kite_instagram_api_disconnect() {
if ( class_exists('Kite_Instagram_Api') && wp_verify_nonce( $_POST['nonce'], 'kite-disconnect-instagram' ) ) {
Kite_Instagram_Api::disconnect();
wp_send_json_success( [ 'message' => 'disconnected successfully'] );
}
}
add_action( 'wp_ajax_kite_instagram_api_disconnect', 'kite_instagram_api_disconnect');
if ( ! function_exists( 'kite_get_wishlist_quantity' ) ) {
function kite_get_wishlist_quantity() {
global $yith_wcwl;
// check to see if the submitted nonce matches with the generated nonce we created earlier
check_ajax_referer( 'ajax-nonce', 'security' );
$data = array(
'wishlist_count_products' => yith_wcwl_count_products(),
);
wp_send_json( $data );
}
}
// Update wishlist widget
add_action( 'wp_ajax_get_wishlist_quantity', 'kite_get_wishlist_quantity' );
add_action( 'wp_ajax_nopriv_get_wishlist_quantity', 'kite_get_wishlist_quantity' );
if ( ! function_exists( 'kite_remove_item' ) ) {
function kite_remove_item() {
$item_key = sanitize_text_field( $_POST['item_key'] );
$removed = WC()->cart->remove_cart_item( $item_key ); // Note: WP 2.3 >
if ( $removed ) {
$data['status'] = '1';
$data['cart_count'] = WC()->cart->get_cart_contents_count();
$data['cart_subtotal'] = WC()->cart->get_cart_subtotal();
} else {
$data['status'] = '0';
}
echo json_encode( $data );
exit;
}
}
// Remove item from card
add_action( 'wp_ajax_cart_remove_item', 'kite_remove_item' );
add_action( 'wp_ajax_nopriv_cart_remove_item', 'kite_remove_item' );
if ( ! function_exists( 'kite_undo_removed_item' ) ) {
function kite_undo_removed_item() {
$item_key = sanitize_text_field( $_POST['item_key'] );
$cart = WC()->instance()->cart;
$undo_item = $cart->restore_cart_item( $item_key );
if ( $undo_item ) {
$data['status'] = '1';
$data['cart_count'] = $cart->get_cart_contents_count();
$data['cart_subtotal'] = $cart->get_cart_subtotal();
} else {
$data['status'] = '0';
}
echo json_encode( $data );
exit;
}
}
// Get back removed item to cart
add_action( 'wp_ajax_undo_removed_item', 'kite_undo_removed_item' );
add_action( 'wp_ajax_nopriv_undo_removed_item', 'kite_undo_removed_item' );
if ( ! function_exists( 'kite_update_mini_cart_item_quantity' ) ) {
function kite_update_mini_cart_item_quantity() {
$item_key = sanitize_text_field( $_POST['item_key'] );
$quantity = (int) sanitize_text_field( $_POST['quantity'] );
$data['status'] = '0';
if ( WC()->cart->set_quantity( $item_key, $quantity) ) {
$data['status'] = '1';
$data['cart_count'] = WC()->cart->get_cart_contents_count();
$data['cart_subtotal'] = WC()->cart->get_cart_subtotal();
}
echo json_encode( $data );
exit;
}
}
add_action( 'wp_ajax_update_mini_cart_item', 'kite_update_mini_cart_item_quantity' );
add_action( 'wp_ajax_nopriv_update_mini_cart_item', 'kite_update_mini_cart_item_quantity' );
//
// ─── DISSMISS NOTICES ───────────────────────────────────────────────────────────
//
if ( !function_exists('kite_dismiss_plugins_install_notices') ) {
function kite_dismiss_plugins_install_notices() {
$days = absint( $_GET['dismiss_time'] );
set_transient( 'kite-install-plugins-dismiss', true, $days * DAY_IN_SECONDS );
}
}
add_action( 'wp_ajax_dismiss_plugins_install_notices', 'kite_dismiss_plugins_install_notices' );