post_content) ) );
$postTitle = single_post_title('',false);
$currentCatDescr = strip_tags((string)category_description());
$title = get_bloginfo('name');
// DESCR LOGIC
if( ($postTitle != "") && (strlen($postTitle) > 0)){
$description = simpleStrip( simpleStrip(subword($postTitle, 50) ) );
}else{
$description = simpleStrip( simpleStrip(subword($post,50) ) );
}
// KEYW LOGIC
$keywordStack = ($postTitle.' '.$post);
$keywordStack = mb_strtolower($keywordStack, mb_detect_encoding($keywordStack));
$keywordStack = str_replace(array("'", '"'), array(''', '"'), $keywordStack);
$removedWords = array ("%", "`", "#", "(",")", ":", ";", '[', ']', '}', "*", "?", '.', "&", "'", "+" ,"<?php" ,'\r\n', '\r', "–", '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'nbsp;' ,"!" ,"?" ,"@" ,"&" ,"" ,"." ,"-" ,"- " ," -" ,"0" ,"/" ,"\n" ,"\t" ,"\r");
$keywordStack = str_replace($removedWords, "", $keywordStack );
$keywordStack = str_replace(' ', "", $keywordStack );
$keywordStack = str_replace(' ', "", $keywordStack );
$keywordStack = str_replace(' ', "", $keywordStack );
$keywordStack = str_replace(' ', "", $keywordStack );
$keywordStack = str_replace(' ', "#splithere#", $keywordStack );
$exploded = explode("#splithere#", $keywordStack);
//looping all words to md array,
$i=0;
foreach ($exploded as $key => $value) {
// counting occurances of each word
$j=0;
$exploded4=$exploded;
foreach ($exploded4 as $key2 => $value2) {
if($value2==$value){$j++;};
}
$wordArray[$i][0] = $j;
$wordArray[$i][1] = trim($value);
$i++;
}
// remove dupes
$wordArray = remove_duplicates($wordArray, 1);
// sort
sort($wordArray);
// popping some instances of the end
$removeDecimal = ( $removePercentage / 100 );
$amountToStrip = round( count($wordArray) * $removeDecimal );
$targetRemoveAmount = ( count($wordArray) - $amountToStrip );
while ( ( $k < $targetRemoveAmount ) && ( $k < $maxKeys ) ){
$wordArray2[$k] = $wordArray[$k];
$k++;
}
// make stringy
while ( $l < count($wordArray2) ){
if( ( ($wordArray2[$l][1]) != "" ) && ( ($wordArray2[$l][1]) != " " ) ) {
$keywords.= $wordArray2[$l][1].', ';
}
$l++;
}
/*prints the meta*/
print "\n\n";
print "\n".$description = '';
print "\n".$keywords = '';
print "\n\n\n";
}
/*
extention of the wordwrap core function
*/
function subWord($string, $amount){
$postBody = $string;
$excerpt = $amount;
$postBody = wordwrap($postBody, $excerpt, '######');
$pattern = "######.*";
return $postBody = eregi_replace($pattern, '', $postBody);
}
/* function credited to "a dot fotoglidis at 7mbit dot net" @ php.net */
function remove_duplicates($array, $row_element) {
$new_array[0] = $array[0];
foreach ($array as $current) {
$add_flag = 1;
foreach ($new_array as $tmp) {
if ($current[$row_element]==$tmp[$row_element]) {
$add_flag = 0; break;
}
}
if ($add_flag) $new_array[] = $current;
}
return $new_array;
}
/*
remove some bad chars
*/
function simpleStrip($removedWordsTitle){
$removedWords = array ('&;' ,'[',']' ,'}', "*", "'", "<?php", '\r\n', "nbsp", "/", "\n", "\t", "\r");
return $removedWordsTitle = trim( str_replace($removedWords, "", $removedWordsTitle ) );
}
/*
call funtions
*/
add_action('wp_head', 'OneClickMeta');
?>