. */ class All_in_One_SEO_Pack { var $version = "1.4.5.4.1"; /** 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 $ob_start_detected = false; var $title_start = -1; var $title_end = -1; /** The title before rewriting */ var $orig_title = ''; /** Temp filename for the latest version. */ var $upgrade_filename = 'temp.zip'; /** Where to extract the downloaded newest version. */ var $upgrade_folder; /** Any error in upgrading. */ var $upgrade_error; /** Which zip to download in order to upgrade .*/ var $upgrade_url = 'http://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip'; /** Filename of log file. */ var $log_file; /** Flag whether there should be logging. */ var $do_log; function All_in_One_SEO_Pack() { $this->log_file = dirname(__FILE__) . '/all_in_one_seo_pack.log'; if (get_option('aiosp_do_log')) { $this->do_log = true; } else { $this->do_log = false; } $this->upgrade_filename = dirname(__FILE__) . '/' . $this->upgrade_filename; $this->upgrade_folder = dirname(__FILE__); } function template_redirect() { global $wp_query; $post = $wp_query->get_queried_object(); if (is_feed()) { return; } if (is_single() || is_page()) { $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, 'aiosp_disable', true))); if ($aiosp_disable) { 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 get_base() { return '/'.end(explode('/', str_replace(array('\\','/all_in_one_seo_pack.php'),array('/',''),__FILE__))); } function admin_head() { $home = get_settings('siteurl'); $stylesheet = $home.'/wp-content/plugins' . $this->get_base() . '/css/all_in_one_seo_pack.css'; echo(''); } function wp_head() { if (is_feed()) { return; } global $wp_query; $post = $wp_query->get_queried_object(); $meta_string = null; if (is_single() || is_page()) { $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, 'aiosp_disable', true))); if ($aiosp_disable) { return; } } if (get_option('aiosp_rewrite_titles')) { // make the title rewrite as short as possible if (function_exists('ob_list_handlers')) { $active_handlers = ob_list_handlers(); } else { $active_handlers = array(); } 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 { $this->log("another plugin interfering?"); // if we get here there *could* be trouble with another plugin :( $this->ob_start_detected = true; foreach (ob_list_handlers() as $handler) { $this->log("detected output handler $handler"); } } } echo "\n"; if ((is_home() && !$this->is_static_posts_page() && get_option('aiosp_home_keywords')) || $this->is_static_front_page()) { $keywords = trim($this->internationalize(get_option('aiosp_home_keywords'))); } else { $keywords = $this->get_all_keywords(); } if (is_single() || is_page()) { if ($this->is_static_front_page()) { $description = trim(stripcslashes($this->internationalize(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(stripcslashes($this->internationalize(get_option('aiosp_home_description')))); } } else if (is_category()) { $description = $this->internationalize(category_description()); } if (isset($description) && (strlen($description) > $this->minimum_description_length) && !(is_home() && is_paged())) { $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); $description = str_replace('%wp_title%', $this->get_original_title(), $description); $meta_string .= sprintf("\n", $description); } if (isset ($keywords) && !empty($keywords) && !(is_home() && is_paged())) { 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 .= ''; } $page_meta = stripcslashes(get_option('aiosp_page_meta_tags')); $post_meta = stripcslashes(get_option('aiosp_post_meta_tags')); if (is_page() && isset($page_meta) && !empty($page_meta)) { if (isset($meta_string)) { $meta_string .= "\n"; } echo "\n$page_meta"; } if (is_single() && isset($post_meta) && !empty($post_meta)) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string .= "$post_meta"; } if ($meta_string != null) { echo "$meta_string\n"; } echo "\n"; } function get_post_description($post) { $description = trim(stripcslashes($this->internationalize(get_post_meta($post->ID, "description", true)))); if (!$description) { $description = $this->trim_excerpt_without_filters_full_length($this->internationalize($post->post_excerpt)); if (!$description && get_option("aiosp_generate_descriptions")) { $description = $this->trim_excerpt_without_filters($this->internationalize($post->post_content)); } } // "internal whitespace trim" $description = preg_replace("/\s+/", " ", $description); return $description; } function replace_title($content, $title) { $title = trim(strip_tags($title)); $title_tag_start = "