File: /home/aprilnet/public_html/sciohost.org/wp-content/themes/doris/library/ajax/ajax-megamenu.php
<?php
if (!class_exists('doris_ajax_megamenu')) {
class doris_ajax_megamenu {
//Search Query
static function doris_query($CatID) {
$args = array(
'cat' => $CatID,
'post_type' => 'post',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => 4
);
$the_query = new WP_Query($args);
return $the_query;
}
static function doris_ajax_content( $the_query, $hasBigPost ) {
$contentReturn = '';
if($hasBigPost == 1) {
$contentReturn .= doris_header::bk_get_megamenu_1stlarge_posts($the_query);
}else {
$contentReturn .= doris_header::bk_get_megamenu_posts($the_query);
}
return $contentReturn;
}
}
}
add_action('wp_ajax_nopriv_doris_ajax_megamenu', 'doris_ajax_megamenu');
add_action('wp_ajax_doris_ajax_megamenu', 'doris_ajax_megamenu');
if (!function_exists('doris_ajax_megamenu')) {
function doris_ajax_megamenu()
{
check_ajax_referer( 'doris_ajax_security', 'securityCheck' );
$CatID = isset( $_POST['thisCatID'] ) ? $_POST['thisCatID'] : null;
$hasBigPost = isset( $_POST['hasBigPost'] ) ? $_POST['hasBigPost'] : null;
$dataReturn = 'no-result';
$the_query = doris_ajax_megamenu::doris_query($CatID);
if ( $the_query->have_posts() ) {
$dataReturn = doris_ajax_megamenu::doris_ajax_content($the_query, intval($hasBigPost));
}else {
$dataReturn = 'no-result';
}
die(json_encode($dataReturn));
}
}