meta description without opening words

stanleyb23

Member
In my old phpbb forum i asked someone to make a script to remove words like: hello, hi, hey guys etc. from the meta description.
I did this for seo.

Is it possible to create this for xenforo? What do you guys think?

This is the script:
PHP:
for( $i = 0; $i < $total_posts; $i++ )
{
    $message = $postrow[0]['post_text'];
        $find=array("Hoi,","hallo,","Hallo,","hi guys");
        $message = str_replace($find, '', $message);
    $sMetaDescription =preg_replace
                ( array
                        ( '#\\[([^/\\]=]+)[^\\]]*\\]#'  // Strip possible BBCode opening tags
                        , '#\\[/[^\\]]*\\]#'  // Closing tags
                        , '#<[^>]+>#'  // Strip possible HTML
                        , '#[\\n\\r\\t]#s'  // Strip linebreaks and tabs
                        , '# +#'  // Strip multiple spaces
                        , '#[a-z]+(:|\\&\\#58;)\\S+#i'  // Strip URIs
                        )
                , array
                        ( ''
                        , ''
                        , ''
                        , ' '
                        , ' '
                        , ' '
                        )
                , $message
                );

        // Keywords must be latin letters, ciphers and underscores only. Need to be more than 3 characters.
        $sKeyWord= ucwords( strtolower( preg_replace( '#[^a-zA-Z0-9_ ]+#', ' ', $sMetaDescription ) ) );
        
        $aKeyWord= explode( ' ', $sKeyWord );
        $aDistinct= array();
        foreach( $aKeyWord as $v1 ) if( !isset( $aDistinct[$v1] )&& strlen( $v1 )> 3 ) $aDistinct[$v1]= 0;
        $sKeyWord= implode( ', ', array_keys( $aDistinct ) );

        // Shorten description if it's longer than 150 characters
        if( ( strlen( $sMetaDescription )> 150 )&& ( $iSpace= strpos( $sMetaDescription, ' ', 150 ) )!== FALSE ) $sMetaDescription= substr( $sMetaDescription, 0, $iSpace );


        }
                $sMetaDescription=ucfirst(ltrim($sMetaDescription));

        if(strlen($sMetaDescription) > 100) {
            $template->assign_block_vars('show_meta_description', true);
             $template-> assign_vars
            ( array
                ( 'S_META_DESCRIPTION'=>$sMetaDescription
                , 'S_META_KEYWORDS'=> $sKeyWord
                )
            );
        } else {
             $template-> assign_vars
            ( array
                ( 'S_META_DESCRIPTION'=>$sMetaDescription.'--'
                , 'S_META_KEYWORDS'=> $sKeyWord
                )
            );
        }
 
Top