if (is_array($rh_page_uris)) { foreach ($rh_page_uris as $uri) { if (strstr($_SERVER['REQUEST_URI'], $uri)) { self::nocache(); break; } } } } /** * Set nocache constants and headers. * * @access private * @return void */ private static function nocache() { if (!defined('DONOTCACHEPAGE')) { define("DONOTCACHEPAGE", "true"); } if (!defined('DONOTCACHEOBJECT')) { define("DONOTCACHEOBJECT", "true"); } if (!defined('DONOTCACHEDB')) { define("DONOTCACHEDB", "true"); } nocache_headers(); } } RH_Cache_Helper::init();
/** * Get an unpaginated list all recipe ID's (both filtered and unfiltered). Makes use of transients. * * @access public * @return void */ public function get_recipes_in_view() { global $wp_the_query; $unfiltered_recipe_ids = array(); // Get main query $current_wp_query = $wp_the_query->query; // Get WP Query for current page (without 'paged') unset($current_wp_query['paged']); // Generate a transient name based on current query $transient_name = 'rh_uf_pid_' . md5(http_build_query($current_wp_query) . RH_Cache_Helper::get_transient_version('recipe_query')); $transient_name = is_search() ? $transient_name . '_s' : $transient_name; if (false === ($unfiltered_recipe_ids = get_transient($transient_name))) { // Get all visible posts, regardless of filters $unfiltered_recipe_ids = get_posts(array_merge($current_wp_query, array('post_type' => 'recipe', 'numberposts' => -1, 'post_status' => 'publish', 'meta_query' => $this->meta_query, 'fields' => 'ids', 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'pagename' => ''))); set_transient($transient_name, $unfiltered_recipe_ids, YEAR_IN_SECONDS); } // Store the variable $this->unfiltered_recipe_ids = $unfiltered_recipe_ids; // Also store filtered posts ids... if (sizeof($this->post__in) > 0) { $this->filtered_recipe_ids = array_intersect($this->unfiltered_recipe_ids, $this->post__in); } else { $this->filtered_recipe_ids = $this->unfiltered_recipe_ids; } }