Просмотр поста

.
Fublin
function.php
public static function create_keywords($story, $separator = ', ', $keyword_count = 20) {  
   
    global $set;  
      
    $fastquotes = array ("\x22", "\x60", "\t", "\n", "\r", '"', "\\", '\r', '\n', "-", "{", "}", "[", "]" );  
    $story1 = str_replace( $fastquotes, " ", $story );  
    $story2 = preg_replace("/[^\w\x7F-\xFF\s]/", " ", $story1);  
    $story = preg_replace("/ {,1}/", " ", $story2);  
      
    $story3 = str_replace( $fastquotes, '', trim( strip_tags( str_replace( '<br />', ' ', stripslashes( $story1 ) ) ) ) );  
      
    $story3 = preg_replace("/ {,1}/", " ", $story3);  
      
      
    $set['meta_desc'] = mb_substr( $story3, 0, 190, 'UTF-8' );  
      
    $arr = explode( " ", $story );  
      
    foreach ( $arr as $word ) {  
        if( mb_strlen( $word, 'UTF-8') > 4 ) $newarr[] = $word;  
    }  
      
    $arr = array_count_values( $newarr );  
    arsort( $arr );  
      
    $arr = array_keys( $arr );  
      
    $total = count( $arr );  
      
    $offset = 0;  
      
    $arr = array_slice( $arr, $offset, $keyword_count );  
      
    $set['meta_key'] = implode( $separator, $arr );  

}