Plugin Directory

Changeset 3451653


Ignore:
Timestamp:
02/02/2026 12:23:04 AM (8 weeks ago)
Author:
richplugins
Message:
  • Improved asset loading by adding version to file path URLs
  • Added option to disable inline CSS
  • Fixed incorrect inline CSS output
  • Fixed star icon conflicts
Location:
fb-reviews-widget
Files:
12 added
6 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • fb-reviews-widget/trunk/assets/src/css/public-main.css

    r3439940 r3451653  
    147147.trustreviews .trustreviews-img {
    148148  min-width: 50px !important;
    149   max-width: none !important;
     149  max-width: 50px !important;
    150150  height: 50px !important;
    151151  overflow: hidden !important;
     
    469469.trustreviews .trustreviews-dot {
    470470  display: inline-block !important;
    471   width: 6px !important;
    472   height: 6px !important;
     471  width: 5px !important;
     472  height: 5px !important;
    473473  background: #cccccc !important;
    474474  border-radius: 20px !important;
     
    483483
    484484.trustreviews .trustreviews-dot.active {
    485   width: 8px !important;
    486   height: 8px !important;
     485  width: 7px !important;
     486  height: 7px !important;
    487487  opacity: 1 !important;
    488   background: #427fed !important;
     488  background: #fb8e28 !important;
    489489}
    490490
  • fb-reviews-widget/trunk/assets/src/js/admin-main.js

    r3440676 r3451653  
    409409                                '</div>' +
    410410                                '<div class="{slg}-powered">Based on ' + res.review_count + ' reviews</div>' +
    411 
    412411                                (place.updated ?
    413412                                '<div class="{slg}-powered">Last updated: ' +
    414413                                    '<span class="{slg}-time">' +
    415                                         WPacTime.getTime(parseInt(place.updated), TrustReviews.Plugin.lang(), 'ago') +
     414                                        rpi.Time.getTimeAgo(parseInt(place.updated), TrustReviews.Plugin.lang()) +
    416415                                    '</span>' +
    417416                                '</div>' : '') +
  • fb-reviews-widget/trunk/assets/src/js/public-main.js

    r3035328 r3451653  
    4343        let els = document.querySelectorAll('.' + TrustReviews.slg + ' [data-rev]');
    4444        for (var i = 0; i < els.length; i++) {
    45             let time,
    46                 rev = els[i].getAttribute('data-rev'),
    47                 tel = els[i].querySelector('[data-time]'),
    48                 dat = tel.getAttribute('data-time');
    49 
    50             //if (rev == 'google') {
    51                 time = parseInt(dat);
    52                 time *= 1000;
    53             /*} else if (rev == 'facebook') {
    54                 time = new Date(dat.replace(/\+\d+$/, '')).getTime();
    55             } else {
    56                 time = new Date(dat.replace(/ /, 'T')).getTime();
    57             }*/
    58             tel.innerHTML = WPacTime.getTime(time, this.lang(), 'ago');
     45            let el = els[i].querySelector('[data-time]');
     46            el.innerHTML = rpi.Time.getTimeAgo(el.dataset.time, this.lang());
    5947        }
    6048    },
  • fb-reviews-widget/trunk/assets/src/sass/public-main.scss

    r3439940 r3451653  
    149149.#{$slg} .#{$slg}-img {
    150150    min-width: 50px !important;
    151     max-width: none !important;
     151    max-width: 50px !important;
    152152    height: 50px !important;
    153153    overflow: hidden !important;
     
    471471.#{$slg} .#{$slg}-dot {
    472472    display: inline-block !important;
    473     width: 6px !important;
    474     height: 6px !important;
     473    width: 5px !important;
     474    height: 5px !important;
    475475    background: #cccccc !important;
    476476    border-radius: 20px !important;
     
    485485
    486486.#{$slg} .#{$slg}-dot.active {
    487     width: 8px !important;
    488     height: 8px !important;
     487    width: 7px !important;
     488    height: 7px !important;
    489489    opacity: 1 !important;
    490     background: #427fed !important;
     490    background: #fb8e28 !important;
    491491}
    492492
  • fb-reviews-widget/trunk/fbrev.php

    r3440691 r3451653  
    44Plugin URI: https://wordpress.org/plugins/fb-reviews-widget
    55Description: Combine Facebook recommendations with Google, Yelp and TripAdvisor reviews in a widget, block or shortcode. Build a trusted website!
    6 Version: 2.7.2
     6Version: 2.7.3
    77Author: Trust.Reviews <support@trust.reviews>
    88Author URI: https://trust.reviews
     
    2222
    2323define('TRUSTREVIEWS_PLUGIN_FILE' , __FILE__);
     24define('TRUSTREVIEWS_PLUGIN_PATH' , plugin_dir_path(TRUSTREVIEWS_PLUGIN_FILE));
    2425
    2526require_once __DIR__ . '/autoloader.php';
  • fb-reviews-widget/trunk/includes/class-assets.php

    r3439940 r3451653  
    99    private $debug;
    1010
     11    private $css_cache = array();
     12
    1113    private static $css_assets = array(
    12         //'rpi-star-yelp-css'                  => 'https://cdn.reviewsplugin.com/assets/css/star-yelp.css',
    13         'rpi-star-yelp-css'                  => 'https://cdn.reviewsplugin.com/assets/css/stars.css',
     14        'rpi-stars-css'                  => 'https://cdn.reviewsplugin.com/assets/css/stars.css',
    1415        Plugin::SLG . '-admin-main-css'      => 'css/admin-main',
    15         //Plugin::SLG . '-public-clean-css'    => 'css/public-clean',
    1616        Plugin::SLG . '-public-main-css'     => 'css/public-main',
    1717    );
     
    1919    private static $js_assets = array(
    2020        'rpi-toast-js'                       => 'https://cdn.reviewsplugin.com/assets/js/toast.js',
     21        'rpi-time-js'                        => 'https://cdn.reviewsplugin.com/assets/js/time.js',
    2122        Plugin::SLG . '-admin-main-js'       => 'js/admin-main',
    2223        Plugin::SLG . '-admin-builder-js'    => 'js/admin-builder',
    2324        Plugin::SLG . '-admin-apexcharts-js' => 'js/admin-apexcharts',
    24         Plugin::SLG . '-public-time-js'      => 'js/public-time',
    2525        Plugin::SLG . '-public-main-js'      => 'js/public-main'
    2626    );
     
    4141            add_action('wp_enqueue_scripts', array($this, 'register_styles'));
    4242            add_action('wp_enqueue_scripts', array($this, 'register_scripts'));
     43
    4344            $demand_assets = get_option(Plugin::SLG . '_demand_assets');
    4445            if (!$demand_assets || $demand_assets != 'true') {
     
    4647                add_action('wp_enqueue_scripts', array($this, 'enqueue_public_scripts'));
    4748            }
    48             add_filter('script_loader_tag', array($this, 'add_async'), 10, 2);
     49
     50            add_filter('script_loader_tag', array($this, 'script_async'), 10, 2);
    4951        }
    5052        add_filter('get_rocket_option_remove_unused_css_safelist', array($this, 'rucss_safelist'));
    5153    }
    5254
    53     function add_async($tag, $handle) {
    54         $js_assets = array(
    55             Plugin::SLG . '-admin-main-js'    => 'js/admin-main',
    56             Plugin::SLG . '-admin-builder-js' => 'js/admin-builder',
    57             Plugin::SLG . '-public-time-js'   => 'js/public-time',
    58             Plugin::SLG . '-public-main-js'   => 'js/public-main',
    59         );
    60         if (isset($handle) && array_key_exists($handle, $js_assets)) {
    61             return str_replace(' src', ' defer="defer" src', $tag);
    62         }
    63         return $tag;
     55    function script_async($tag, $handle) {
     56        $defer = array(
     57            Plugin::SLG . '-admin-main-js',
     58            Plugin::SLG . '-admin-builder-js',
     59            Plugin::SLG . '-public-main-js',
     60        );
     61        if (!in_array($handle, $defer, true)) {
     62            return $tag;
     63        }
     64        if (strpos($tag, ' defer') !== false || strpos($tag, ' async') !== false) {
     65            return $tag;
     66        }
     67        return preg_replace('/<script\b/i', '<script defer="defer"', $tag, 1);
    6468    }
    6569
     
    7579    public function register_styles() {
    7680        $styles = array(
    77             'rpi-star-yelp-css',
     81            'rpi-stars-css',
    7882            Plugin::SLG . '-admin-main-css',
    7983            Plugin::SLG . '-public-main-css'
    8084        );
    81         /*if ($this->debug) {
    82             array_push($styles, Plugin::SLG . '-public-clean-css');
    83         }*/
    8485        $this->register_styles_loop($styles);
    8586    }
     
    8788    public function register_scripts() {
    8889        $scripts = array(
    89             'rpi-toast-js',
    9090            Plugin::SLG . '-admin-main-js',
    9191            Plugin::SLG . '-public-main-js',
     
    9393        );
    9494        if ($this->debug) {
     95            array_push($scripts, 'rpi-toast-js');
     96            array_push($scripts, 'rpi-time-js');
    9597            array_push($scripts, Plugin::SLG . '-admin-builder-js');
    96             array_push($scripts, Plugin::SLG . '-public-time-js');
    9798        }
    9899        $this->register_scripts_loop($scripts);
     
    132133    public function enqueue_public_styles() {
    133134        if ($this->debug) {
    134             wp_enqueue_style('rpi-star-yelp-css');
    135             //wp_enqueue_style(Plugin::SLG . '-public-clean-css');
    136             //wp_style_add_data(Plugin::SLG . '-public-clean-css', 'rtl', 'replace');
    137         }
    138         wp_enqueue_style(Plugin::SLG . '-public-main-css');
    139         wp_style_add_data(Plugin::SLG . '-public-main-css', 'rtl', 'replace');
     135            wp_enqueue_style('rpi-stars-css');
     136        }
     137
     138        $handle = Plugin::SLG . '-public-main-css';
     139        $inlinecss_off = get_option(Plugin::SLG . '_inlinecss_off');
     140        if ($inlinecss_off !== 'true') {
     141            $css = $this->get_css_content('public-main');
     142            if (!empty($css)) {
     143                wp_dequeue_style($handle);
     144                wp_deregister_style($handle);
     145                wp_register_style($handle, false);
     146                wp_enqueue_style($handle);
     147                wp_add_inline_style($handle, $css);
     148                return;
     149            }
     150        }
     151
     152        wp_enqueue_style($handle);
     153        wp_style_add_data($handle, 'rtl', 'replace');
    140154    }
    141155
    142156    public function enqueue_public_scripts() {
    143157        if ($this->debug) {
    144             wp_enqueue_script(Plugin::SLG . '-public-time-js');
     158            wp_enqueue_script('rpi-time-js');
    145159        }
    146160        wp_enqueue_script(Plugin::SLG . '-public-main-js');
     
    161175    public function get_css_asset($asset) {
    162176        $css = self::$css_assets[$asset];
    163         return strpos($css, 'https:') === 0 ? $css : $this->url . ($this->debug ? 'src/' : '') . $css . '.css';
     177        return strpos($css, 'https:') === 0 ? $css : $this->url . ($this->debug ? 'src/' : $this->version . '/') . $css . '.css';
    164178    }
    165179
    166180    public function get_js_asset($asset) {
    167181        $js = self::$js_assets[$asset];
    168         return strpos($js, 'https:') === 0 ? $js : $this->url . ($this->debug ? 'src/' : '') . $js . '.js';
     182        return strpos($js, 'https:') === 0 ? $js : $this->url . ($this->debug ? 'src/' : $this->version . '/') . $js . '.js';
    169183    }
    170184
     
    173187    }
    174188
     189    private function get_css_content($name) {
     190        $key = $name . (is_rtl() ? '-rtl' : '');
     191
     192        if (isset($this->css_cache[$key])) {
     193            return $this->css_cache[$key];
     194        }
     195
     196        $file = TRUSTREVIEWS_PLUGIN_PATH . '/assets/' . ($this->debug ? 'src/' : $this->version . '/') . 'css/' . $key . '.css';
     197        if (!file_exists($file) || !is_readable($file)) {
     198            return $this->css_cache[$key] = '';
     199        }
     200        $css = (string) file_get_contents($file);
     201        return $this->css_cache[$key] = $css;
     202    }
    175203}
  • fb-reviews-widget/trunk/includes/class-plugin-settings.php

    r3439940 r3451653  
    3131        $activation_time = get_option(Plugin::SLG . '_activation_time');
    3232        $debug_mode      = get_option(Plugin::SLG . '_debug_mode') == '1';
     33        $inlinecss_off   = get_option(Plugin::SLG . '_inlinecss_off');
    3334        $debug_display   = $debug_mode ? 'flex' : 'none';
    3435
     
    5556                <div id="{slg}-general" class="tab-content" style="display:<?php echo $tab == 'active' ? 'block' : 'none'?>;">
    5657                    <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=' . Plugin::SLG . '_settings_save&' . Plugin::SLG . '_tab=active&active=' . (string)((int)($enabled != true)))); ?>">
     58                        <?php wp_nonce_field(Plugin::SLG . '-wpnonce_active', Plugin::SLG . '-form_nonce_active'); ?>
    5759                        <div class="{slg}-field">
    5860                            <div class="{slg}-field-label">
     
    6062                            </div>
    6163                            <div class="wp-review-field-option">
    62                                 <?php wp_nonce_field(Plugin::SLG . '-wpnonce_active', Plugin::SLG . '-form_nonce_active'); ?>
    6364                                <input type="submit" name="active" class="button" value="<?php echo $enabled ? 'Disable' : 'Enable'; ?>" />
     65                            </div>
     66                        </div>
     67                        <div class="{slg}-field">
     68                            <div class="{slg}-field-label">
     69                                <label>Disable inline CSS</label>
     70                            </div>
     71                            <div class="wp-review-field-option">
     72                                <label>
     73                                    <input type="hidden" name="inlinecss_off" value="false">
     74                                    <input type="checkbox" id="inlinecss_off" name="inlinecss_off" value="true" <?php checked('true', $inlinecss_off); ?>>
     75                                    Do not output the plugin’s inline CSS styles.<br>
     76                                    <b>Do not turn on this</b> to ensure the latest styles and avoid caching issues after updates.
     77                                </label>
     78                                <div style="padding-top:15px">
     79                                    <input type="submit" value="Save" name="save" class="button" />
     80                                </div>
    6481                            </div>
    6582                        </div>
  • fb-reviews-widget/trunk/includes/class-plugin.php

    r3440691 r3451653  
    1818final class Plugin {
    1919
    20     const VER = '2.7.2';
     20    const VER = '2.7.3';
    2121    const SLG = 'trustreviews';
    2222    const PFX = self::SLG . '_';
  • fb-reviews-widget/trunk/includes/class-settings-save.php

    r3439940 r3451653  
    4545
    4646        if (isset($_POST['save'])) {
    47             $fields = array('demand_assets', 'minified_assets', 'google_api_key', 'yelp_api_key');
     47            $fields = array('demand_assets', 'minified_assets', 'inlinecss_off', 'google_api_key', 'yelp_api_key');
    4848            foreach ($fields as $field) {
    4949
  • fb-reviews-widget/trunk/includes/class-view.php

    r3440691 r3451653  
    66
    77    private $view_svg;
    8 
    9     private static $public_main_css_cache = null;
    108
    119    public function __construct(View_Svg $view_svg) {
    1210        $this->view_svg = $view_svg;
    13     }
    14 
    15     private function get_public_main_css_inline() {
    16         if (self::$public_main_css_cache !== null) {
    17             return self::$public_main_css_cache;
    18         }
    19 
    20         $css_file = dirname(TRUSTREVIEWS_PLUGIN_FILE) . '/assets/css/public-main' . (is_rtl() ? '-rtl' : '') . '.css';
    21 
    22         if (!is_readable($css_file)) {
    23             self::$public_main_css_cache = '';
    24             return self::$public_main_css_cache;
    25         }
    26 
    27         $css = file_get_contents($css_file);
    28         $css = str_replace('</style', '<\/style', (string) $css);
    29         self::$public_main_css_cache = $css;
    30         return self::$public_main_css_cache;
    3111    }
    3212
     
    6646            }
    6747            $this->view_svg->render();
    68             if (get_option(Plugin::SLG . '_debug_mode') !== '1') {
    69                 $css_inline = $this->get_public_main_css_inline();
    70                 if (!empty($css_inline)) {
    71                     ?><span class="{slg}-hide" style="display:none"><style><?php echo $css_inline; ?>.{slg}-hide{display:none!important}</style></span><?php
    72                 }
    73             }
    7448        ?></div><?php
    7549        return preg_replace('/{slg}/', Plugin::SLG, preg_replace('/[\n\r]|(>)\s+(<)/', '$1$2', ob_get_clean()));
  • fb-reviews-widget/trunk/readme.txt

    r3440691 r3451653  
    55Requires at least: 4.7
    66Tested up to: 6.9
    7 Stable tag: 2.7.2
     7Stable tag: 2.7.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    190190== Changelog ==
    191191
     192= 2.7.3 =
     193* Improved asset loading by adding version to file path URLs
     194* Added option to disable inline CSS
     195* Fixed incorrect inline CSS output
     196* Fixed star icon conflicts
     197
    192198= 2.7.2 =
    193199* Fixed Google rating and star icons
Note: See TracChangeset for help on using the changeset viewer.