Esempio n. 1
0
 function avia_link_content_filter($current_post)
 {
     //retrieve the link for the post
     $link = "";
     $pattern1 = '!^(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/[^\\s]*)?!';
     $pattern2 = "!^\\<a.+?<\\/a>!";
     $pattern3 = "!\\<a.+?<\\/a>!";
     //if the url is at the begnning of the content extract it
     preg_match($pattern1, $current_post['content'], $link);
     if (!empty($link[0])) {
         $link = $link[0];
         $current_post['title'] = "<a href='{$link}' rel='bookmark' title='" . __('Link to:', 'avia_framework') . " " . the_title_attribute('echo=0') . "' >" . get_the_title() . "</a>";
         $current_post['content'] = str_replace($link, "", $current_post['content']);
     } else {
         preg_match($pattern2, $current_post['content'], $link);
         if (!empty($link[0])) {
             $current_post['title'] = $link[0];
             $current_post['content'] = str_replace($link, "", $current_post['content']);
         } else {
             preg_match($pattern3, $current_post['content'], $link);
             if (!empty($link[0])) {
                 $current_post['title'] = $link[0];
             }
         }
     }
     if ($link) {
         $heading = is_singular() ? "h1" : "h2";
         //$current_post['title'] = "<{$heading} class='post-title ". avia_offset_class('meta', false). "'>".$current_post['title']."</{$heading}>";
         $current_post['title'] = "<{$heading} class='post-title'>" . $current_post['title'] . "</{$heading}>";
     } else {
         $current_post = avia_default_title_filter($current_post);
     }
     return $current_post;
 }
 function avia_link_content_filter($current_post)
 {
     //retrieve the link for the post
     $link = "";
     $pattern1 = '$^\\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$i';
     $pattern2 = "!^\\<a.+?<\\/a>!";
     $pattern3 = "!\\<a.+?<\\/a>!";
     //if the url is at the begnning of the content extract it
     preg_match($pattern1, $current_post['content'], $link);
     if (!empty($link[0])) {
         $link = $link[0];
         $markup = avia_markup_helper(array('context' => 'entry_title', 'echo' => false));
         $current_post['title'] = "<a href='{$link}' rel='bookmark' title='" . __('Link to:', 'avia_framework') . " " . the_title_attribute('echo=0') . "' {$markup}>" . get_the_title() . "</a>";
         $current_post['content'] = preg_replace("!" . str_replace("?", "\\?", $link) . "!", "", $current_post['content'], 1);
     } else {
         preg_match($pattern2, $current_post['content'], $link);
         if (!empty($link[0])) {
             $link = $link[0];
             $current_post['title'] = $link;
             $current_post['content'] = preg_replace("!" . str_replace("?", "\\?", $link) . "!", "", $current_post['content'], 1);
         } else {
             preg_match($pattern3, $current_post['content'], $link);
             if (!empty($link[0])) {
                 $current_post['title'] = $link[0];
             }
         }
     }
     if ($link) {
         if (is_array($link)) {
             $link = $link[0];
         }
         $heading = is_singular() ? "h1" : "h2";
         //$current_post['title'] = "<{$heading} class='post-title entry-title ". avia_offset_class('meta', false). "'>".$current_post['title']."</{$heading}>";
         $current_post['title'] = "<{$heading} class='post-title entry-title' " . avia_markup_helper(array('context' => 'entry_title', 'echo' => false)) . ">" . $current_post['title'] . "</{$heading}>";
         //needs to be set for masonry
         $current_post['url'] = $link;
     } else {
         $current_post = avia_default_title_filter($current_post);
     }
     return $current_post;
 }