From 2c41ed550def91348049815f025f1df0d6781ecc Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Thu, 4 Aug 2016 21:06:12 +0200 Subject: [PATCH] [WordPress] Fix content loading --- bridges/WordPressBridge.php | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index 11cddbf..27afe0e 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -86,7 +86,7 @@ class WordPressBridge extends BridgeAbstract { if($type === WORDPRESS_TYPE_RSS){ $item->uri = $article->find('url', 0)->innertext; // 'link' => 'url'! $item->title = $article->find('title', 0)->plaintext; - $item->author = trim($article->find('dc:creator', 0)->innertext); + $item->author = trim($this->StripCDATA($article->find('dc:creator', 0)->innertext)); $item->timestamp = strtotime($article->find('pubDate', 0)->innertext); } else { $item->uri = $article->find('url', 0)->getAttribute('href'); // 'link' => 'url'! @@ -97,14 +97,30 @@ class WordPressBridge extends BridgeAbstract { $article_html = $this->file_get_html($item->uri); - $article = $article_html->find('article', 0); - if(!empty($article)){ - $item->content = $this->ClearContent($article->innertext); - if(empty($item->content)) - $item->content = $this->ClearContent($article_html->find('.single-content', 0)->innertext); // another common content div - if(empty($item->content)) - $item->content = $this->ClearContent($article_html->find('.post', 0)->innertext); // for old WordPress themes without HTML5 + // Attempt to find most common content div + if(empty($item->content)){ + $article = $article_html->find('article', 0); + if(!empty($article)){ + $item->content = $this->ClearContent($article->innertext); + } } + + // another common content div + if(empty($item->content)){ + $article = $article_html->find('.single-content', 0); + if(!empty($article)){ + $item->content = $this->ClearContent($article->innertext); + } + } + + // for old WordPress themes without HTML5 + if(empty($item->content)){ + $article = $article_html->find('.post', 0); + if(!empty($article)){ + $item->content = $this->ClearContent($article->innertext); + } + } + $this->items[] = $item; $i++; }