Plugin Directory

Changeset 3793012


Ignore:
Timestamp:
11/09/2026 06:07:35 PM (less than one hour ago)
Author:
trustami
Message:

Release 1.1.1: ship the complete plugin package (1.1.0 was missing files)

Location:
trustami-badge-for-customer-reviews-and-google-stars
Files:
8 deleted
36 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/README.txt

    r3773501 r3793012  
    55Requires at least: 6.0
    66Tested up to: 7.1
    7 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    88Requires PHP: 7.4
    99License: GPLv3
    … …  
    119119* fix widget script not loading when the custom data attribute contains quotes or invalid JSON
    120120* add missing German translation
     121
     122= 1.1.1 =
     123* fix fatal error after updating to 1.1.0: the 1.1.0 package on wordpress.org was missing files, 1.1.1 ships the complete plugin
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/class-trustami-settings-tab.php

    r3417416 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit; // Exit if accessed directly
    5 }
     3defined('ABSPATH') || exit; // Exit if accessed directly
    64
    75class WC_Trustami_Settings_Tab
    … …  
    131129                'name' => __('Display trust badge text in the footer', 'trustami-badge-for-customer-reviews-and-google-stars'),
    132130                'type' => 'checkbox',
    133                 'default' => '1',
     131                'default' => 'no',
    134132                'id' => 'WC_Trustami_Settings_Tab_text_badge'
    135133            ),
    … …  
    137135                'name' => __('Display trust badge overlay', 'trustami-badge-for-customer-reviews-and-google-stars'),
    138136                'type' => 'checkbox',
    139                 'default' => '1',
     137                'default' => 'no',
    140138                'id' => 'WC_Trustami_Settings_Tab_overlay_badge'
    141139            ),
    … …  
    143141                'name' => __('Display trust badge frame', 'trustami-badge-for-customer-reviews-and-google-stars'),
    144142                'type' => 'checkbox',
    145                 'default' => '1',
     143                'default' => 'no',
    146144                'id' => 'WC_Trustami_Settings_Tab_overlay_frame'
    147145            ),
    … …  
    149147                'name' => __('Display trust badge list', 'trustami-badge-for-customer-reviews-and-google-stars'),
    150148                'type' => 'checkbox',
    151                 'default' => '1',
     149                'default' => 'no',
    152150                'id' => 'WC_Trustami_Settings_Tab_overlay_list'
    153151            ),
    … …  
    155153                'name' => __('Display trust badge sticker', 'trustami-badge-for-customer-reviews-and-google-stars'),
    156154                'type' => 'checkbox',
    157                 'default' => '1',
     155                'default' => 'no',
    158156                'id' => 'WC_Trustami_Settings_Tab_overlay_sticker'
    159157            ),
    … …  
    161159                'name' => __('Display trust badge button', 'trustami-badge-for-customer-reviews-and-google-stars'),
    162160                'type' => 'checkbox',
    163                 'default' => '0',
     161                'default' => 'no',
    164162                'id' => 'WC_Trustami_Settings_Tab_overlay_button'
    165163            ),
    … …  
    167165                'name' => __('Display trust badge social', 'trustami-badge-for-customer-reviews-and-google-stars'),
    168166                'type' => 'checkbox',
    169                 'default' => '0',
     167                'default' => 'no',
    170168                'id' => 'WC_Trustami_Settings_Tab_overlay_social'
    171169            ),
    … …  
    173171                'name' => __('Display trust badge duo', 'trustami-badge-for-customer-reviews-and-google-stars'),
    174172                'type' => 'checkbox',
    175                 'default' => '0',
     173                'default' => 'no',
    176174                'id' => 'WC_Trustami_Settings_Tab_overlay_duo'
    177175            ),
    … …  
    179177                'name' => __('Display trust badge stars', 'trustami-badge-for-customer-reviews-and-google-stars'),
    180178                'type' => 'checkbox',
    181                 'default' => '0',
     179                'default' => 'no',
    182180                'id' => 'WC_Trustami_Settings_Tab_overlay_stars'
    183181            ),
    … …  
    185183                'name' => __('Display Shopauskunft trust badge', 'trustami-badge-for-customer-reviews-and-google-stars'),
    186184                'type' => 'checkbox',
    187                 'default' => '0',
     185                'default' => 'no',
    188186                'id' => 'WC_Trustami_Settings_Tab_overlay_shopak'
    189187            ),
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/class-trustami.php

    r3417416 r3793012  
    7070
    7171                $this->plugin_name = 'Trustami Badge for Customer Reviews and Google Stars';
    72                 $this->version = '1.0.12';
     72                $this->version = '1.1.1';
    7373
    7474                $this->load_dependencies();
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-badge.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-box.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-button.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-comments.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-container.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-duo.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-shopauskunft.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-social.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-stars.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-sticker.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/includes/widgets/class-trustami-widget-text.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/languages/trustami-badge-for-customer-reviews-and-google-stars-de_DE.po

    r3417416 r3793012  
    103103msgstr "Wähle den Action Hook, der die Header Snippets erzeugt (bspw. get_header, wp_head). Standardwert: get_header"
    104104
     105msgid "Product Action Hook"
     106msgstr "Produkt Action Hook"
     107
    105108msgid "Choose the filter-hook used to create product snippets (e.g. woocommerce_short_description, woocommerce_product_get_short_description, woocommerce_product_meta_end). Default: woocommerce_short_description"
    106109msgstr "Wähle den Filter Hook, der die Produkt Snippets erzeugt (bspw. woocommerce_short_description, woocommerce_product_get_short_description, woocommerce_product_meta_end). Standardwert: woocommerce_short_description"
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/public/class-trustami-public.php

    r3417416 r3793012  
    6363    function returnTrustamiScriptCnt()
    6464    {
    65         $opts = get_option('WC_Trustami_Settings_Tab_trustami_profile_id');
    66         if (!empty($opts)) {
    67             $footerCtn = "";
    68 
    69             $options = array(
    70                 "profileId" => $opts,
    71                 "textBadge" => get_option('WC_Trustami_Settings_Tab_text_badge'),
    72                 "overlayBadge" => get_option('WC_Trustami_Settings_Tab_overlay_badge'),
    73                 "overlayFrame" => get_option('WC_Trustami_Settings_Tab_overlay_frame'),
    74                 "overlayList" => get_option('WC_Trustami_Settings_Tab_overlay_list'),
    75                 "overlaySticker" => get_option('WC_Trustami_Settings_Tab_overlay_sticker'),
    76                 "overlayButton" => get_option('WC_Trustami_Settings_Tab_overlay_button'),
    77                 "overlaySocial" => get_option('WC_Trustami_Settings_Tab_overlay_social'),
    78                 "overlayDuo" => get_option('WC_Trustami_Settings_Tab_overlay_duo'),
    79                 "cusDataAtt" => get_option('WC_Trustami_Settings_Tab_cus_data_att')
    80             );
    81 
    82             $footerCtn .= '<script>let taScript = document.createElement("script");
    83             taScript.setAttribute("type", "text/javascript");
    84             taScript.setAttribute("id", "trustamiwidget");
    85             taScript.setAttribute("src", "https://cdn.trustami.com/widgetapi/widget2/trustami-widget.js?cache=off");
    86             taScript.setAttribute("data-user", "31ae1621831be5333185d875512bf5e52c480452");
    87             taScript.setAttribute("data-profile", "' . $options["profileId"] . '");
    88             taScript.setAttribute("data-platform", "0");
    89             taScript.setAttribute("data-plugin", "wc");';
    90 
    91             if (!empty($options["cusDataAtt"])) {
    92                 $footerCtn .= 'taScript.setAttribute("data-custom", "' . urlencode($options["cusDataAtt"]) . '");
    93             let ta_parsed_json = JSON.parse(\'' . $options["cusDataAtt"] . '\');
    94             for (let property in ta_parsed_json) {
    95                 if (ta_parsed_json[property] !== undefined) {
    96                     taScript.setAttribute(property, ta_parsed_json[property]);
     65        $profileId = get_option('WC_Trustami_Settings_Tab_trustami_profile_id');
     66        if (empty($profileId)) {
     67            return;
     68        }
     69
     70        $attributes = array(
     71            'type' => 'text/javascript',
     72            'id' => 'trustamiwidget',
     73            'src' => 'https://cdn.trustami.com/widgetapi/widget2/trustami-widget.js?cache=off',
     74            'data-user' => '31ae1621831be5333185d875512bf5e52c480452',
     75            'data-profile' => (string) $profileId,
     76            'data-platform' => '0',
     77            'data-plugin' => 'wc'
     78        );
     79
     80        // The custom data attribute is a JSON object whose keys become additional script attributes.
     81        $customData = get_option('WC_Trustami_Settings_Tab_cus_data_att');
     82        if (!empty($customData)) {
     83            $attributes['data-custom'] = urlencode($customData);
     84            $parsed = json_decode($customData, true);
     85            if (is_array($parsed)) {
     86                foreach ($parsed as $name => $value) {
     87                    if (is_scalar($value)) {
     88                        $attributes[(string) $name] = (string) $value;
     89                    }
    9790                }
    98             }';
    9991            }
    100 
    101             $footerCtn .= 'document.body.appendChild(taScript);</script>';
    102             if (!empty($footerCtn)) echo $footerCtn;
    103         }
     92        }
     93
     94        // The JSON_HEX_* flags prevent values from closing the script tag or breaking out of the JS string.
     95        $json = wp_json_encode($attributes, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
     96
     97        echo '<script>let taScript = document.createElement("script");
     98            let taAttributes = ' . $json . ';
     99            for (let property in taAttributes) {
     100                taScript.setAttribute(property, taAttributes[property]);
     101            }
     102            document.body.appendChild(taScript);</script>';
    104103    }
    105104
    … …  
    156155    }
    157156   
    158     function returnTrustamiCategoryCnt($html)
    159     {
    160         $opts = get_option('WC_Trustami_Settings_Tab_trustami_profile_id');
    161         if (!empty($opts)) {
     157    /**
     158     * Output the badge in the product description.
     159     *
     160     * Works for both filter hooks (e.g. woocommerce_short_description) and action hooks
     161     * (e.g. woocommerce_product_meta_end). A filter must return its input, so the badge
     162     * is prepended to it; an action has no input, so the badge is echoed.
     163     *
     164     * The number or type of arguments cannot tell them apart: do_action() passes an empty
     165     * string to callbacks even when the action has no arguments. Instead, WordPress counts
     166     * every executed action (did_action) but not filters, so a hook with a count is an action.
     167     *
     168     * No badge is added in REST (e.g. WooCommerce Store API), JSON or feed requests.
     169     *
     170     * @param string $html Filtered content (only passed when used as a filter).
     171     * @return string|void
     172     */
     173    function returnTrustamiCategoryCnt($html = '')
     174    {
     175        $hook = current_filter();
     176        $isFilter = !$hook || did_action($hook) === 0;
     177        $catHtml = null;
     178
     179        if (!empty(get_option('WC_Trustami_Settings_Tab_trustami_profile_id')) && !$this->isNonHtmlRequest()) {
    162180            $catHtml = $this->trustamiDiv(get_option('WC_Trustami_Settings_Tab_trustami_product_display'), "productDesc");
    163             if ($catHtml) echo $catHtml;
    164         }
     181        }
     182
     183        if ($isFilter) {
     184            return $catHtml ? $catHtml . $html : $html;
     185        }
     186        if ($catHtml) {
     187            echo $catHtml;
     188        }
     189    }
     190
     191    /**
     192     * Whether the current request returns data instead of a rendered page (REST/Store API, JSON, feeds).
     193     * The badge is only useful on HTML pages, where the widget script can fill it.
     194     *
     195     * @return bool
     196     */
     197    private function isNonHtmlRequest()
     198    {
     199        return (defined('REST_REQUEST') && REST_REQUEST) || wp_is_json_request() || is_feed();
    165200    }
    166201
  • trustami-badge-for-customer-reviews-and-google-stars/tags/1.1.1/trustami.php

    r3773501 r3793012  
    1616 * Plugin URI:        https://app.trustami.com/manuals/WooCommerce?lang=en
    1717 * Description:       Trustami plugin for WooCommerce. Trustami - One badge for all your customer reviews. Trustami collects, analyzes and presents a users’ distributed social media data in a standardized and user-friendly format to fill the need for trust in online interactions. Trustami enables users to collect ratings and reviews from all networks and show a trust badge.
    18  * Version:           1.1.0
     18 * Version:           1.1.1
    1919 * Requires at least: 6.0
    2020 * Requires PHP:      7.4
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/README.txt

    r3773501 r3793012  
    55Requires at least: 6.0
    66Tested up to: 7.1
    7 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    88Requires PHP: 7.4
    99License: GPLv3
    … …  
    119119* fix widget script not loading when the custom data attribute contains quotes or invalid JSON
    120120* add missing German translation
     121
     122= 1.1.1 =
     123* fix fatal error after updating to 1.1.0: the 1.1.0 package on wordpress.org was missing files, 1.1.1 ships the complete plugin
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/class-trustami-settings-tab.php

    r3417416 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit; // Exit if accessed directly
    5 }
     3defined('ABSPATH') || exit; // Exit if accessed directly
    64
    75class WC_Trustami_Settings_Tab
    … …  
    131129                'name' => __('Display trust badge text in the footer', 'trustami-badge-for-customer-reviews-and-google-stars'),
    132130                'type' => 'checkbox',
    133                 'default' => '1',
     131                'default' => 'no',
    134132                'id' => 'WC_Trustami_Settings_Tab_text_badge'
    135133            ),
    … …  
    137135                'name' => __('Display trust badge overlay', 'trustami-badge-for-customer-reviews-and-google-stars'),
    138136                'type' => 'checkbox',
    139                 'default' => '1',
     137                'default' => 'no',
    140138                'id' => 'WC_Trustami_Settings_Tab_overlay_badge'
    141139            ),
    … …  
    143141                'name' => __('Display trust badge frame', 'trustami-badge-for-customer-reviews-and-google-stars'),
    144142                'type' => 'checkbox',
    145                 'default' => '1',
     143                'default' => 'no',
    146144                'id' => 'WC_Trustami_Settings_Tab_overlay_frame'
    147145            ),
    … …  
    149147                'name' => __('Display trust badge list', 'trustami-badge-for-customer-reviews-and-google-stars'),
    150148                'type' => 'checkbox',
    151                 'default' => '1',
     149                'default' => 'no',
    152150                'id' => 'WC_Trustami_Settings_Tab_overlay_list'
    153151            ),
    … …  
    155153                'name' => __('Display trust badge sticker', 'trustami-badge-for-customer-reviews-and-google-stars'),
    156154                'type' => 'checkbox',
    157                 'default' => '1',
     155                'default' => 'no',
    158156                'id' => 'WC_Trustami_Settings_Tab_overlay_sticker'
    159157            ),
    … …  
    161159                'name' => __('Display trust badge button', 'trustami-badge-for-customer-reviews-and-google-stars'),
    162160                'type' => 'checkbox',
    163                 'default' => '0',
     161                'default' => 'no',
    164162                'id' => 'WC_Trustami_Settings_Tab_overlay_button'
    165163            ),
    … …  
    167165                'name' => __('Display trust badge social', 'trustami-badge-for-customer-reviews-and-google-stars'),
    168166                'type' => 'checkbox',
    169                 'default' => '0',
     167                'default' => 'no',
    170168                'id' => 'WC_Trustami_Settings_Tab_overlay_social'
    171169            ),
    … …  
    173171                'name' => __('Display trust badge duo', 'trustami-badge-for-customer-reviews-and-google-stars'),
    174172                'type' => 'checkbox',
    175                 'default' => '0',
     173                'default' => 'no',
    176174                'id' => 'WC_Trustami_Settings_Tab_overlay_duo'
    177175            ),
    … …  
    179177                'name' => __('Display trust badge stars', 'trustami-badge-for-customer-reviews-and-google-stars'),
    180178                'type' => 'checkbox',
    181                 'default' => '0',
     179                'default' => 'no',
    182180                'id' => 'WC_Trustami_Settings_Tab_overlay_stars'
    183181            ),
    … …  
    185183                'name' => __('Display Shopauskunft trust badge', 'trustami-badge-for-customer-reviews-and-google-stars'),
    186184                'type' => 'checkbox',
    187                 'default' => '0',
     185                'default' => 'no',
    188186                'id' => 'WC_Trustami_Settings_Tab_overlay_shopak'
    189187            ),
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/class-trustami.php

    r3417416 r3793012  
    7070
    7171                $this->plugin_name = 'Trustami Badge for Customer Reviews and Google Stars';
    72                 $this->version = '1.0.12';
     72                $this->version = '1.1.1';
    7373
    7474                $this->load_dependencies();
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-badge.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-box.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-button.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-comments.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-container.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-duo.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-shopauskunft.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-social.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-stars.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-sticker.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/includes/widgets/class-trustami-widget-text.php

    r3328197 r3793012  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     exit;
    5 }
    6 // Exit if accessed directly
     3defined('ABSPATH') || exit; // Exit if accessed directly
    74
    85/**
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/languages/trustami-badge-for-customer-reviews-and-google-stars-de_DE.po

    r3417416 r3793012  
    103103msgstr "Wähle den Action Hook, der die Header Snippets erzeugt (bspw. get_header, wp_head). Standardwert: get_header"
    104104
     105msgid "Product Action Hook"
     106msgstr "Produkt Action Hook"
     107
    105108msgid "Choose the filter-hook used to create product snippets (e.g. woocommerce_short_description, woocommerce_product_get_short_description, woocommerce_product_meta_end). Default: woocommerce_short_description"
    106109msgstr "Wähle den Filter Hook, der die Produkt Snippets erzeugt (bspw. woocommerce_short_description, woocommerce_product_get_short_description, woocommerce_product_meta_end). Standardwert: woocommerce_short_description"
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/public/class-trustami-public.php

    r3417416 r3793012  
    6363    function returnTrustamiScriptCnt()
    6464    {
    65         $opts = get_option('WC_Trustami_Settings_Tab_trustami_profile_id');
    66         if (!empty($opts)) {
    67             $footerCtn = "";
    68 
    69             $options = array(
    70                 "profileId" => $opts,
    71                 "textBadge" => get_option('WC_Trustami_Settings_Tab_text_badge'),
    72                 "overlayBadge" => get_option('WC_Trustami_Settings_Tab_overlay_badge'),
    73                 "overlayFrame" => get_option('WC_Trustami_Settings_Tab_overlay_frame'),
    74                 "overlayList" => get_option('WC_Trustami_Settings_Tab_overlay_list'),
    75                 "overlaySticker" => get_option('WC_Trustami_Settings_Tab_overlay_sticker'),
    76                 "overlayButton" => get_option('WC_Trustami_Settings_Tab_overlay_button'),
    77                 "overlaySocial" => get_option('WC_Trustami_Settings_Tab_overlay_social'),
    78                 "overlayDuo" => get_option('WC_Trustami_Settings_Tab_overlay_duo'),
    79                 "cusDataAtt" => get_option('WC_Trustami_Settings_Tab_cus_data_att')
    80             );
    81 
    82             $footerCtn .= '<script>let taScript = document.createElement("script");
    83             taScript.setAttribute("type", "text/javascript");
    84             taScript.setAttribute("id", "trustamiwidget");
    85             taScript.setAttribute("src", "https://cdn.trustami.com/widgetapi/widget2/trustami-widget.js?cache=off");
    86             taScript.setAttribute("data-user", "31ae1621831be5333185d875512bf5e52c480452");
    87             taScript.setAttribute("data-profile", "' . $options["profileId"] . '");
    88             taScript.setAttribute("data-platform", "0");
    89             taScript.setAttribute("data-plugin", "wc");';
    90 
    91             if (!empty($options["cusDataAtt"])) {
    92                 $footerCtn .= 'taScript.setAttribute("data-custom", "' . urlencode($options["cusDataAtt"]) . '");
    93             let ta_parsed_json = JSON.parse(\'' . $options["cusDataAtt"] . '\');
    94             for (let property in ta_parsed_json) {
    95                 if (ta_parsed_json[property] !== undefined) {
    96                     taScript.setAttribute(property, ta_parsed_json[property]);
     65        $profileId = get_option('WC_Trustami_Settings_Tab_trustami_profile_id');
     66        if (empty($profileId)) {
     67            return;
     68        }
     69
     70        $attributes = array(
     71            'type' => 'text/javascript',
     72            'id' => 'trustamiwidget',
     73            'src' => 'https://cdn.trustami.com/widgetapi/widget2/trustami-widget.js?cache=off',
     74            'data-user' => '31ae1621831be5333185d875512bf5e52c480452',
     75            'data-profile' => (string) $profileId,
     76            'data-platform' => '0',
     77            'data-plugin' => 'wc'
     78        );
     79
     80        // The custom data attribute is a JSON object whose keys become additional script attributes.
     81        $customData = get_option('WC_Trustami_Settings_Tab_cus_data_att');
     82        if (!empty($customData)) {
     83            $attributes['data-custom'] = urlencode($customData);
     84            $parsed = json_decode($customData, true);
     85            if (is_array($parsed)) {
     86                foreach ($parsed as $name => $value) {
     87                    if (is_scalar($value)) {
     88                        $attributes[(string) $name] = (string) $value;
     89                    }
    9790                }
    98             }';
    9991            }
    100 
    101             $footerCtn .= 'document.body.appendChild(taScript);</script>';
    102             if (!empty($footerCtn)) echo $footerCtn;
    103         }
     92        }
     93
     94        // The JSON_HEX_* flags prevent values from closing the script tag or breaking out of the JS string.
     95        $json = wp_json_encode($attributes, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
     96
     97        echo '<script>let taScript = document.createElement("script");
     98            let taAttributes = ' . $json . ';
     99            for (let property in taAttributes) {
     100                taScript.setAttribute(property, taAttributes[property]);
     101            }
     102            document.body.appendChild(taScript);</script>';
    104103    }
    105104
    … …  
    156155    }
    157156   
    158     function returnTrustamiCategoryCnt($html)
    159     {
    160         $opts = get_option('WC_Trustami_Settings_Tab_trustami_profile_id');
    161         if (!empty($opts)) {
     157    /**
     158     * Output the badge in the product description.
     159     *
     160     * Works for both filter hooks (e.g. woocommerce_short_description) and action hooks
     161     * (e.g. woocommerce_product_meta_end). A filter must return its input, so the badge
     162     * is prepended to it; an action has no input, so the badge is echoed.
     163     *
     164     * The number or type of arguments cannot tell them apart: do_action() passes an empty
     165     * string to callbacks even when the action has no arguments. Instead, WordPress counts
     166     * every executed action (did_action) but not filters, so a hook with a count is an action.
     167     *
     168     * No badge is added in REST (e.g. WooCommerce Store API), JSON or feed requests.
     169     *
     170     * @param string $html Filtered content (only passed when used as a filter).
     171     * @return string|void
     172     */
     173    function returnTrustamiCategoryCnt($html = '')
     174    {
     175        $hook = current_filter();
     176        $isFilter = !$hook || did_action($hook) === 0;
     177        $catHtml = null;
     178
     179        if (!empty(get_option('WC_Trustami_Settings_Tab_trustami_profile_id')) && !$this->isNonHtmlRequest()) {
    162180            $catHtml = $this->trustamiDiv(get_option('WC_Trustami_Settings_Tab_trustami_product_display'), "productDesc");
    163             if ($catHtml) echo $catHtml;
    164         }
     181        }
     182
     183        if ($isFilter) {
     184            return $catHtml ? $catHtml . $html : $html;
     185        }
     186        if ($catHtml) {
     187            echo $catHtml;
     188        }
     189    }
     190
     191    /**
     192     * Whether the current request returns data instead of a rendered page (REST/Store API, JSON, feeds).
     193     * The badge is only useful on HTML pages, where the widget script can fill it.
     194     *
     195     * @return bool
     196     */
     197    private function isNonHtmlRequest()
     198    {
     199        return (defined('REST_REQUEST') && REST_REQUEST) || wp_is_json_request() || is_feed();
    165200    }
    166201
  • trustami-badge-for-customer-reviews-and-google-stars/trunk/trustami.php

    r3773501 r3793012  
    1616 * Plugin URI:        https://app.trustami.com/manuals/WooCommerce?lang=en
    1717 * Description:       Trustami plugin for WooCommerce. Trustami - One badge for all your customer reviews. Trustami collects, analyzes and presents a users’ distributed social media data in a standardized and user-friendly format to fill the need for trust in online interactions. Trustami enables users to collect ratings and reviews from all networks and show a trust badge.
    18  * Version:           1.1.0
     18 * Version:           1.1.1
    1919 * Requires at least: 6.0
    2020 * Requires PHP:      7.4
Note: See TracChangeset for help on using the changeset viewer.