maximum_excerpt_length = get_option('aiosp_max_words_excerpt');
}
ob_start();
}
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;
}
global $post;
$meta_string = null;
$this->rewrite_title();
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) {
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("\n", $keywords);
}
if((is_category() && get_option('aiosp_category_noindex')) ||
(!is_category() && is_archive() && get_option('aiosp_archive_noindex'))) {
if (isset($meta_string)) {
$meta_string .= "\n";
}
$meta_string = '';
}
if ($meta_string != null) {
echo $meta_string;
}
}
function rewrite_title() {
global $post;
if (is_home()) {
$title = trim(stripslashes(get_option('aiosp_home_title')));
} else if (is_single() || is_page()) {
$title = stripslashes(get_post_meta($post->ID, "title", true));
} else if (is_category() && get_option('aiosp_use_category_description_as_title')) {
$title = category_description();
}
$header = ob_get_contents();
ob_end_clean();
if ($title) {
$title = addslashes($title);
$header = preg_replace_callback("/
.*<\/title>/",
create_function('$match',"return '$title';"), $header);
} else if (get_option('aiosp_rewrite_titles')) {
global $s;
if (is_search() && isset($s) && !empty($s)) {
if (function_exists('attribute_escape')) {
$title = attribute_escape(stripslashes($s));
} else {
$title = wp_specialchars(stripslashes($s), true);
}
} else if (is_single() || is_page()) {
$title = stripslashes(get_post_meta($post->ID, "title", true));
}
if (!$title) {
$title = wp_title('', false);
}
if ($title) {
$title .= ' | ' . get_bloginfo('name');
$title = trim($title);
$header = preg_replace("/.*<\/title>/", "$title", $header);
}
}
gzip_compression();
print($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));
}
function get_all_keywords() {
global $posts;
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) {
if (isset($keywords) && !empty($keywords)) {
$keywords .= ',';
}
$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);
if (isset($keywords) && !empty($keywords)) {
$keywords .= ',';
}
$keywords .= $tag;
}
}
$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)) {
if (isset($keywords) && !empty($keywords)) {
$keywords .= ',';
}
$keywords .= $keywords_i;
}
}
}
}
return $this->get_unique_keywords($keywords);
}
function get_unique_keywords($keywords) {
$keywords_ar = array_unique(explode(',', $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 add_meta_tags_textinput() {
global $post;
$keywords = stripslashes(get_post_meta($post->ID, 'keywords', true));
$title = stripslashes(get_post_meta($post->ID, 'title', true));
?>
ID, 'keywords', true));
$description = stripslashes(get_post_meta($post->ID, 'description', true));
$title = stripslashes(get_post_meta($post->ID, 'title', true));
?>
Feedback', 'all_in_one_seo_pack') ?>
| Help', 'all_in_one_seo_pack') ?>