Plugin Directory

Changeset 3706275


Ignore:
Timestamp:
09/21/2026 08:19:01 PM (4 weeks ago)
Author:
ftpwebdesign
Message:

Release 2.0.5: show the product name under each video. Widget badges, footer, and the German Herkunft notice follow the site language; shortcode lang overrides it.

Location:
aboutbuzz-stories-embed
Files:
2 edited
9 copied

Legend:

Unmodified
Added
Removed
  • aboutbuzz-stories-embed/tags/2.0.5/aboutbuzz-stories-embed.php

    r3692056 r3706275  
    44Plugin URI:  https://aboutbuzz.com
    55Description: Embed AboutBuzz video stories using [aboutbuzz_reviews code="ABZ-XXXX-XXXX"] shortcode.
    6 Version:     2.0.4
     6Version:     2.0.5
    77Author:      ftpwebdesign.com
    88Author URI:  https://ftpwebdesign.com
    … …  
    1616
    1717if (!defined('ABOUTBUZZ_EMBED_VERSION')) {
    18     define('ABOUTBUZZ_EMBED_VERSION', '2.0.4');
     18    define('ABOUTBUZZ_EMBED_VERSION', '2.0.5');
    1919}
    2020
    … …  
    259259}
    260260
     261function aboutbuzz_clean_story_text($value) {
     262    if (is_array($value)) {
     263        if (!array_key_exists(0, $value) || is_array($value[0]) || is_object($value[0])) {
     264            return '';
     265        }
     266        $value = $value[0];
     267    }
     268    if (!is_string($value)) {
     269        return '';
     270    }
     271    $value = trim(sanitize_text_field($value));
     272    if ($value === '' || $value === '0') {
     273        return '';
     274    }
     275    return $value;
     276}
     277
     278function aboutbuzz_story_product_name($story) {
     279    if (!is_array($story)) {
     280        return '';
     281    }
     282    $acf  = (isset($story['acf']) && is_array($story['acf'])) ? $story['acf'] : [];
     283    $meta = (isset($story['meta']) && is_array($story['meta'])) ? $story['meta'] : [];
     284
     285    $candidates = [
     286        $acf['product'] ?? null,
     287        $acf['product_name'] ?? null,
     288        $acf['izdelek'] ?? null,
     289        $acf['product_title'] ?? null,
     290    ];
     291    if (isset($meta['product']) && is_array($meta['product'])) {
     292        $candidates[] = $meta['product'][0] ?? null;
     293    }
     294
     295    foreach ($candidates as $candidate) {
     296        $label = aboutbuzz_clean_story_text($candidate);
     297        if ($label !== '') {
     298            return $label;
     299        }
     300    }
     301    return '';
     302}
     303
    261304function aboutbuzz_smart_brand_stories_shortcode($atts) {
    262305    $atts = shortcode_atts(['code' => '', 'lang' => ''], $atts);
    … …  
    286329    }
    287330
    288     if ($from_cache && is_array($cached_body) && !empty($cached_body) && !array_key_exists('language', $cached_body[0])) {
    289         $from_cache = false;
    290         delete_transient($cache_key);
    291         $cached_body = false;
     331    if ($from_cache && is_array($cached_body) && !empty($cached_body)) {
     332        $cached_story = $cached_body[0];
     333        $has_language = is_array($cached_story) && array_key_exists('language', $cached_story);
     334        $has_product  = $has_language
     335            && isset($cached_story['acf'])
     336            && is_array($cached_story['acf'])
     337            && array_key_exists('product', $cached_story['acf']);
     338        if (!$has_language || !$has_product) {
     339            $from_cache = false;
     340            delete_transient($cache_key);
     341            $cached_body = false;
     342        }
    292343    }
    293344
    … …  
    365416            $brand_name     = $story['acf']['brand'] ?? $story['meta']['brand'][0] ?? '';
    366417            $brand_name     = is_string($brand_name) ? sanitize_text_field($brand_name) : '';
     418            $product_name   = aboutbuzz_story_product_name($story);
    367419            $jezik          = $story['acf']['jezik'] ?? '';
    368420            $language       = aboutbuzz_normalize_language(is_string($jezik) ? $jezik : '');
    … …  
    377429                    'product_source'  => [$product_source],
    378430                    'brand'           => [$brand_name],
     431                    'product'         => [$product_name],
    379432                ],
    380433                'acf'        => [
    … …  
    385438                    'product_source'  => $product_source,
    386439                    'brand'           => $brand_name,
     440                    'product'         => $product_name,
    387441                ],
    388442                'language'   => $language,
    … …  
    411465    $video_count = count($sanitized_posts);
    412466    $has_many_videos = ' aboutbutzz-has-many-videos';
     467
     468    $widget_lang = aboutbuzz_site_language();
     469    if (!empty($atts['lang'])) {
     470        $forced_lang = aboutbuzz_normalize_language($atts['lang']);
     471        if ($forced_lang !== '') {
     472            $widget_lang = $forced_lang;
     473        }
     474    }
    413475
    414476    ob_start();
    … …  
    501563                ? (is_array($video_data['product_source']) ? ($video_data['product_source'][0] ?? '') : $video_data['product_source'])
    502564                : '';
    503             $review_language = aboutbuzz_ui_language($post['language'] ?? '');
    504             if (!empty($atts['lang'])) {
    505                 $forced = aboutbuzz_normalize_language($atts['lang']);
    506                 if ($forced !== '') {
    507                     $review_language = $forced;
    508                 }
    509             }
    510             $source_badge = aboutbuzz_get_source_badge_url($product_source_value, $review_language);
    511             $brand_label  = isset($video_data['brand'])
    512                 ? (is_array($video_data['brand']) ? ($video_data['brand'][0] ?? '') : $video_data['brand'])
    513                 : '';
    514             $brand_label  = is_string($brand_label) ? trim($brand_label) : '';
    515             if ($brand_label === '0') {
    516                 $brand_label = '';
    517             }
     565            $source_badge = aboutbuzz_get_source_badge_url($product_source_value, $widget_lang);
     566            $brand_label = aboutbuzz_clean_story_text($video_data['brand'] ?? '');
     567            $product_label = aboutbuzz_clean_story_text($video_data['product'] ?? '');
     568            $under_video_label = $product_label ?: $brand_label ?: aboutbuzz_verified_review_label($widget_lang);
    518569
    519570            $is_mobile = aboutbuzz_is_mobile();
    … …  
    627678                <div class="aboutbutzz_under_video">
    628679                    <span class="aboutbutzz_verified">
    629                         <img class="aboutbutzz_check" src="<?php echo esc_url(plugin_dir_url(__FILE__) . 'assets/icons/check-gray.svg'); ?>" alt="" width="16" height="16"> <?php echo esc_html(aboutbuzz_verified_review_label($review_language)); ?>
     680                        <img class="aboutbutzz_check" src="<?php echo esc_url(plugin_dir_url(__FILE__) . 'assets/icons/check-gray.svg'); ?>" alt="" width="16" height="16"> <?php echo esc_html($under_video_label); ?>
    630681                    </span>
    631682                </div>
    … …  
    636687        <div class="aboutbutzz_footer_inline">
    637688            <span class="aboutbutzz_caption_inline">
    638                 <?php
    639                 $widget_lang = aboutbuzz_site_language();
    640                 if (!empty($atts['lang'])) {
    641                     $forced_lang = aboutbuzz_normalize_language($atts['lang']);
    642                     if ($forced_lang !== '') {
    643                         $widget_lang = $forced_lang;
    644                     }
    645                 }
    646                 echo esc_html(aboutbuzz_footer_caption($widget_lang, $average_rating));
    647                 ?>
     689                <?php echo esc_html(aboutbuzz_footer_caption($widget_lang, $average_rating)); ?>
    648690            </span>
    649691            <a href="https://aboutbuzz.com" target="_blank" rel="noopener noreferrer" class="aboutbutzz_link_inline">
    … …  
    662704        </div>
    663705        <?php
    664         $widget_lang = aboutbuzz_site_language();
    665         if (!empty($atts['lang'])) {
    666             $forced_lang = aboutbuzz_normalize_language($atts['lang']);
    667             if ($forced_lang !== '') {
    668                 $widget_lang = $forced_lang;
    669             }
    670         }
    671706        $origin_notice = aboutbuzz_review_origin_notice($widget_lang);
    672707        if ($origin_notice !== ''):
  • aboutbuzz-stories-embed/tags/2.0.5/readme.txt

    r3692056 r3706275  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.4
     6Stable tag: 2.0.5
    77Requires PHP: 7.4
    88License: GPLv2 or later
    … …  
    5252
    5353== Changelog ==
     54
     55= 2.0.5 =
     56
     57Product name under each video. Widget chrome follows the website language.
     58
     59* The line under each video is the product name, then the brand name, then the old generic label only when both are missing.
     60* Product name is the first non-empty value among `acf.product`, `acf.product_name`, `acf.izdelek`, `acf.product_title`, and `meta.product`. The reviewer's `post_title` is not used.
     61* Badges, that generic fallback, the footer rating line, and the German Herkunft notice use the site language. Shortcode `lang="de"` (or another supported code) overrides the site language for the whole widget.
     62* Stories cached before the product field existed are fetched again once.
    5463
    5564= 2.0.4 =
  • aboutbuzz-stories-embed/trunk/aboutbuzz-stories-embed.php

    r3692056 r3706275  
    44Plugin URI:  https://aboutbuzz.com
    55Description: Embed AboutBuzz video stories using [aboutbuzz_reviews code="ABZ-XXXX-XXXX"] shortcode.
    6 Version:     2.0.4
     6Version:     2.0.5
    77Author:      ftpwebdesign.com
    88Author URI:  https://ftpwebdesign.com
    … …  
    1616
    1717if (!defined('ABOUTBUZZ_EMBED_VERSION')) {
    18     define('ABOUTBUZZ_EMBED_VERSION', '2.0.4');
     18    define('ABOUTBUZZ_EMBED_VERSION', '2.0.5');
    1919}
    2020
    … …  
    259259}
    260260
     261function aboutbuzz_clean_story_text($value) {
     262    if (is_array($value)) {
     263        if (!array_key_exists(0, $value) || is_array($value[0]) || is_object($value[0])) {
     264            return '';
     265        }
     266        $value = $value[0];
     267    }
     268    if (!is_string($value)) {
     269        return '';
     270    }
     271    $value = trim(sanitize_text_field($value));
     272    if ($value === '' || $value === '0') {
     273        return '';
     274    }
     275    return $value;
     276}
     277
     278function aboutbuzz_story_product_name($story) {
     279    if (!is_array($story)) {
     280        return '';
     281    }
     282    $acf  = (isset($story['acf']) && is_array($story['acf'])) ? $story['acf'] : [];
     283    $meta = (isset($story['meta']) && is_array($story['meta'])) ? $story['meta'] : [];
     284
     285    $candidates = [
     286        $acf['product'] ?? null,
     287        $acf['product_name'] ?? null,
     288        $acf['izdelek'] ?? null,
     289        $acf['product_title'] ?? null,
     290    ];
     291    if (isset($meta['product']) && is_array($meta['product'])) {
     292        $candidates[] = $meta['product'][0] ?? null;
     293    }
     294
     295    foreach ($candidates as $candidate) {
     296        $label = aboutbuzz_clean_story_text($candidate);
     297        if ($label !== '') {
     298            return $label;
     299        }
     300    }
     301    return '';
     302}
     303
    261304function aboutbuzz_smart_brand_stories_shortcode($atts) {
    262305    $atts = shortcode_atts(['code' => '', 'lang' => ''], $atts);
    … …  
    286329    }
    287330
    288     if ($from_cache && is_array($cached_body) && !empty($cached_body) && !array_key_exists('language', $cached_body[0])) {
    289         $from_cache = false;
    290         delete_transient($cache_key);
    291         $cached_body = false;
     331    if ($from_cache && is_array($cached_body) && !empty($cached_body)) {
     332        $cached_story = $cached_body[0];
     333        $has_language = is_array($cached_story) && array_key_exists('language', $cached_story);
     334        $has_product  = $has_language
     335            && isset($cached_story['acf'])
     336            && is_array($cached_story['acf'])
     337            && array_key_exists('product', $cached_story['acf']);
     338        if (!$has_language || !$has_product) {
     339            $from_cache = false;
     340            delete_transient($cache_key);
     341            $cached_body = false;
     342        }
    292343    }
    293344
    … …  
    365416            $brand_name     = $story['acf']['brand'] ?? $story['meta']['brand'][0] ?? '';
    366417            $brand_name     = is_string($brand_name) ? sanitize_text_field($brand_name) : '';
     418            $product_name   = aboutbuzz_story_product_name($story);
    367419            $jezik          = $story['acf']['jezik'] ?? '';
    368420            $language       = aboutbuzz_normalize_language(is_string($jezik) ? $jezik : '');
    … …  
    377429                    'product_source'  => [$product_source],
    378430                    'brand'           => [$brand_name],
     431                    'product'         => [$product_name],
    379432                ],
    380433                'acf'        => [
    … …  
    385438                    'product_source'  => $product_source,
    386439                    'brand'           => $brand_name,
     440                    'product'         => $product_name,
    387441                ],
    388442                'language'   => $language,
    … …  
    411465    $video_count = count($sanitized_posts);
    412466    $has_many_videos = ' aboutbutzz-has-many-videos';
     467
     468    $widget_lang = aboutbuzz_site_language();
     469    if (!empty($atts['lang'])) {
     470        $forced_lang = aboutbuzz_normalize_language($atts['lang']);
     471        if ($forced_lang !== '') {
     472            $widget_lang = $forced_lang;
     473        }
     474    }
    413475
    414476    ob_start();
    … …  
    501563                ? (is_array($video_data['product_source']) ? ($video_data['product_source'][0] ?? '') : $video_data['product_source'])
    502564                : '';
    503             $review_language = aboutbuzz_ui_language($post['language'] ?? '');
    504             if (!empty($atts['lang'])) {
    505                 $forced = aboutbuzz_normalize_language($atts['lang']);
    506                 if ($forced !== '') {
    507                     $review_language = $forced;
    508                 }
    509             }
    510             $source_badge = aboutbuzz_get_source_badge_url($product_source_value, $review_language);
    511             $brand_label  = isset($video_data['brand'])
    512                 ? (is_array($video_data['brand']) ? ($video_data['brand'][0] ?? '') : $video_data['brand'])
    513                 : '';
    514             $brand_label  = is_string($brand_label) ? trim($brand_label) : '';
    515             if ($brand_label === '0') {
    516                 $brand_label = '';
    517             }
     565            $source_badge = aboutbuzz_get_source_badge_url($product_source_value, $widget_lang);
     566            $brand_label = aboutbuzz_clean_story_text($video_data['brand'] ?? '');
     567            $product_label = aboutbuzz_clean_story_text($video_data['product'] ?? '');
     568            $under_video_label = $product_label ?: $brand_label ?: aboutbuzz_verified_review_label($widget_lang);
    518569
    519570            $is_mobile = aboutbuzz_is_mobile();
    … …  
    627678                <div class="aboutbutzz_under_video">
    628679                    <span class="aboutbutzz_verified">
    629                         <img class="aboutbutzz_check" src="<?php echo esc_url(plugin_dir_url(__FILE__) . 'assets/icons/check-gray.svg'); ?>" alt="" width="16" height="16"> <?php echo esc_html(aboutbuzz_verified_review_label($review_language)); ?>
     680                        <img class="aboutbutzz_check" src="<?php echo esc_url(plugin_dir_url(__FILE__) . 'assets/icons/check-gray.svg'); ?>" alt="" width="16" height="16"> <?php echo esc_html($under_video_label); ?>
    630681                    </span>
    631682                </div>
    … …  
    636687        <div class="aboutbutzz_footer_inline">
    637688            <span class="aboutbutzz_caption_inline">
    638                 <?php
    639                 $widget_lang = aboutbuzz_site_language();
    640                 if (!empty($atts['lang'])) {
    641                     $forced_lang = aboutbuzz_normalize_language($atts['lang']);
    642                     if ($forced_lang !== '') {
    643                         $widget_lang = $forced_lang;
    644                     }
    645                 }
    646                 echo esc_html(aboutbuzz_footer_caption($widget_lang, $average_rating));
    647                 ?>
     689                <?php echo esc_html(aboutbuzz_footer_caption($widget_lang, $average_rating)); ?>
    648690            </span>
    649691            <a href="https://aboutbuzz.com" target="_blank" rel="noopener noreferrer" class="aboutbutzz_link_inline">
    … …  
    662704        </div>
    663705        <?php
    664         $widget_lang = aboutbuzz_site_language();
    665         if (!empty($atts['lang'])) {
    666             $forced_lang = aboutbuzz_normalize_language($atts['lang']);
    667             if ($forced_lang !== '') {
    668                 $widget_lang = $forced_lang;
    669             }
    670         }
    671706        $origin_notice = aboutbuzz_review_origin_notice($widget_lang);
    672707        if ($origin_notice !== ''):
  • aboutbuzz-stories-embed/trunk/readme.txt

    r3692056 r3706275  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.4
     6Stable tag: 2.0.5
    77Requires PHP: 7.4
    88License: GPLv2 or later
    … …  
    5252
    5353== Changelog ==
     54
     55= 2.0.5 =
     56
     57Product name under each video. Widget chrome follows the website language.
     58
     59* The line under each video is the product name, then the brand name, then the old generic label only when both are missing.
     60* Product name is the first non-empty value among `acf.product`, `acf.product_name`, `acf.izdelek`, `acf.product_title`, and `meta.product`. The reviewer's `post_title` is not used.
     61* Badges, that generic fallback, the footer rating line, and the German Herkunft notice use the site language. Shortcode `lang="de"` (or another supported code) overrides the site language for the whole widget.
     62* Stories cached before the product field existed are fetched again once.
    5463
    5564= 2.0.4 =
Note: See TracChangeset for help on using the changeset viewer.