function get_current_settings($override = '') { global $post; if ($this->disabled == true) { return array(); } // This is useful for when we call a filter to prevent infinite loops $meta = array(); if ($override) { $meta[] = $override; } else { if (is_admin()) { $meta[] = $this->get_post_settings(isset($_GET['post']) ? intval($_GET['post']) : 0); } else { if (!is_admin()) { $meta[] = get_option('headspace_global'); } // We don't get this in admin mode as it will affect our settings // Decide what kind of page we're on // Note that on the home page we want headspace_home settings when outside the loop, but post settings inside if (is_single() || is_page() || (is_front_page() || is_home() || is_archive() || is_search()) && in_the_loop()) { if (is_attachment()) { $meta[] = get_option('headspace_attachment'); } if (is_page()) { $meta[] = get_option('headspace_page'); } else { $meta[] = get_option('headspace_post'); } if (!empty($post->ID)) { $meta[] = $this->get_post_settings($post->ID); } } else { if (is_404()) { $meta[] = get_option('headspace_404'); } else { if (is_category()) { $meta[] = get_option('headspace_category'); $meta[] = get_option('headspace_cat_' . intval(get_query_var('cat'))); } else { if (is_author()) { $meta[] = get_option('headspace_author'); } else { if (is_home()) { $meta[] = get_option('headspace_home'); } else { if (is_front_page()) { $meta[] = get_option('headspace_front'); } else { if (is_search()) { $meta[] = get_option('headspace_search'); } else { if (is_tag()) { $meta[] = get_option('headspace_tags'); } else { if (is_archive()) { if (is_tax()) { $taxonomy = get_query_var('taxonomy'); $specific_taxonomy_settings = get_option('headspace_taxonomy_' . $taxonomy); $generic_taxonomy_settings = get_option('headspace_taxonomy'); // Settings for a specific taxonomy override general ones foreach ((array) $specific_taxonomy_settings as $key => $value) { if (!empty($value)) { $generic_taxonomy_settings[$key] = $value; } } $meta[] = $generic_taxonomy_settings; } else { $meta[] = get_option('headspace_archive'); } } else { if (strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false) { $meta[] = get_option('headspace_login'); } else { if (is_feed()) { // Remove title from RSS if (is_array($meta) && isset($meta[0]) && isset($meta[0]['page_title'])) { unset($meta[0]['page_title']); } } } } } } } } } } } } } } $meta = array_filter($meta); // Do we merge the settings? $options = $this->get_options(); if ($options['inherit'] !== true && count($meta) > 1) { $meta = array($meta[count($meta) - 1]); } // Merge the settings together $merged = array(); foreach ($meta as $item) { if (!empty($item) && is_array($item)) { foreach ($item as $key => $value) { if (!empty($value)) { $merged[$key] = $value; } } } } $meta = $merged; if (!$override && !is_admin()) { // Replace any inline tags if (count($meta) > 0) { foreach ($meta as $key => $value) { $meta[$key] = HS_InlineTags::replace($value, $post); } } $meta = array_filter($meta); } $this->meta = $meta; return $this->meta; }