.
*/
class All_in_One_SEO_Pack {
var $version = "1.2.5";
/**
* Number of words to be used (max) for generating an excerpt.
*/
var $maximum_excerpt_length = 25;
/**
* 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_excerpt_length = 1;
function template_redirect() {
if (get_option('aiosp_max_words_excerpt') && is_numeric(get_option('aiosp_max_words_excerpt'))) {
$this->maximum_excerpt_length = get_option('aiosp_max_words_excerpt');
}
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_textdomain() {
if(function_exists('load_plugin_textdomain')) {
load_plugin_textdomain('all_in_one_seo_pack', 'wp-content/plugins/all-in-one-seo-pack');
}
}
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 && $active_handlers[sizeof($active_handlers) - 1] == 'All_in_One_SEO_Pack::output_callback_for_title') {
// if we don't land here there *could* be trouble with another plugin :(
ob_end_flush();
}
}
global $wp_query;
$post = $wp_query->get_queried_object();
$meta_string = null;
echo "\n";
if (is_home() && get_option('aiosp_home_keywords')) {
$keywords = trim(get_option('aiosp_home_keywords'));
} else {
$keywords = $this->get_all_keywords();
}
if (is_single() || is_page()) {
$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);
}
}
} else if (is_home()) {
$description = trim(stripslashes(get_option('aiosp_home_description')));
}
if (isset($description) && strlen($description) > $this->minimum_excerpt_length) {
$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";
}
$meta_string .= sprintf("", $description);
}
if (isset ($keywords) && !empty($keywords)) {
if (isset($meta_string)) {
$meta_string .= "\n";
}
$meta_string .= sprintf("", $keywords);
}
if((is_category() && get_option('aiosp_category_noindex')) ||
(!is_category() && is_archive() && get_option('aiosp_archive_noindex')) ||
(get_option('aiosp_tags_noindex') && function_exists('is_tag') && is_tag())) {
if (isset($meta_string)) {
$meta_string .= "\n";
}
$meta_string = '';
}
if ($meta_string != null) {
echo "$meta_string\n";
}
}
function replace_title($content, $title) {
$title = trim(addslashes(stripslashes($title)));
$header = preg_replace_callback("/