HEX
Server: Apache
System: Linux nc-ph-0707-26.instaforreviews.com 3.10.0-1160.119.1.el7.tuxcare.els13.x86_64 #1 SMP Fri Nov 22 06:29:45 UTC 2024 x86_64
User: qirgxuo4hkuv (1004)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: /home/qirgxuo4hkuv/public_html/koracheap.com/wp-content/themes/rehub-theme/jsonids/json-ids.php
<?php  
require_once(dirName(__FILE__).'/../../../../wp-load.php'); 

$search_array = array();

if ( empty( $_GET['q'] ) && !empty( $_GET['t'] ) ) {
	$taxonomies = sanitize_text_field($_GET['taxonomy']);

	if( isset( $_GET['hide_empty'] ) ){
		$hide_empty = $_GET['hide_empty'];
	}else{
		$hide_empty = 1;
	}
	
	$args = array(
		'search' => sanitize_text_field($_GET['t']),
		'hide_empty' => $hide_empty,
		'taxonomy'=> $taxonomies,
	);
	
	$terms = get_terms( $args );
	
	if ( !empty( $terms ) ) {
		foreach ( $terms as $term ) {
			$tag_id = $term->term_id;
			$tag_name = $term->name;
			$search_array[] = array( 'id' => $tag_id, 'name' => $tag_name );
		}
	}

} else {
	$post_type = sanitize_text_field($_GET['posttype']);
	$post_type = explode(',', $post_type);

    $args = array(
        's' => sanitize_text_field($_GET['q']),
        'post_type' => $post_type,
        'posts_per_page' => sanitize_text_field($_GET['postnum']),
        'post_status' => 'publish',
		'cache_results' => false,
		'no_found_rows' => true	    
    );

    $search_query = new WP_Query( $args );

    if ( !empty( $search_query->posts ) ) {
        foreach ( $search_query->posts as $post ) {
			$post_id = $post->ID;
			$post_title = $post->post_title;
			$search_array[] = array( 'id' => $post_id, 'name' => $post_title.' - ID:'.$post_id );
        }
		wp_reset_query();
    }
}

die( json_encode( $search_array ) );