diff --git a/includes/News/News.php b/includes/News/News.php index 58815c39..6c42a190 100644 --- a/includes/News/News.php +++ b/includes/News/News.php @@ -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']); } /** @@ -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) { @@ -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') { @@ -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 { @@ -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 .= ''; - if (has_post_thumbnail($id) && ! $hide_thumbnail && !$imgFirst) { + if ($displayThumbnail && !$imgFirst) { $output .= '
' . get_the_post_thumbnail($id, $thumbnailSize) . '' . '
'; @@ -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; + } + } } diff --git a/package.json b/package.json index e3f2a83d..efc1e095 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/rrze-elements.php b/rrze-elements.php index 8ab0d4b0..d334543f 100644 --- a/rrze-elements.php +++ b/rrze-elements.php @@ -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