Ejemplo n.º 1
0
 /**
  * @param mixed $args array or string (query style eg. 'post_id=1')
  *  post_id - WP Post id (default: global post id)
  *  limit - max characters in anchor text (default: 30)
  *  pad - string used for text complement (default: ...)
  */
 public static function format($args)
 {
     self::init();
     $defaults = array('content' => null, 'post_id' => null, 'limit' => 30, 'pad' => '...');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     if (null === $content) {
         $content = self::get_content($post_id);
     }
     $url = self::find_url($content);
     if (!empty($url)) {
         self::$href = $url;
         $title = get_the_title($post_id);
         return self::format_link($url, $title, $limit, $pad);
     } else {
         foreach (self::$allowed_html_tags as $tag) {
             $html_tag = self::find_html_tag($tag, $content);
             if (!empty($html_tag)) {
                 self::$href = self::extract_attr_from_html_tag('href', $html_tag);
                 return $html_tag;
             }
         }
     }
     return null;
 }
Ejemplo n.º 2
0
function g1_post_format_the_content($content)
{
    global $post;
    if ($post) {
        switch (get_post_format($post->ID)) {
            case 'chat':
                $content = G1_Post_Format_Chat::format(array('content' => $content, 'post_id' => $post->ID));
                break;
            case 'quote':
                $content = G1_Post_Format_Quote::format(array('content' => $content, 'post_id' => $post->ID));
                break;
            case 'alink':
                $content = G1_Post_Format_Link::format(array('content' => $content, 'post_id' => $post->ID));
                break;
        }
    }
    return $content;
}