Skip to content

Rodyti po #261880: BBCode Auto Title For URL

Gabriel Redaguoti:
CyberGhostNet Group
Bbcode Auto Title URL For 7.0.0
if you insert url this can print the title of url you inserted.
Folow this
Open your bbcode and add this code:
/**
     * @var Auto Title
     *
     * @param string $var
     * @return string
     */

    private function Get_title($var)
    {
       $str = file_get_contents($var);
       $str = trim(preg_replace('/\s+/', ' ', $str));      
       preg_match("/\<title\>(.*)\<\/title\>/i",$str,$title);
       if(strlen($title[1]) > 0){
          return $title[1];
       } else {
         return $url;
       }
     }


Find:
return $whitespace . '<a href="' . $url . '">' . $text . '</a>' . $append;

change to
return $whitespace . '<a href="' . $url . '">' . $this->Get_title($text) . '</a>' . $append;

save and tested thanks
Show in the topic