. */ class All_in_One_SEO_Pack { var $version = "1.2.6.1"; /** * 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; var $table_prefix = "aiosp_"; var $table_categries; var $db_version = '0.1'; function template_redirect() { if (is_feed()) { return; } 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() { if(function_exists('load_plugin_textdomain')) { load_plugin_textdomain('all_in_one_seo_pack', 'wp-content/plugins/all-in-one-seo-pack'); } //$this->db_install(); } 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'))); } else if (is_category()) { $description = category_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_tag_start = ""; $title_tag_end = ""; $len_start = strlen($title_tag_start); $len_end = strlen($title_tag_end); $title = stripslashes(trim($title)); $start = strpos($content, ""); $end = strpos($content, ""); if ($start && $end) { $header = substr($content, 0, $start + $len_start) . $title . substr($content, $end); } else { $header = $content . "$title"; } return $header; } function rewrite_title($header) { global $wp_query; if (!$wp_query) { $header .= "\n"; return $header; } $post = $wp_query->get_queried_object(); // the_search_query() is not suitable, it cannot just return global $s; if (is_home()) { if (get_option('aiosp_home_title')) { $header = $this->replace_title($header, get_option('aiosp_home_title')); } } else if (is_single()) { $title = get_post_meta($post->ID, "title", true); if (!$title) { $title = wp_title('', false); } $title_format = get_option('aiosp_post_title_format'); $new_title = str_replace('%blog_title%', get_bloginfo('name'), $title_format); $new_title = str_replace('%post_title%', $title, $new_title); $title = $new_title; $title = trim($title); $header = $this->replace_title($header, $title); } else if (is_search() && isset($s) && !empty($s)) { if (function_exists('attribute_escape')) { $title = attribute_escape(stripslashes($s)); } else { $title = wp_specialchars(stripslashes($s), true); } $header = $this->replace_title($header, $title); } else if (is_category() && !is_feed()) { $category_name = ucwords(single_cat_title('', false)); $title_format = get_option('aiosp_category_title_format'); $title = str_replace('%category_title%', $category_name, $title_format); $title = str_replace('%blog_title%', get_bloginfo('name'), $title); $header = $this->replace_title($header, $title); } else if (is_page()) { $title = get_post_meta($post->ID, "title", true); if (!$title) { $title = wp_title('', false); } $title_format = get_option('aiosp_page_title_format'); $new_title = str_replace('%blog_title%', get_bloginfo('name'), $title_format); $new_title = str_replace('%page_title%', $title, $new_title); $title = $new_title; $title = trim($title); $header = $this->replace_title($header, $title); } else if (function_exists('is_tag') && is_tag()) { global $utw; if ($utw) { $tags = $utw->GetCurrentTagSet(); $tag = $tags[0]->tag; $header = $this->replace_title($header, $tag); } } return $header; } function trim_excerpt_without_filters($text) { $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = $this->maximum_excerpt_length; $words = explode(' ', $text, $excerpt_length + 1); if (count($words) > $excerpt_length) { array_pop($words); array_push($words, '...'); $text = implode(' ', $words); } return trim(stripslashes($text)); } function trim_excerpt_without_filters_full_length($text) { $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = $this->maximum_excerpt_length; $words = explode(' ', $text, $excerpt_length + 1); return trim(stripslashes($text)); } /** * @return comma-separated list of unique keywords */ function get_all_keywords() { global $posts; $keywords = array(); if (is_array($posts)) { foreach ($posts as $post) { if ($post) { if (get_option('aiosp_use_categories') && !is_page()) { $categories = get_the_category($post->ID); foreach ($categories as $category) { $keywords[] = $category->cat_name; } } // Ultimate Tag Warrior integration global $utw; if ($utw) { $tags = $utw->GetTagsForPost($post); foreach ($tags as $tag) { $tag = $tag->tag; $tag = str_replace('_',' ', $tag); $tag = str_replace('-',' ',$tag); $tag = stripslashes($tag); $keywords[] = $tag; } } // WP 2.3 tags if (function_exists('get_tags')) { $tags = get_tags(); foreach ($tags as $tag) { $keywords[] = $tag->name; } } $keywords_a = $keywords_i = null; $description_a = $description_i = null; $id = $post->ID; $keywords_i = stripslashes(get_post_meta($post->ID, "keywords", true)); if (isset($keywords_i) && !empty($keywords_i)) { $keywords[] = $keywords_i; } } } } return $this->get_unique_keywords($keywords); } function db_install() { global $wpdb; $this->table_categories = $wpdb->prefix . $this->table_prefix . "categories"; if(get_option('aiosp_db_version') != $this->db_version) { $sql = "CREATE TABLE $this->table_categories ( ID bigint(20) NOT NULL auto_increment, category_id bigint(20) NOT NULL default '0', meta_title text NOT NULL, meta_description text NOT NULL, meta_keywords text NOT NULL, PRIMARY KEY (ID), KEY category_id (category_id));"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sql); update_option('aiosp_db_version', $this->db_version); } } function get_unique_keywords($keywords) { $keywords_ar = array_unique($keywords); return implode(',', $keywords_ar); } function post_meta_tags($id) { $awmp_edit = $_POST["aiosp_edit"]; if (isset($awmp_edit) && !empty($awmp_edit)) { $keywords = $_POST["aiosp_keywords"]; $description = $_POST["aiosp_description"]; $title = $_POST["aiosp_title"]; delete_post_meta($id, 'keywords'); delete_post_meta($id, 'description'); delete_post_meta($id, 'title'); if (isset($keywords) && !empty($keywords)) { add_post_meta($id, 'keywords', $keywords); } if (isset($description) && !empty($description)) { add_post_meta($id, 'description', $description); } if (isset($title) && !empty($title)) { add_post_meta($id, 'title', $title); } } } function edit_category($id) { global $wpdb; $id = $wpdb->escape($id); $awmp_edit = $_POST["aiosp_edit"]; if (isset($awmp_edit) && !empty($awmp_edit)) { $keywords = $wpdb->escape($_POST["aiosp_keywords"]); $title = $wpdb->escape($_POST["aiosp_title"]); $old_category = $wpdb->get_row("select * from $this->table_categories where category_id=$id", OBJECT); if ($old_category) { $wpdb->query("update $this->table_categories set meta_title='$title', meta_keywords='$keywords' where category_id=$id"); } else { $wpdb->query("insert into $this->table_categories(meta_title, meta_keywords, category_id) values ('$title', '$keywords', $id"); } //$wpdb->query("insert into $this->table_categories") /* delete_post_meta($id, 'keywords'); delete_post_meta($id, 'description'); delete_post_meta($id, 'title'); if (isset($keywords) && !empty($keywords)) { add_post_meta($id, 'keywords', $keywords); } if (isset($description) && !empty($description)) { add_post_meta($id, 'description', $description); } if (isset($title) && !empty($title)) { add_post_meta($id, 'title', $title); } */ } } function edit_category_form() { global $post; $keywords = stripslashes(get_post_meta($post->ID, 'keywords', true)); $title = stripslashes(get_post_meta($post->ID, 'title', true)); $description = stripslashes(get_post_meta($post->ID, 'description', true)); ?>
All in One SEO Pack
ID, 'keywords', true))); $title = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'title', true))); $description = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'description', true))); ?>
All in One SEO Pack
ID, 'keywords', true))); $description = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'description', true))); $title = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'title', true))); ?>

version. " . 'Should I upgrade?', 'all_in_one_seo_pack') ?>

Help', 'all_in_one_seo_pack') ?> | FAQ', 'all_in_one_seo_pack') ?> | Feedback', 'all_in_one_seo_pack') ?>

/>
/>
/>
/>
/>
/>