. */ class All_in_One_SEO_Pack { var $version = "1.3.5.7"; /** * Max numbers of chars in auto-generated description. */ var $maximum_description_length = 160; /** * Minimum number of chars an excerpt should be so that it can be used * as description. Touch only if you know what you're doing. */ var $minimum_description_length = 1; var $table_prefix = "aiosp_"; var $table_categries; var $db_version = '0.1'; var $ob_start_detected = false; var $title_start = -1; var $title_end = -1; var $orig_title = ''; function template_redirect() { if (is_feed()) { return; } if (get_option('aiosp_rewrite_titles')) { ob_start(array($this, 'output_callback_for_title')); } } function output_callback_for_title($content) { return $this->rewrite_title($content); } function init() { if(function_exists('load_plugin_textdomain')) { load_plugin_textdomain('all_in_one_seo_pack', 'wp-content/plugins/all-in-one-seo-pack'); } } function is_static_front_page() { global $wp_query; $post = $wp_query->get_queried_object(); return get_option('show_on_front') == 'page' && is_page() && $post->ID == get_option('page_on_front'); } function is_static_posts_page() { global $wp_query; $post = $wp_query->get_queried_object(); return get_option('show_on_front') == 'page' && is_home() && $post->ID == get_option('page_for_posts'); } function wp_head() { if (is_feed()) { return; } if (get_option('aiosp_rewrite_titles')) { // make the title rewrite as short as possible $active_handlers = ob_list_handlers(); if (sizeof($active_handlers) > 0 && strtolower($active_handlers[sizeof($active_handlers) - 1]) == strtolower('All_in_One_SEO_Pack::output_callback_for_title')) { ob_end_flush(); } else { // if we get here there *could* be trouble with another plugin :( $this->ob_start_detected = true; echo "\n"; foreach (ob_list_handlers() as $handler) { echo "\n"; } } } global $wp_query; $post = $wp_query->get_queried_object(); $meta_string = null; echo "\n"; if ((is_home() && !$this->is_static_posts_page() && get_option('aiosp_home_keywords')) || $this->is_static_front_page()) { $keywords = trim(get_option('aiosp_home_keywords')); } else { $keywords = $this->get_all_keywords(); } if (is_single() || is_page()) { if ($this->is_static_front_page()) { $description = trim(stripslashes(get_option('aiosp_home_description'))); } else { $description = $this->get_post_description($post); } } else if (is_home()) { if ($this->is_static_posts_page()) { $description = $this->get_post_description(get_post(get_option('page_for_posts'))); } else { $description = trim(stripslashes(get_option('aiosp_home_description'))); } } else if (is_category()) { $description = category_description(); } if (isset($description) && strlen($description) > $this->minimum_description_length) { $description = trim(strip_tags($description)); $description = str_replace('"', '', $description); // replace newlines on mac / windows? $description = str_replace("\r\n", ' ', $description); // maybe linux uses this alone $description = str_replace("\n", ' ', $description); if (isset($meta_string)) { $meta_string .= "\n"; } else { $meta_string = ''; } // description format $description_format = get_option('aiosp_description_format'); if (!isset($description_format) || empty($description_format)) { $description_format = "%description%"; } $description = str_replace('%description%', $description, $description_format); $description = str_replace('%blog_title%', get_bloginfo('name'), $description); $description = str_replace('%blog_description%', get_bloginfo('description'), $description); $meta_string .= sprintf("", $description); } if (isset ($keywords) && !empty($keywords)) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string .= sprintf("", $keywords); } if (function_exists('is_tag')) { $is_tag = is_tag(); } if ((is_category() && get_option('aiosp_category_noindex')) || (!is_category() && is_archive() &&!$is_tag && get_option('aiosp_archive_noindex')) || (get_option('aiosp_tags_noindex') && $is_tag)) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string = ''; } if ($meta_string != null) { echo "$meta_string\n"; } } function get_post_description($post) { $description = trim(stripslashes(get_post_meta($post->ID, "description", true))); if (!$description) { $description = $this->trim_excerpt_without_filters_full_length($post->post_excerpt); if (!$description && get_option("aiosp_generate_descriptions")) { $description = $this->trim_excerpt_without_filters($post->post_content); } } return $description; } function replace_title($content, $title) { $title = trim(strip_tags($title)); $title = apply_filters('the_title', $title); $title_tag_start = "