HEX
Server: LiteSpeed
System: Linux standart103.isimtescil.net 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: byildiz (11197)
PHP: 8.2.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/byildiz.com.tr/httpdocs/wp-content/themes/lumex/inc/infinite-scroll.php
<?php
/**
 * Functions for implement Ajax Infinite Scroll for Portfolio & Posts for this theme
 *
 * @package lumex
 */

function lumex_ajax_infinite_scroll_el() {
	check_ajax_referer( 'lumex_ajax', 'ajax_nonce' );

	$post_type = sanitize_text_field( $_POST['post_type'] );

	if ( $post_type == 'portfolio' ) {
		$page_id = absint( $_POST['page_id'] );
		$paged = absint( $_POST['page_no'] );
		$per_page = absint( $_POST['per_page'] );

		$orderby = sanitize_text_field( $_POST['order_by'] );
		$order = sanitize_text_field( $_POST['order'] );
		$source = sanitize_text_field( $_POST['source'] );
		$cat_ids = sanitize_text_field( $_POST['cat_ids'] );
		$columns = sanitize_text_field( $_POST['columns'] );

		$temp = sanitize_key( $_POST['temp'] );

		$allowed = array( 'portfolio' );
		if ( ! in_array( $temp, $allowed ) ) {
			$temp = 'portfolio';
		}

		$args = array(
			'post_type'		 => 'portfolio',
			'post_status'	   => 'publish',
			'orderby'			=> $orderby,
			'order'				=> $order,
			'posts_per_page'	=> $per_page,
			'paged' 			=> $paged
		);

		if( $source == 'categories' ) {
			$tax_array = array(
				array(
					'taxonomy' => 'portfolio_categories',
					'field'    => 'id',
					'terms'    => $cat_ids
				)
			);

			$args += array('tax_query' => $tax_array);
		}
		if ( $source == 'tags' ) {
			$tax_array = array(
				array(
					'taxonomy' => 'post_tag',
					'field'    => 'id',
					'terms'    => $cat_ids
				)
			);

			$args += array('tax_query' => $tax_array);
		}
		if ( $source == 'custom' ) {
			$args += array( 'post__in' => $cat_ids );
		}

		$q = new WP_Query($args);

		if ( $q->have_posts() ) : ?>
			<?php $index = 0; while ( $q->have_posts() ) : $q->the_post(); $index++; ?>
			<?php 
				set_query_var( 'index', ($per_page*($paged-1))+$index );
				set_query_var( 'grid', true );
				set_query_var( 'columns', $columns );

				get_template_part( 'template-parts/content', $temp );
			?>
			<?php endwhile; ?>

			<?php wp_reset_postdata();
		endif;

		exit;

	} else {
		//load blog posts

		$page_id = absint( $_POST['page_id'] );
		$paged = absint( $_POST['page_no'] );
		$per_page = absint( $_POST['per_page'] );

		$orderby = sanitize_text_field( $_POST['order_by'] );
		$order = sanitize_text_field( $_POST['order'] );
		$source = sanitize_text_field( $_POST['source'] );
		$cat_ids = sanitize_text_field( $_POST['cat_ids'] );
		$items_per_row = sanitize_text_field( $_POST['items_per_row'] );
		$row_layout = sanitize_text_field( $_POST['row_layout'] );

		$args = array(
			'post_type'		 => 'post',
			'post_status'	   => 'publish',
			'orderby'			=> $orderby,
			'order'				=> $order,
			'posts_per_page'	=> $per_page,
			'paged' 			=> $paged
		);

		if( $source == 'categories' ) {
			$tax_array = array(
				array(
					'taxonomy' => 'category',
					'field'    => 'id',
					'terms'    => $cat_ids
				)
			);

			$args += array('tax_query' => $tax_array);
		}
		if ( $source == 'tags' ) {
			$tax_array = array(
				array(
					'taxonomy' => 'post_tag',
					'field'    => 'id',
					'terms'    => $cat_ids
				)
			);

			$args += array('tax_query' => $tax_array);
		}
		if ( $source == 'custom' ) {
			$args += array( 'post__in' => $cat_ids );
		}

		$q = new WP_Query($args);

		if( $q->have_posts() ) :
			while( $q->have_posts() ) : $q->the_post();
				set_query_var( 'row_layout', $row_layout );
				set_query_var( 'items_per_row', $items_per_row );

				get_template_part( 'template-parts/content' );
			endwhile;

			wp_reset_postdata();
		endif;

		exit;

	}
}
add_action( 'wp_ajax_infinite_scroll_el', 'lumex_ajax_infinite_scroll_el' );
add_action( 'wp_ajax_nopriv_infinite_scroll_el', 'lumex_ajax_infinite_scroll_el' );