false, 'post_value' => $_all_post_vals, ); // Verify the nonce before proceeding. $megamenu_nonce_value = isset( $_all_post_vals['megamenu_nonce_value'] ) ? esc_html($_all_post_vals['megamenu_nonce_value']) : ''; $dglib_nonce_megamenu_action = 'dglib_megamenu_posts_nonce'; // Check if nonce is set... if ( ! isset( $megamenu_nonce_value ) ) { $response['message'] = esc_html__( 'Nonce doesnot exist.', 'blogmagazine' ); wp_send_json($response); } // Check if nonce is valid... if ( ! wp_verify_nonce( $megamenu_nonce_value, $dglib_nonce_megamenu_action ) ) { $response['message'] = esc_html__( 'Nonce doesnot match.', 'blogmagazine' ); wp_send_json($response); } $paged = (isset($_all_post_vals['paged']) ) ? absint($_all_post_vals['paged']) : 1; $terms = (is_array($_all_post_vals['term_ids'])) ? array_map( 'absint', wp_unslash( $_all_post_vals['term_ids'] ) ) : absint($_all_post_vals['term_ids']); $args = array( 'paged' => $paged, 'post_type' => 'post', 'posts_per_page' => (isset($_all_post_vals['posts_per_page'])) ? absint($_all_post_vals['posts_per_page']) : 4, 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $terms, 'operator' => 'IN', ) ), ); $query = new WP_Query($args); $megamenu_html = ''; if($query->have_posts()): while($query->have_posts()): $query->the_post(); $featured_image_class = (has_post_thumbnail()) ? 'has-image' : 'no-image'; $megamenu_html .= '