File: /home/frenchy/refonte2023/wordpress/wp-content/plugins/ova-sev/inc/class-ova-ajax.php
<?php
if ( ! defined('ABSPATH') ) {
exit();
}
if ( ! class_exists( 'OVASEV_Ajax' ) ) {
class OVASEV_Ajax {
public function __construct(){
add_action( 'wp_ajax_ova_sev_pagination_ajax', array( $this, 'ova_sev_pagination_ajax' ) );
add_action( 'wp_ajax_nopriv_ova_sev_pagination_ajax', array( $this, 'ova_sev_pagination_ajax' ) );
add_action( 'wp_ajax_ova_sev_filter_ajax', array( $this, 'ova_sev_filter_ajax' ) );
add_action( 'wp_ajax_nopriv_ova_sev_filter_ajax', array( $this, 'ova_sev_filter_ajax' ) );
}
public function ova_sev_pagination_ajax() {
$args = $_POST['args'];
$offset = $_POST['offset'];
$curent_page = $_POST['page'];
$args['offset'] = intval( $offset );
$services = ova_sev_query( $args );
$total_pages = $services->max_num_pages;
$post_per_page = intval( $args['posts_per_page'] );
ob_start();
ova_get_sev_list( $services );
ova_sev_pagination_ajax($total_pages,$curent_page,$post_per_page,$args);
echo ob_get_clean();
wp_die();
}
public function ova_sev_filter_ajax(){
$form_data = $_POST['form_data'];
$cate_name = sanitize_text_field( $form_data['cate_name'] );
$cate_slug = sanitize_text_field( $form_data['cate_slug'] );
$post_per_page = intval( get_theme_mod( 'ova_sev_total_record', 9 ) );
$order_by = get_theme_mod( 'ova_sev_orderby', 'ID' );
$order = get_theme_mod( 'ova_sev_order', 'DESC' );
$args = array(
'order_by' => $order_by,
'order' => $order,
'posts_per_page' => $post_per_page,
'cate' => $cate_slug,
'cate_name' => trim( $cate_name ),
);
$services = ova_sev_query( $args );
$total_pages = $services->max_num_pages;
$curent_page = 1;
ob_start();
ova_get_sev_list( $services );
ova_sev_pagination_ajax($total_pages,$curent_page,$post_per_page,$args);
echo ob_get_clean();
wp_die();
}
}
new OVASEV_Ajax();
}