OwlCyberSecurity - MANAGER
Edit File: class-ajax.php
<?php if ( !defined( 'ABSPATH' ) ) exit(); if ( ! class_exists( 'Chursy_Ajax' ) ) { class Chursy_Ajax{ public function __construct(){ add_action( 'wp_ajax_load_blog_post', array( $this, 'load_blog_post') ); add_action( 'wp_ajax_nopriv_load_blog_post', array( $this, 'load_blog_post') ); } public function load_blog_post() { check_ajax_referer( apply_filters( 'chursy_ajax_security', 'ajax_theme' ), 'security' ); $posts_per_page = isset( $_POST['posts_per_page'] ) ? sanitize_text_field( $_POST['posts_per_page'] ) : 3; $orderby = isset( $_POST['orderby'] ) ? sanitize_text_field( $_POST['orderby'] ) : 'date'; $order = isset( $_POST['order'] ) ? sanitize_text_field( $_POST['order'] ) : ''; $category = isset( $_POST['category'] ) ? sanitize_text_field( $_POST['category'] ) : ''; $paged = isset( $_POST['paged'] ) ? sanitize_text_field( $_POST['paged'] ) : 1; $number_column = isset( $_POST['number_column'] ) ? sanitize_text_field( $_POST['number_column'] ) : 'number_column'; $show_pagination = isset( $_POST['show_pagination'] ) ? sanitize_text_field( $_POST['show_pagination'] ) : 'no'; $args_ajax = []; if ( $category == 'all' ) { $args_ajax = [ 'post_type' => 'post', 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'order' => $order, 'orderby' => $orderby, ]; } else { $args_ajax = [ 'post_type' => 'post', 'category_name' => $category, 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'order' => $order, 'orderby' => $orderby, 'fields' => 'ids' ]; } $blog = new WP_Query( $args_ajax ); ?> <div class="ova-blog <?php echo esc_attr($number_column); ?>"> <?php if( $blog->have_posts() ) : while( $blog->have_posts() ) : $blog->the_post(); $categories = get_the_category(); $thumbnail = wp_get_attachment_image_url(get_post_thumbnail_id() , 'chursy_thumbnail' ); ?> <div class="item"> <?php if( has_post_thumbnail() ) { ?> <div class="media"> <img src="<?php echo esc_url( $thumbnail ); ?>" alt="<?php the_title(); ?>"> </div> <?php } ?> <div class="info"> <?php if ( get_the_title() ) { ?> <h2 class="post-title"> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"> <?php echo get_the_title(); ?> </a> </h2> <?php } ?> <?php if ( get_the_excerpt() ) { ?> <div class="short_desc"> <?php echo chursy_custom_text( get_the_excerpt(), 15 ); ?> </div> <?php } ?> <div class="post-bottom"> <ul class="post-meta"> <li class="item-meta post-date"> <span class="right date"> <?php the_time( get_option( 'date_format' ) ); ?> </span> </li> </ul> <?php if( has_category() && is_array($categories) ) { ?> <span class="category"> <?php echo esc_html( $categories[0]->name ); ?> </span> <?php } ?> </div> </div> </div> <?php endwhile; endif; wp_reset_postdata(); ?> </div> <?php $total = $blog->max_num_pages; if ( $total > 1 && $show_pagination == 'yes' ): ?> <div class="ova_pagination_ajax"> <?php echo ova_pagination_ajax( $blog->found_posts, $blog->query_vars['posts_per_page'], $paged ); ?> </div> <?php endif; ?> <?php wp_die(); } } new Chursy_Ajax(); }