Skip to content

Commit

Permalink
Merge pull request #305 from RRZE-Webteam/dev
Browse files Browse the repository at this point in the history
v1.25.22
  • Loading branch information
cassandre authored Oct 23, 2023
2 parents a78d0a4 + da7f913 commit b8209be
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
33 changes: 26 additions & 7 deletions includes/News/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function __construct()
{
add_shortcode('custom-news', [$this, 'shortcodeCustomNews']);
add_shortcode('blogroll', [$this, 'shortcodeCustomNews']);
add_filter( 'the_seo_framework_query_supports_seo', [$this, 'disableTSF']);
}

/**
Expand Down Expand Up @@ -188,8 +189,8 @@ function ($post_ID) {
$args['post__in'] = $id;
}

if($hideDuplicates && isset($GLOBALS['a_displayedPosts']) && is_array($GLOBALS['a_displayedPosts'])) {
$args['post__not_in'] = array_unique($GLOBALS['a_displayedPosts']);
if($hideDuplicates && isset($GLOBALS['a_rrze_elements_displayed_posts']) && is_array($GLOBALS['a_rrze_elements_displayed_posts'])) {
$args['post__not_in'] = array_unique($GLOBALS['a_rrze_elements_displayed_posts']);
}

if ($hasThumbnail) {
Expand Down Expand Up @@ -275,7 +276,7 @@ function ($post_ID) {
if (filter_var($externalLink, FILTER_VALIDATE_URL) !== false) {
$permalink = $externalLink;
}
$GLOBALS['a_displayedPosts'][] = $id;
$GLOBALS['a_rrze_elements_displayed_posts'][] = $id;
$args = [];

if ($display == 'list') {
Expand Down Expand Up @@ -419,8 +420,9 @@ private function display_news_teaser($argsRaw) {
if (filter_var($externalLink, FILTER_VALIDATE_URL) !== false) {
$permalink = $externalLink;
}
if (has_post_thumbnail($id) && ! $hide_thumbnail) {
$image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), $thumbnailSize );
$displayThumbnail = false;
if (has_post_thumbnail($id) && ! $hide_thumbnail && $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), $thumbnailSize )) {
$displayThumbnail = true;
if ($forceLandscape) {
$ratioClass = 'ratio-landscape';
} else {
Expand All @@ -441,7 +443,7 @@ private function display_news_teaser($argsRaw) {
$output .= '[columns number="'. $numCols .'"][column span="' . $postCols['left'] . '"]';
}

if (has_post_thumbnail($id) && ! $hide_thumbnail && $imgFirst) {
if ($displayThumbnail && $imgFirst && $image_data) {
$output .= '<div class="entry-thumbnail ' . $ratioClass . ' ' . $imgfloat . '" aria-hidden="true" role="presentation">'
. '<meta itemprop="image" content="'.get_the_post_thumbnail_url($id).'">'
. '<a href="'.$permalink.'" tabindex="-1">'
Expand Down Expand Up @@ -475,7 +477,7 @@ private function display_news_teaser($argsRaw) {
}
}
$output .= '</div>';
if (has_post_thumbnail($id) && ! $hide_thumbnail && !$imgFirst) {
if ($displayThumbnail && !$imgFirst) {
$output .= '<div class="entry-thumbnail ' . $ratioClass . ' ' . $imgfloat . '">' . get_the_post_thumbnail($id, $thumbnailSize)
. '<meta itemprop="image" content="'.get_the_post_thumbnail_url($id).'">'
. '</div>';
Expand Down Expand Up @@ -512,4 +514,21 @@ private function display_news_teaser($argsRaw) {

return do_shortcode($output);
}

/*
* Disable TSF on pages containing 'hideduplicates="true"' because of counter issues
* Cf. https://wordpress.org/support/topic/how-to-identify-pre-rendered-content/
*/
public function disableTSF($supported) {
if (!is_plugin_active('autodescription/autodescription.php') && !is_plugin_active_for_network('autodescription/autodescription.php')) {
return true;
}

$content = get_the_content(null, false, get_the_ID());
if (str_contains($content, 'hideduplicates="true"')) {
return false;
} else {
return TRUE;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rrze-elements",
"version": "1.25.20",
"version": "1.25.22",
"description": "RRZE Elements: Gestalterische Erweiterungen für Webauftritte.",
"main": "rrze-elements.php",
"textdomain": "rrze-elements",
Expand Down
2 changes: 1 addition & 1 deletion rrze-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: RRZE Elements
Plugin URI: https://github.com/RRZE-Webteam/rrze-elements
Description: Advanced design elements for WordPress websites.
Version: 1.25.20
Version: 1.25.22
Author: RRZE Webteam
Author URI: https://blogs.fau.de/webworking/
License: GNU General Public License v2
Expand Down

0 comments on commit b8209be

Please sign in to comment.