From 455b98757cd71d29f76df6474e552f67dde95b47 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Thu, 4 Aug 2016 20:40:38 +0200 Subject: [PATCH] [WordPress] Don't attempt to load pages with missing .article Some sites use WordPress but don't provide pages with articles. Instead of throwing internal errors we just don't return any content. --- bridges/WordPressBridge.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index 50d54c4..eee3c97 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -39,6 +39,7 @@ class WordPressBridge extends BridgeAbstract { $element_text = $element->outertext; $element_text = str_replace('', '', $element_text); $element_text = str_replace('', '', $element_text); + $element_text = str_replace('author = trim($article->find('author', 0)->innertext); $item->timestamp = strtotime($article->find('updated', 0)->innertext); } + $article_html = $this->file_get_html($item->uri); - $item->content = $this->ClearContent($article_html->find('article', 0)->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 - + + $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 + } $this->items[] = $item; $i++; }