$post) {
if ($title_list_only) {
$results[] = self::getPostTitle($post, $args);
} else {
$postJSON = self::postToEditorJson($post, $args);
$results = array_merge($results, $postJSON);
if ($use_divider && $index + 1 < $total_posts) {
$results[] = $args['divider'];
}
}
}
if ($title_list_only && !empty($results)) {
$results = array(
array(
'type' => 'text',
'text' => '
' . implode('', $results) . '
',
),
);
}
return $results;
}
private static function postToEditorJson($post, $args) {
if ($args['displayType'] === 'titleOnly') {
$content = '';
} elseif ($args['displayType'] === 'excerpt') {
// get excerpt
if(!empty($post->post_excerpt)) {
$content = $post->post_excerpt;
} else {
// if excerpt is empty then try to find the "more" tag
$excerpts = explode('', $post->post_content);
if (count($excerpts) > 1) {
// separator was present
$content = $excerpts[0];
} else {
// Separator not present, try to shorten long posts
$content = self::postContentToExcerpt($post->post_content, self::MAX_EXCERPT_LENGTH);
}
}
} else {
$content = $post->post_content;
}
if (strlen($post->post_content) < strlen($content)) {
$hideReadMore = true;
} else {
$hideReadMore = false;
}
$content = self::stripShortCodes($content);
// remove wysija nl shortcode
$content = preg_replace('/\(.*?)\<\/div>/','',$content);
// convert embedded content if necessary
$content = self::convertEmbeddedContent($content);
// convert h4 h5 h6 to h3
$content = preg_replace('/<([\/])?h[456](.*?)>/', '<$1h3$2>', $content);
if ($args['titlePosition'] === 'aboveBlock') {
$content = self::getPostTitle($post, $args) . $content;
}
// convert currency signs
$content = str_replace(array('$', '€', '£', '¥'), array('$', '€', '£', '¥'), $content);
// strip useless tags
$tags_not_being_stripped = array('
![]()
', '
','','','','','','