Plugin Directory

Changeset 3461887


Ignore:
Timestamp:
02/15/2026 03:10:20 PM (4 days ago)
Author:
hcabrera
Message:

WPP version 7.3.7

Location:
wordpress-popular-posts
Files:
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wordpress-popular-posts/tags/7.3.7/assets/css/wpp.css

    r3377714 r3461887  
    5151        }
    5252
    53         .wpp-excerpt:empty {
    54             display: none;
    55         }
    56 
    5753        /* Stats tag styles */
    5854        .wpp-meta, .post-stats {
    5955            display: block;
    6056            font-size: 0.8em;
    61         }
    62 
    63         .wpp-meta:empty, .post-stats:empty {
    64             display: none;
    6557        }
    6658
  • wordpress-popular-posts/tags/7.3.7/assets/js/chart.js

    r2751127 r3461887  
    1 var WPPChart = (function() {
    2     "use strict";
     1const WPPChart = (() => {
     2    'use strict';
    33
    44    /**
     
    66     */
    77
    8     var defaults = {
     8    let chart = null,
     9        element = null,
     10        cvs = null;
     11
     12    const defaults = {
    913        type: 'line',
    1014        data: {
     
    1216            datasets: [
    1317                {
    14                     label: "",
     18                    label: '',
    1519                    fill: true,
    1620                    lineTension: 0.2,
    1721                    borderWidth: 3,
    18                     backgroundColor: "rgba(221, 66, 66, 0.8)",
    19                     borderColor: "#881111",
     22                    backgroundColor: 'rgba(221, 66, 66, 0.8)',
     23                    borderColor: '#881111',
    2024                    borderCapStyle: 'butt',
    2125                    borderDash: [],
    2226                    borderDashOffset: 0.0,
    2327                    borderJoinStyle: 'miter',
    24                     pointBorderColor: "#881111",
    25                     pointBackgroundColor: "#fff",
     28                    pointBorderColor: '#881111',
     29                    pointBackgroundColor: '#fff',
    2630                    pointBorderWidth: 2,
    2731                    pointHoverRadius: 4,
    28                     pointHoverBackgroundColor: "#881111",
    29                     pointHoverBorderColor: "#881111",
     32                    pointHoverBackgroundColor: '#881111',
     33                    pointHoverBorderColor: '#881111',
    3034                    pointHoverBorderWidth: 3,
    3135                    pointRadius: 3,
     
    3438                },
    3539                {
    36                     label: "",
     40                    label: '',
    3741                    fill: true,
    3842                    lineTension: 0.2,
    3943                    borderWidth: 3,
    40                     backgroundColor: "rgba(136, 17, 17, 0.3)",
    41                     borderColor: "#a80000",
     44                    backgroundColor: 'rgba(136, 17, 17, 0.3)',
     45                    borderColor: '#a80000',
    4246                    borderCapStyle: 'butt',
    4347                    borderDash: [],
    4448                    borderDashOffset: 0.0,
    4549                    borderJoinStyle: 'miter',
    46                     pointBorderColor: "#a80000",
    47                     pointBackgroundColor: "#fff",
     50                    pointBorderColor: '#a80000',
     51                    pointBackgroundColor: '#fff',
    4852                    pointBorderWidth: 2,
    4953                    pointHoverRadius: 4,
    50                     pointHoverBackgroundColor: "#a80000",
    51                     pointHoverBorderColor: "#a80000",
     54                    pointHoverBackgroundColor: '#a80000',
     55                    pointHoverBorderColor: '#a80000',
    5256                    pointHoverBorderWidth: 3,
    5357                    pointRadius: 3,
     
    9296                    }
    9397                },
    94                   y: {
     98                y: {
    9599                    grid: {
    96100                        display: false,
     
    102106                }
    103107            }
    104         }
     108        },
    105109    },
    106     chart = null,
    107     canRender = !! window.CanvasRenderingContext2D,
    108     element = null,
    109     cvs = null;
    110 
    111     var canRender = function(){
    112         return canRender;
    113     };
     110    canRender = !! window.CanvasRenderingContext2D;
    114111
    115112    // Source: http://stackoverflow.com/a/5624139
    116     var HexToRGB = function( hex ){
    117         var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
    118 
    119         hex = hex.replace(shorthandRegex, function( m, r, g, b ) {
     113    const HexToRGB = ( hex ) => {
     114        const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
     115
     116        hex = hex.replace(shorthandRegex, ( _m, r, g, b ) => {
    120117            return r + r + g + g + b + b;
    121118        });
    122119
    123         var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
     120        const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    124121
    125122        return result ? {
     
    134131     */
    135132
    136     var init = function(container, options){
    137         if ( ! canRender() ) {
     133    const init = (container) => {
     134        if ( ! canRender ) {
    138135            throw new Error('Your browser is too old, WPPChart cannot create its data chart.');
    139136        }
     
    157154    };
    158155
    159     var populate = function(data){
     156    const populate = (data) => {
    160157        if ( chart ) {
    161158            chart.destroy();
    162159        }
    163160
    164         var config = defaults;
     161        const totalComments = data.datasets[0].data.reduce(
     162            (accumulator, currentValue) => accumulator + parseInt(currentValue, 10),
     163            0,
     164        );
     165
     166        const totalViews = data.datasets[1].data.reduce(
     167            (accumulator, currentValue) => accumulator + parseInt(currentValue, 10),
     168            0,
     169        );
     170
     171        const display_y_scale = !! parseInt(element.dataset.yScale, 10);
     172
     173        const config = defaults;
     174
     175        if ( display_y_scale ) {
     176            config.options.scales.y.grid.display = ! ( totalComments <= 0 && totalViews <= 0 );
     177            config.options.scales.y.ticks.display = ! ( totalComments <= 0 && totalViews <= 0 );
     178        }
    165179
    166180        config.data.labels = data.labels;
     
    170184        config.data.datasets[1].data = data.datasets[1].data;
    171185
    172         var colors_arr = wpp_chart_params.colors.slice(-2);
    173 
    174         var rgb_comments = HexToRGB(colors_arr[0]);
    175         config.data.datasets[1].backgroundColor = "rgba(" + rgb_comments.r + ", " + rgb_comments.g + ", " + rgb_comments.b + ", 0.9)";
     186        const colors_arr = wpp_chart_params.colors.slice(-2);
     187
     188        const rgb_comments = HexToRGB(colors_arr[0]);
     189        config.data.datasets[1].backgroundColor = `rgba(${rgb_comments.r}, ${rgb_comments.g}, ${rgb_comments.b}, 0.9)`;
    176190        config.data.datasets[1].borderColor = colors_arr[0];
    177191        config.data.datasets[1].pointBorderColor = colors_arr[0];
     
    179193        config.data.datasets[1].pointHoverBorderColor = colors_arr[0];
    180194
    181         var rgb_views = HexToRGB(colors_arr[1]);
    182         config.data.datasets[0].backgroundColor = "rgba(" + rgb_views.r + ", " + rgb_views.g + ", " + rgb_views.b + ",  0.7)";
     195        const rgb_views = HexToRGB(colors_arr[1]);
     196        config.data.datasets[0].backgroundColor = `rgba(${rgb_views.r}, ${rgb_views.g}, ${rgb_views.b},  0.7)`;
    183197        config.data.datasets[0].borderColor = colors_arr[1];
    184198        config.data.datasets[0].pointBorderColor = colors_arr[1];
     
    194208
    195209    return {
    196         init: init,
    197         populate: populate,
    198         canRender: canRender
     210        init,
     211        populate,
     212        canRender: () => canRender
    199213    };
    200214})();
  • wordpress-popular-posts/tags/7.3.7/i18n/wordpress-popular-posts.pot

    r3383614 r3461887  
    66"Project-Id-Version: WP Popular Posts\n"
    77"Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-popular-posts\n"
    8 "POT-Creation-Date: 2025-10-23 14:50-0400\n"
     8"POT-Creation-Date: 2026-02-15 10:23-0400\n"
    99"PO-Revision-Date: 2015-04-24 13:30-0430\n"
    1010"Last-Translator: Héctor Cabrera <[email protected]>\n"
     
    7777msgstr ""
    7878
    79 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:85
     79#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:91
    8080#: src/Block/Widget/edit.js:200
    8181#: src/Compatibility/Elementor/widgets/widget-controls.php:58
     
    8383msgstr ""
    8484
    85 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:88
     85#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:94
    8686#: src/Block/Widget/edit.js:201
    8787#: src/Compatibility/Elementor/widgets/widget-controls.php:59
     
    9494msgstr ""
    9595
    96 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:91
     96#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:97
    9797#: src/Block/Widget/edit.js:203
    9898#: src/Compatibility/Elementor/widgets/widget-controls.php:61
     
    110110msgstr ""
    111111
    112 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:51
     112#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:57
    113113#: src/Admin/screen-tools.php:185 src/Block/Widget/edit.js:220
    114114#: src/Compatibility/Elementor/widgets/widget-controls.php:88
     
    116116msgstr ""
    117117
    118 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:52
     118#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:58
    119119#: src/Admin/screen-tools.php:186 src/Block/Widget/edit.js:221
    120120#: src/Compatibility/Elementor/widgets/widget-controls.php:89
     
    122122msgstr ""
    123123
    124 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:53
     124#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:59
    125125#: src/Admin/screen-tools.php:187 src/Block/Widget/edit.js:222
    126126#: src/Compatibility/Elementor/widgets/widget-controls.php:90
     
    380380msgstr[1] ""
    381381
    382 #: src/Admin/Admin.php:295 src/Admin/screen-stats.php:104
     382#: src/Admin/Admin.php:295 src/Admin/screen-stats.php:110
    383383msgid "Trending now"
    384384msgstr ""
     
    458458
    459459#: src/Admin/Admin.php:629 src/Admin/Admin.php:1035 src/Admin/Admin.php:1039
    460 #: src/Output.php:895 src/Shortcode/ViewsCount.php:79
     460#: src/Output.php:958 src/Shortcode/ViewsCount.php:79
    461461#, php-format
    462462msgid "%s view"
     
    466466
    467467#: src/Admin/Admin.php:629 src/Admin/Admin.php:1037 src/Admin/Admin.php:1039
    468 #: src/Output.php:878
     468#: src/Output.php:941
    469469#, php-format
    470470msgid "%s comment"
     
    514514msgstr ""
    515515
    516 #: src/Admin/admin-page.php:7 src/Admin/admin-page.php:122
     516#: src/Admin/admin-page.php:7 src/Admin/admin-page.php:123
    517517msgid "Stats"
    518518msgstr ""
    519519
    520 #: src/Admin/admin-page.php:8 src/Admin/admin-page.php:123
     520#: src/Admin/admin-page.php:8 src/Admin/admin-page.php:124
    521521msgid "Tools"
    522522msgstr ""
     
    526526msgstr ""
    527527
    528 #: src/Admin/admin-page.php:32 src/Admin/admin-page.php:44 src/Admin/admin-page.php:80
    529 #: src/Admin/admin-page.php:112
     528#: src/Admin/admin-page.php:33 src/Admin/admin-page.php:45 src/Admin/admin-page.php:81
     529#: src/Admin/admin-page.php:113
    530530msgid "Settings saved."
    531531msgstr ""
    532532
    533 #: src/Admin/admin-page.php:60
     533#: src/Admin/admin-page.php:61
    534534msgid "Please provide the name of your custom field."
    535535msgstr ""
     
    547547msgstr ""
    548548
    549 #: src/Admin/screen-stats.php:32 src/Admin/screen-stats.php:65
     549#: src/Admin/screen-stats.php:31
     550msgid "Display Y scale"
     551msgstr ""
     552
     553#: src/Admin/screen-stats.php:38 src/Admin/screen-stats.php:71
    550554#: src/Admin/screen-tools.php:111 src/Admin/screen-tools.php:226
    551555#: src/Admin/screen-tools.php:273
     
    553557msgstr ""
    554558
    555 #: src/Admin/screen-stats.php:33 src/Admin/screen-stats.php:68
     559#: src/Admin/screen-stats.php:39 src/Admin/screen-stats.php:74
    556560msgid "Cancel"
    557561msgstr ""
    558562
    559 #: src/Admin/screen-stats.php:40
     563#: src/Admin/screen-stats.php:46
    560564msgid "Custom Time Range Settings"
    561565msgstr ""
    562566
    563 #: src/Admin/screen-stats.php:43
     567#: src/Admin/screen-stats.php:49
    564568msgid "Custom Time Range"
    565569msgstr ""
    566570
    567 #: src/Admin/screen-stats.php:44
     571#: src/Admin/screen-stats.php:50
    568572msgid "Date Range"
    569573msgstr ""
    570574
    571 #: src/Admin/screen-stats.php:58
     575#: src/Admin/screen-stats.php:64
    572576msgid "Select a date..."
    573577msgstr ""
    574578
    575 #: src/Admin/screen-stats.php:79
     579#: src/Admin/screen-stats.php:85
    576580msgid "Today"
    577581msgstr ""
    578582
    579 #: src/Admin/screen-stats.php:82
     583#: src/Admin/screen-stats.php:88
    580584msgid "Last 24 hours"
    581585msgstr ""
    582586
    583 #: src/Admin/screen-stats.php:96
     587#: src/Admin/screen-stats.php:102
    584588#, php-format
    585589msgid ""
     
    589593msgstr ""
    590594
    591 #: src/Admin/screen-stats.php:102
     595#: src/Admin/screen-stats.php:108
    592596msgid "See your most viewed posts within the selected time range"
    593597msgstr ""
    594598
    595 #: src/Admin/screen-stats.php:102
     599#: src/Admin/screen-stats.php:108
    596600msgid "Most viewed"
    597601msgstr ""
    598602
    599 #: src/Admin/screen-stats.php:103
     603#: src/Admin/screen-stats.php:109
    600604msgid "See your most commented posts within the selected time range"
    601605msgstr ""
    602606
    603 #: src/Admin/screen-stats.php:103
     607#: src/Admin/screen-stats.php:109
    604608msgid "Most commented"
    605609msgstr ""
    606610
    607 #: src/Admin/screen-stats.php:104
     611#: src/Admin/screen-stats.php:110
    608612msgid "See your most viewed posts within the last hour"
    609613msgstr ""
    610614
    611 #: src/Admin/screen-stats.php:105
     615#: src/Admin/screen-stats.php:111
    612616msgid "See your most viewed posts of all time"
    613617msgstr ""
    614618
    615 #: src/Admin/screen-stats.php:105
     619#: src/Admin/screen-stats.php:111
    616620msgid "Hall of Fame"
    617621msgstr ""
     
    876880msgstr ""
    877881
    878 #: src/Output.php:276
     882#: src/Output.php:319
    879883msgid "Sorry. No data so far."
    880884msgstr ""
    881885
    882 #: src/Output.php:706
     886#: src/Output.php:759
    883887#, php-format
    884888msgid "%s ago"
    885889msgstr ""
    886890
    887 #: src/Output.php:889
     891#: src/Output.php:952
    888892#, php-format
    889893msgid "%s view per day"
     
    892896msgstr[1] ""
    893897
    894 #: src/Output.php:907
     898#: src/Output.php:970
    895899#, php-format
    896900msgid "by %s"
    897901msgstr ""
    898902
    899 #: src/Output.php:912
     903#: src/Output.php:975
    900904#, php-format
    901905msgid "posted %s"
    902906msgstr ""
    903907
    904 #: src/Output.php:912
     908#: src/Output.php:975
    905909#, php-format
    906910msgid "posted on %s"
    907911msgstr ""
    908912
    909 #: src/Output.php:917
     913#: src/Output.php:980
    910914#, php-format
    911915msgid "under %s"
  • wordpress-popular-posts/tags/7.3.7/readme.txt

    r3413514 r3461887  
    44Tags: popular, posts, widget, popularity, top
    55Requires at least: 6.2
    6 Tested up to: 6.9
     6Tested up to: 6.9.1
    77Requires PHP: 7.4
    8 Stable tag: 7.3.6
     8Stable tag: 7.3.7
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515
    1616WP Popular Posts is a highly customizable plugin that displays your most popular posts.
     17
     18= PSA: Plugin has been renamed as WP Popular Posts! =
     19
     20See the [announcement](https://cabrerahector.com/wordpress/wordpress-popular-posts-renamed-to-wp-popular-posts/) for more details.
    1721
    1822= Main Features =
     
    113117== Changelog ==
    114118
     119= 7.3.7 =
     120
     121- Fixes shortcode rendering empty tags (props to NetzzJD for the report!)
     122- Renames filter hook pretiffy_numbers to prettify_numbers.
     123- Adds toggle to display the Y-axis in the Stats chart.
     124- Minor code improvements.
     125
     126[Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-7-3-experimental-elementor-support/#7.3.7)
     127
     128= 7.3.6 =
     129
    115130**If you're updating from a previous version please clear your popular posts thumbnails cache via WP Dashboard > Settings > WP Popular Posts > Tools > Thumbnails > Empty image cache button.**
    116 
    117 = 7.3.6 =
    118131
    119132- Improves security around thumbnail generation (props to smile9381!)
  • wordpress-popular-posts/tags/7.3.7/src/Admin/admin-page.php

    r3383614 r3461887  
    2828            $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? 'post' : sanitize_text_field($_POST['stats_type']);
    2929            $this->config['stats']['freshness'] = isset($_POST['stats_freshness']);
     30            $this->config['stats']['y_scale'] = isset($_POST['stats_y_scale']);
    3031
    3132            update_option('wpp_settings_config', $this->config);
  • wordpress-popular-posts/tags/7.3.7/src/Admin/screen-stats.php

    r3264124 r3461887  
    2424                <label for="stats_freshness">
    2525                    <input type="checkbox" class="checkbox" <?php echo ($this->config['stats']['freshness']) ? 'checked="checked"' : ''; ?> id="stats_freshness" name="stats_freshness"> <small><?php esc_html_e('Display only posts published within the selected Time Range', 'wordpress-popular-posts'); ?></small>
     26                </label>
     27
     28                <div class="clear"></div>
     29
     30                <label for="stats_y_scale">
     31                    <input type="checkbox" class="checkbox" <?php echo ($this->config['stats']['y_scale']) ? 'checked="checked"' : ''; ?> id="stats_y_scale" name="stats_y_scale"> <small><?php esc_html_e('Display Y scale', 'wordpress-popular-posts'); ?></small>
    2632                </label>
    2733
     
    9399        </ul>
    94100
    95         <div id="wpp-chart">
     101        <div id="wpp-chart" data-y-scale="<?php echo absint($this->config['stats']['y_scale']); ?>">
    96102            <p><?php echo sprintf( __('Err... A nice little chart is supposed to be here, instead you are seeing this because your browser is too old. <br /> Please <a href="%s" target="_blank">get a better browser</a>.', 'wordpress-popular-posts'), 'https://browsehappy.com/'); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
    97103        </div>
  • wordpress-popular-posts/tags/7.3.7/src/Output.php

    r3377030 r3461887  
    154154    public function get_output()
    155155    {
     156        $this->output = $this->get_clean_output();
    156157        $this->output = ( WP_DEBUG ? "\n" . '<!-- WP Popular Posts v' . WPP_VERSION . ( $this->admin_options['tools']['cache']['active'] ? ' - cached' : '' ) . ' -->' . "\n" : '' ) . $this->output;
    157 
    158         // Attempt to close open tags
    159         $this->output = force_balance_tags($this->output);
    160 
    161         /**
    162          * @ToDo
    163          *
    164          * Look into \Dom\HTMLDocument (PHP 8.4 apparently) to see
    165          * if it's a good alternative to the code below.
    166          */
    167 
    168         if ( extension_loaded('mbstring') && function_exists('mb_encode_numericentity') ) {
    169             // Process special characters
    170             $html = htmlspecialchars_decode(mb_encode_numericentity(htmlentities(trim($this->output), ENT_QUOTES, 'UTF-8'), [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
    171 
    172             // Remove empty tags
    173             $clean_html = '';
    174             $html = '<!DOCTYPE html><html><head><meta charset="UTF-8" /></head><body>' . $html . '</body></html>';
    175 
    176             $dom = new \DOMDocument();
    177             $dom->loadHTML($html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
    178             $xpath = new \DOMXPath($dom);
    179 
    180             while ( ($node_list = $xpath->query('//*[not(*) and not(@*) and not(text()[normalize-space()])]')) && $node_list->length ) {
    181                 foreach ($node_list as $node) {
    182                     $node->parentNode->removeChild($node);
     158        return $this->output;
     159    }
     160
     161    /**
     162     * Returns a "clean" version of the HTML output.
     163     *
     164     * @since   7.3.7
     165     * @return  string
     166     */
     167    private function get_clean_output()
     168    {
     169        if ( $this->output ) {
     170            // Attempt to close open tags
     171            $this->output = force_balance_tags($this->output);
     172
     173            /**
     174             * @ToDo
     175             *
     176             * Look into \Dom\HTMLDocument (PHP 8.4 apparently) to see
     177             * if it's a good alternative to the code below.
     178             */
     179
     180            if ( extension_loaded('mbstring') && function_exists('mb_encode_numericentity') ) {
     181                $clean_html = '';
     182                $html = trim($this->output);
     183
     184                // Process special characters
     185                $html = htmlspecialchars_decode(mb_encode_numericentity(htmlentities($html, ENT_QUOTES, 'UTF-8'), [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
     186
     187                // Remove empty tags
     188                $html = '<!DOCTYPE html><html><head><meta charset="UTF-8" /></head><body>' . $html . '</body></html>';
     189
     190                $dom = new \DOMDocument();
     191                $dom->loadHTML($html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     192                $xpath = new \DOMXPath($dom);
     193
     194                // Void/empty tags that should never be removed
     195                $voids = ['br', 'div', 'hr', 'img', 'source', 'span'];
     196                $voidPred = implode(' or ', array_map(function($n) { return "name() = '" . $n . "'"; }, $voids));
     197
     198                // Build XPath predicate
     199                $query = "//*[not(normalize-space()) and not(*) and not({$voidPred})]";
     200
     201                // Iterate until no more removable nodes found (because removing can create new empty tags)
     202                do {
     203                    $removed = false;
     204                    $nodes = $xpath->query($query);
     205
     206                    if ( $nodes === null || $nodes->length === 0 ) {
     207                        break;
     208                    }
     209
     210                    // Collect nodes first to avoid live-node issues
     211                    $toRemove = [];
     212
     213                    foreach( $nodes as $node ) {
     214                        $toRemove[] = $node;
     215                    }
     216
     217                    foreach( $toRemove as $node ) {
     218                        if ($node->parentNode) {
     219                            $node->parentNode->removeChild($node);
     220                            $removed = true;
     221                        }
     222                    }
     223                } while( $removed );
     224
     225                $body = $dom->getElementsByTagName('body')->item(0);
     226
     227                if ( isset($body->childNodes) ) {
     228                    foreach( $body->childNodes as $node ) {
     229                        $clean_html .= $dom->saveHTML($node);
     230                    }
    183231                }
    184             }
    185 
    186             $body = $dom->getElementsByTagName('body')->item(0);
    187 
    188             if ( isset($body->childNodes) ) {
    189                 foreach( $body->childNodes as $node ) {
    190                     $clean_html .= $dom->saveHTML($node);
     232
     233                $this->output = trim($clean_html);
     234            } else {
     235                if ( defined('WP_DEBUG') && WP_DEBUG ) {
     236                    trigger_error('WP Popular Posts - looks like PHP\'s mbstring extension isn\'t enabled on this site. Please enable it for the plugin to be able to properly format your popular post list.', E_USER_WARNING);
    191237                }
    192238            }
    193239
    194             $this->output = trim($clean_html);
    195         } else {
    196             if ( defined('WP_DEBUG') && WP_DEBUG ) {
    197                 trigger_error('WP Popular Posts - looks like PHP\'s mbstring extension isn\'t enabled on this site. Please enable it for the plugin to be able to properly format your popular post list.', E_USER_WARNING);
    198             }
    199         }
    200 
    201         // Sanitize HTML
    202         $this->output = Helper::sanitize_html($this->output, $this->public_options);
     240            // Remove excess line jumps
     241            $this->output = preg_replace('/\R+/', "\n", $this->output);
     242
     243            // Sanitize HTML
     244            $this->output = Helper::sanitize_html($this->output, $this->public_options);
     245        }
    203246
    204247        return $this->output;
     
    433476        $prettify_numbers = apply_filters('wpp_prettify_numbers', true);
    434477
    435         /** Legacy, should be removed */
     478        /**
     479         * @ToDo
     480         *
     481         * Remove this filter, it's a typo and the correct one has been around since 6.3.4
     482         *
     483         * @since  7.3.7
     484         */
    436485        if ( has_filter('wpp_pretiffy_numbers') ) {
    437486            $prettify_numbers = apply_filters('wpp_pretiffy_numbers', true);
     487
     488            if ( defined('WP_DEBUG') && WP_DEBUG ) {
     489                trigger_error('WP Popular Posts - wpp_pretiffy_numbers has been deprecated. Please use wpp_prettify_numbers instead.', E_USER_WARNING);
     490            }
    438491        }
    439492
     
    868921        $prettify_numbers = apply_filters('wpp_prettify_numbers', true);
    869922
    870         /* Legacy, should be removed */
     923        /**
     924         * @ToDo
     925         *
     926         * Remove this filter, it's a typo and the correct one has been around since 6.3.4
     927         *
     928         * @since  7.3.7
     929         */
    871930        if ( has_filter('wpp_pretiffy_numbers') ) {
    872931            $prettify_numbers = apply_filters('wpp_pretiffy_numbers', true);
     932
     933            if ( defined('WP_DEBUG') && WP_DEBUG ) {
     934                trigger_error('WP Popular Posts - wpp_pretiffy_numbers has been deprecated. Please use wpp_prettify_numbers instead..', E_USER_WARNING);
     935            }
    873936        }
    874937
  • wordpress-popular-posts/tags/7.3.7/src/Settings.php

    r3204883 r3461887  
    9797                'limit' => 10,
    9898                'post_type' => 'post',
    99                 'freshness' => false
     99                'freshness' => false,
     100                'y_scale' => false
    100101            ],
    101102            'tools' => [
  • wordpress-popular-posts/tags/7.3.7/wordpress-popular-posts.php

    r3383614 r3461887  
    1717 * Plugin URI:        https://wordpress.org/plugins/wordpress-popular-posts/
    1818 * Description:       A highly customizable plugin that displays your most popular posts.
    19  * Version:           7.3.6
     19 * Version:           7.3.7
    2020 * Requires at least: 6.2
    2121 * Requires PHP:      7.4
     
    3232}
    3333
    34 define('WPP_VERSION', '7.3.6');
     34define('WPP_VERSION', '7.3.7');
    3535
    3636$wpp_main_plugin_file = __FILE__;
  • wordpress-popular-posts/trunk/assets/css/wpp.css

    r3377714 r3461887  
    5151        }
    5252
    53         .wpp-excerpt:empty {
    54             display: none;
    55         }
    56 
    5753        /* Stats tag styles */
    5854        .wpp-meta, .post-stats {
    5955            display: block;
    6056            font-size: 0.8em;
    61         }
    62 
    63         .wpp-meta:empty, .post-stats:empty {
    64             display: none;
    6557        }
    6658
  • wordpress-popular-posts/trunk/assets/js/chart.js

    r2751127 r3461887  
    1 var WPPChart = (function() {
    2     "use strict";
     1const WPPChart = (() => {
     2    'use strict';
    33
    44    /**
     
    66     */
    77
    8     var defaults = {
     8    let chart = null,
     9        element = null,
     10        cvs = null;
     11
     12    const defaults = {
    913        type: 'line',
    1014        data: {
     
    1216            datasets: [
    1317                {
    14                     label: "",
     18                    label: '',
    1519                    fill: true,
    1620                    lineTension: 0.2,
    1721                    borderWidth: 3,
    18                     backgroundColor: "rgba(221, 66, 66, 0.8)",
    19                     borderColor: "#881111",
     22                    backgroundColor: 'rgba(221, 66, 66, 0.8)',
     23                    borderColor: '#881111',
    2024                    borderCapStyle: 'butt',
    2125                    borderDash: [],
    2226                    borderDashOffset: 0.0,
    2327                    borderJoinStyle: 'miter',
    24                     pointBorderColor: "#881111",
    25                     pointBackgroundColor: "#fff",
     28                    pointBorderColor: '#881111',
     29                    pointBackgroundColor: '#fff',
    2630                    pointBorderWidth: 2,
    2731                    pointHoverRadius: 4,
    28                     pointHoverBackgroundColor: "#881111",
    29                     pointHoverBorderColor: "#881111",
     32                    pointHoverBackgroundColor: '#881111',
     33                    pointHoverBorderColor: '#881111',
    3034                    pointHoverBorderWidth: 3,
    3135                    pointRadius: 3,
     
    3438                },
    3539                {
    36                     label: "",
     40                    label: '',
    3741                    fill: true,
    3842                    lineTension: 0.2,
    3943                    borderWidth: 3,
    40                     backgroundColor: "rgba(136, 17, 17, 0.3)",
    41                     borderColor: "#a80000",
     44                    backgroundColor: 'rgba(136, 17, 17, 0.3)',
     45                    borderColor: '#a80000',
    4246                    borderCapStyle: 'butt',
    4347                    borderDash: [],
    4448                    borderDashOffset: 0.0,
    4549                    borderJoinStyle: 'miter',
    46                     pointBorderColor: "#a80000",
    47                     pointBackgroundColor: "#fff",
     50                    pointBorderColor: '#a80000',
     51                    pointBackgroundColor: '#fff',
    4852                    pointBorderWidth: 2,
    4953                    pointHoverRadius: 4,
    50                     pointHoverBackgroundColor: "#a80000",
    51                     pointHoverBorderColor: "#a80000",
     54                    pointHoverBackgroundColor: '#a80000',
     55                    pointHoverBorderColor: '#a80000',
    5256                    pointHoverBorderWidth: 3,
    5357                    pointRadius: 3,
     
    9296                    }
    9397                },
    94                   y: {
     98                y: {
    9599                    grid: {
    96100                        display: false,
     
    102106                }
    103107            }
    104         }
     108        },
    105109    },
    106     chart = null,
    107     canRender = !! window.CanvasRenderingContext2D,
    108     element = null,
    109     cvs = null;
    110 
    111     var canRender = function(){
    112         return canRender;
    113     };
     110    canRender = !! window.CanvasRenderingContext2D;
    114111
    115112    // Source: http://stackoverflow.com/a/5624139
    116     var HexToRGB = function( hex ){
    117         var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
    118 
    119         hex = hex.replace(shorthandRegex, function( m, r, g, b ) {
     113    const HexToRGB = ( hex ) => {
     114        const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
     115
     116        hex = hex.replace(shorthandRegex, ( _m, r, g, b ) => {
    120117            return r + r + g + g + b + b;
    121118        });
    122119
    123         var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
     120        const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    124121
    125122        return result ? {
     
    134131     */
    135132
    136     var init = function(container, options){
    137         if ( ! canRender() ) {
     133    const init = (container) => {
     134        if ( ! canRender ) {
    138135            throw new Error('Your browser is too old, WPPChart cannot create its data chart.');
    139136        }
     
    157154    };
    158155
    159     var populate = function(data){
     156    const populate = (data) => {
    160157        if ( chart ) {
    161158            chart.destroy();
    162159        }
    163160
    164         var config = defaults;
     161        const totalComments = data.datasets[0].data.reduce(
     162            (accumulator, currentValue) => accumulator + parseInt(currentValue, 10),
     163            0,
     164        );
     165
     166        const totalViews = data.datasets[1].data.reduce(
     167            (accumulator, currentValue) => accumulator + parseInt(currentValue, 10),
     168            0,
     169        );
     170
     171        const display_y_scale = !! parseInt(element.dataset.yScale, 10);
     172
     173        const config = defaults;
     174
     175        if ( display_y_scale ) {
     176            config.options.scales.y.grid.display = ! ( totalComments <= 0 && totalViews <= 0 );
     177            config.options.scales.y.ticks.display = ! ( totalComments <= 0 && totalViews <= 0 );
     178        }
    165179
    166180        config.data.labels = data.labels;
     
    170184        config.data.datasets[1].data = data.datasets[1].data;
    171185
    172         var colors_arr = wpp_chart_params.colors.slice(-2);
    173 
    174         var rgb_comments = HexToRGB(colors_arr[0]);
    175         config.data.datasets[1].backgroundColor = "rgba(" + rgb_comments.r + ", " + rgb_comments.g + ", " + rgb_comments.b + ", 0.9)";
     186        const colors_arr = wpp_chart_params.colors.slice(-2);
     187
     188        const rgb_comments = HexToRGB(colors_arr[0]);
     189        config.data.datasets[1].backgroundColor = `rgba(${rgb_comments.r}, ${rgb_comments.g}, ${rgb_comments.b}, 0.9)`;
    176190        config.data.datasets[1].borderColor = colors_arr[0];
    177191        config.data.datasets[1].pointBorderColor = colors_arr[0];
     
    179193        config.data.datasets[1].pointHoverBorderColor = colors_arr[0];
    180194
    181         var rgb_views = HexToRGB(colors_arr[1]);
    182         config.data.datasets[0].backgroundColor = "rgba(" + rgb_views.r + ", " + rgb_views.g + ", " + rgb_views.b + ",  0.7)";
     195        const rgb_views = HexToRGB(colors_arr[1]);
     196        config.data.datasets[0].backgroundColor = `rgba(${rgb_views.r}, ${rgb_views.g}, ${rgb_views.b},  0.7)`;
    183197        config.data.datasets[0].borderColor = colors_arr[1];
    184198        config.data.datasets[0].pointBorderColor = colors_arr[1];
     
    194208
    195209    return {
    196         init: init,
    197         populate: populate,
    198         canRender: canRender
     210        init,
     211        populate,
     212        canRender: () => canRender
    199213    };
    200214})();
  • wordpress-popular-posts/trunk/i18n/wordpress-popular-posts.pot

    r3383614 r3461887  
    66"Project-Id-Version: WP Popular Posts\n"
    77"Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-popular-posts\n"
    8 "POT-Creation-Date: 2025-10-23 14:50-0400\n"
     8"POT-Creation-Date: 2026-02-15 10:23-0400\n"
    99"PO-Revision-Date: 2015-04-24 13:30-0430\n"
    1010"Last-Translator: Héctor Cabrera <[email protected]>\n"
     
    7777msgstr ""
    7878
    79 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:85
     79#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:91
    8080#: src/Block/Widget/edit.js:200
    8181#: src/Compatibility/Elementor/widgets/widget-controls.php:58
     
    8383msgstr ""
    8484
    85 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:88
     85#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:94
    8686#: src/Block/Widget/edit.js:201
    8787#: src/Compatibility/Elementor/widgets/widget-controls.php:59
     
    9494msgstr ""
    9595
    96 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:91
     96#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:97
    9797#: src/Block/Widget/edit.js:203
    9898#: src/Compatibility/Elementor/widgets/widget-controls.php:61
     
    110110msgstr ""
    111111
    112 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:51
     112#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:57
    113113#: src/Admin/screen-tools.php:185 src/Block/Widget/edit.js:220
    114114#: src/Compatibility/Elementor/widgets/widget-controls.php:88
     
    116116msgstr ""
    117117
    118 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:52
     118#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:58
    119119#: src/Admin/screen-tools.php:186 src/Block/Widget/edit.js:221
    120120#: src/Compatibility/Elementor/widgets/widget-controls.php:89
     
    122122msgstr ""
    123123
    124 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:53
     124#: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:59
    125125#: src/Admin/screen-tools.php:187 src/Block/Widget/edit.js:222
    126126#: src/Compatibility/Elementor/widgets/widget-controls.php:90
     
    380380msgstr[1] ""
    381381
    382 #: src/Admin/Admin.php:295 src/Admin/screen-stats.php:104
     382#: src/Admin/Admin.php:295 src/Admin/screen-stats.php:110
    383383msgid "Trending now"
    384384msgstr ""
     
    458458
    459459#: src/Admin/Admin.php:629 src/Admin/Admin.php:1035 src/Admin/Admin.php:1039
    460 #: src/Output.php:895 src/Shortcode/ViewsCount.php:79
     460#: src/Output.php:958 src/Shortcode/ViewsCount.php:79
    461461#, php-format
    462462msgid "%s view"
     
    466466
    467467#: src/Admin/Admin.php:629 src/Admin/Admin.php:1037 src/Admin/Admin.php:1039
    468 #: src/Output.php:878
     468#: src/Output.php:941
    469469#, php-format
    470470msgid "%s comment"
     
    514514msgstr ""
    515515
    516 #: src/Admin/admin-page.php:7 src/Admin/admin-page.php:122
     516#: src/Admin/admin-page.php:7 src/Admin/admin-page.php:123
    517517msgid "Stats"
    518518msgstr ""
    519519
    520 #: src/Admin/admin-page.php:8 src/Admin/admin-page.php:123
     520#: src/Admin/admin-page.php:8 src/Admin/admin-page.php:124
    521521msgid "Tools"
    522522msgstr ""
     
    526526msgstr ""
    527527
    528 #: src/Admin/admin-page.php:32 src/Admin/admin-page.php:44 src/Admin/admin-page.php:80
    529 #: src/Admin/admin-page.php:112
     528#: src/Admin/admin-page.php:33 src/Admin/admin-page.php:45 src/Admin/admin-page.php:81
     529#: src/Admin/admin-page.php:113
    530530msgid "Settings saved."
    531531msgstr ""
    532532
    533 #: src/Admin/admin-page.php:60
     533#: src/Admin/admin-page.php:61
    534534msgid "Please provide the name of your custom field."
    535535msgstr ""
     
    547547msgstr ""
    548548
    549 #: src/Admin/screen-stats.php:32 src/Admin/screen-stats.php:65
     549#: src/Admin/screen-stats.php:31
     550msgid "Display Y scale"
     551msgstr ""
     552
     553#: src/Admin/screen-stats.php:38 src/Admin/screen-stats.php:71
    550554#: src/Admin/screen-tools.php:111 src/Admin/screen-tools.php:226
    551555#: src/Admin/screen-tools.php:273
     
    553557msgstr ""
    554558
    555 #: src/Admin/screen-stats.php:33 src/Admin/screen-stats.php:68
     559#: src/Admin/screen-stats.php:39 src/Admin/screen-stats.php:74
    556560msgid "Cancel"
    557561msgstr ""
    558562
    559 #: src/Admin/screen-stats.php:40
     563#: src/Admin/screen-stats.php:46
    560564msgid "Custom Time Range Settings"
    561565msgstr ""
    562566
    563 #: src/Admin/screen-stats.php:43
     567#: src/Admin/screen-stats.php:49
    564568msgid "Custom Time Range"
    565569msgstr ""
    566570
    567 #: src/Admin/screen-stats.php:44
     571#: src/Admin/screen-stats.php:50
    568572msgid "Date Range"
    569573msgstr ""
    570574
    571 #: src/Admin/screen-stats.php:58
     575#: src/Admin/screen-stats.php:64
    572576msgid "Select a date..."
    573577msgstr ""
    574578
    575 #: src/Admin/screen-stats.php:79
     579#: src/Admin/screen-stats.php:85
    576580msgid "Today"
    577581msgstr ""
    578582
    579 #: src/Admin/screen-stats.php:82
     583#: src/Admin/screen-stats.php:88
    580584msgid "Last 24 hours"
    581585msgstr ""
    582586
    583 #: src/Admin/screen-stats.php:96
     587#: src/Admin/screen-stats.php:102
    584588#, php-format
    585589msgid ""
     
    589593msgstr ""
    590594
    591 #: src/Admin/screen-stats.php:102
     595#: src/Admin/screen-stats.php:108
    592596msgid "See your most viewed posts within the selected time range"
    593597msgstr ""
    594598
    595 #: src/Admin/screen-stats.php:102
     599#: src/Admin/screen-stats.php:108
    596600msgid "Most viewed"
    597601msgstr ""
    598602
    599 #: src/Admin/screen-stats.php:103
     603#: src/Admin/screen-stats.php:109
    600604msgid "See your most commented posts within the selected time range"
    601605msgstr ""
    602606
    603 #: src/Admin/screen-stats.php:103
     607#: src/Admin/screen-stats.php:109
    604608msgid "Most commented"
    605609msgstr ""
    606610
    607 #: src/Admin/screen-stats.php:104
     611#: src/Admin/screen-stats.php:110
    608612msgid "See your most viewed posts within the last hour"
    609613msgstr ""
    610614
    611 #: src/Admin/screen-stats.php:105
     615#: src/Admin/screen-stats.php:111
    612616msgid "See your most viewed posts of all time"
    613617msgstr ""
    614618
    615 #: src/Admin/screen-stats.php:105
     619#: src/Admin/screen-stats.php:111
    616620msgid "Hall of Fame"
    617621msgstr ""
     
    876880msgstr ""
    877881
    878 #: src/Output.php:276
     882#: src/Output.php:319
    879883msgid "Sorry. No data so far."
    880884msgstr ""
    881885
    882 #: src/Output.php:706
     886#: src/Output.php:759
    883887#, php-format
    884888msgid "%s ago"
    885889msgstr ""
    886890
    887 #: src/Output.php:889
     891#: src/Output.php:952
    888892#, php-format
    889893msgid "%s view per day"
     
    892896msgstr[1] ""
    893897
    894 #: src/Output.php:907
     898#: src/Output.php:970
    895899#, php-format
    896900msgid "by %s"
    897901msgstr ""
    898902
    899 #: src/Output.php:912
     903#: src/Output.php:975
    900904#, php-format
    901905msgid "posted %s"
    902906msgstr ""
    903907
    904 #: src/Output.php:912
     908#: src/Output.php:975
    905909#, php-format
    906910msgid "posted on %s"
    907911msgstr ""
    908912
    909 #: src/Output.php:917
     913#: src/Output.php:980
    910914#, php-format
    911915msgid "under %s"
  • wordpress-popular-posts/trunk/readme.txt

    r3413514 r3461887  
    44Tags: popular, posts, widget, popularity, top
    55Requires at least: 6.2
    6 Tested up to: 6.9
     6Tested up to: 6.9.1
    77Requires PHP: 7.4
    8 Stable tag: 7.3.6
     8Stable tag: 7.3.7
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515
    1616WP Popular Posts is a highly customizable plugin that displays your most popular posts.
     17
     18= PSA: Plugin has been renamed as WP Popular Posts! =
     19
     20See the [announcement](https://cabrerahector.com/wordpress/wordpress-popular-posts-renamed-to-wp-popular-posts/) for more details.
    1721
    1822= Main Features =
     
    113117== Changelog ==
    114118
     119= 7.3.7 =
     120
     121- Fixes shortcode rendering empty tags (props to NetzzJD for the report!)
     122- Renames filter hook pretiffy_numbers to prettify_numbers.
     123- Adds toggle to display the Y-axis in the Stats chart.
     124- Minor code improvements.
     125
     126[Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-7-3-experimental-elementor-support/#7.3.7)
     127
     128= 7.3.6 =
     129
    115130**If you're updating from a previous version please clear your popular posts thumbnails cache via WP Dashboard > Settings > WP Popular Posts > Tools > Thumbnails > Empty image cache button.**
    116 
    117 = 7.3.6 =
    118131
    119132- Improves security around thumbnail generation (props to smile9381!)
  • wordpress-popular-posts/trunk/src/Admin/admin-page.php

    r3383614 r3461887  
    2828            $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? 'post' : sanitize_text_field($_POST['stats_type']);
    2929            $this->config['stats']['freshness'] = isset($_POST['stats_freshness']);
     30            $this->config['stats']['y_scale'] = isset($_POST['stats_y_scale']);
    3031
    3132            update_option('wpp_settings_config', $this->config);
  • wordpress-popular-posts/trunk/src/Admin/screen-stats.php

    r3264124 r3461887  
    2424                <label for="stats_freshness">
    2525                    <input type="checkbox" class="checkbox" <?php echo ($this->config['stats']['freshness']) ? 'checked="checked"' : ''; ?> id="stats_freshness" name="stats_freshness"> <small><?php esc_html_e('Display only posts published within the selected Time Range', 'wordpress-popular-posts'); ?></small>
     26                </label>
     27
     28                <div class="clear"></div>
     29
     30                <label for="stats_y_scale">
     31                    <input type="checkbox" class="checkbox" <?php echo ($this->config['stats']['y_scale']) ? 'checked="checked"' : ''; ?> id="stats_y_scale" name="stats_y_scale"> <small><?php esc_html_e('Display Y scale', 'wordpress-popular-posts'); ?></small>
    2632                </label>
    2733
     
    9399        </ul>
    94100
    95         <div id="wpp-chart">
     101        <div id="wpp-chart" data-y-scale="<?php echo absint($this->config['stats']['y_scale']); ?>">
    96102            <p><?php echo sprintf( __('Err... A nice little chart is supposed to be here, instead you are seeing this because your browser is too old. <br /> Please <a href="%s" target="_blank">get a better browser</a>.', 'wordpress-popular-posts'), 'https://browsehappy.com/'); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
    97103        </div>
  • wordpress-popular-posts/trunk/src/Output.php

    r3377030 r3461887  
    154154    public function get_output()
    155155    {
     156        $this->output = $this->get_clean_output();
    156157        $this->output = ( WP_DEBUG ? "\n" . '<!-- WP Popular Posts v' . WPP_VERSION . ( $this->admin_options['tools']['cache']['active'] ? ' - cached' : '' ) . ' -->' . "\n" : '' ) . $this->output;
    157 
    158         // Attempt to close open tags
    159         $this->output = force_balance_tags($this->output);
    160 
    161         /**
    162          * @ToDo
    163          *
    164          * Look into \Dom\HTMLDocument (PHP 8.4 apparently) to see
    165          * if it's a good alternative to the code below.
    166          */
    167 
    168         if ( extension_loaded('mbstring') && function_exists('mb_encode_numericentity') ) {
    169             // Process special characters
    170             $html = htmlspecialchars_decode(mb_encode_numericentity(htmlentities(trim($this->output), ENT_QUOTES, 'UTF-8'), [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
    171 
    172             // Remove empty tags
    173             $clean_html = '';
    174             $html = '<!DOCTYPE html><html><head><meta charset="UTF-8" /></head><body>' . $html . '</body></html>';
    175 
    176             $dom = new \DOMDocument();
    177             $dom->loadHTML($html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
    178             $xpath = new \DOMXPath($dom);
    179 
    180             while ( ($node_list = $xpath->query('//*[not(*) and not(@*) and not(text()[normalize-space()])]')) && $node_list->length ) {
    181                 foreach ($node_list as $node) {
    182                     $node->parentNode->removeChild($node);
     158        return $this->output;
     159    }
     160
     161    /**
     162     * Returns a "clean" version of the HTML output.
     163     *
     164     * @since   7.3.7
     165     * @return  string
     166     */
     167    private function get_clean_output()
     168    {
     169        if ( $this->output ) {
     170            // Attempt to close open tags
     171            $this->output = force_balance_tags($this->output);
     172
     173            /**
     174             * @ToDo
     175             *
     176             * Look into \Dom\HTMLDocument (PHP 8.4 apparently) to see
     177             * if it's a good alternative to the code below.
     178             */
     179
     180            if ( extension_loaded('mbstring') && function_exists('mb_encode_numericentity') ) {
     181                $clean_html = '';
     182                $html = trim($this->output);
     183
     184                // Process special characters
     185                $html = htmlspecialchars_decode(mb_encode_numericentity(htmlentities($html, ENT_QUOTES, 'UTF-8'), [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
     186
     187                // Remove empty tags
     188                $html = '<!DOCTYPE html><html><head><meta charset="UTF-8" /></head><body>' . $html . '</body></html>';
     189
     190                $dom = new \DOMDocument();
     191                $dom->loadHTML($html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     192                $xpath = new \DOMXPath($dom);
     193
     194                // Void/empty tags that should never be removed
     195                $voids = ['br', 'div', 'hr', 'img', 'source', 'span'];
     196                $voidPred = implode(' or ', array_map(function($n) { return "name() = '" . $n . "'"; }, $voids));
     197
     198                // Build XPath predicate
     199                $query = "//*[not(normalize-space()) and not(*) and not({$voidPred})]";
     200
     201                // Iterate until no more removable nodes found (because removing can create new empty tags)
     202                do {
     203                    $removed = false;
     204                    $nodes = $xpath->query($query);
     205
     206                    if ( $nodes === null || $nodes->length === 0 ) {
     207                        break;
     208                    }
     209
     210                    // Collect nodes first to avoid live-node issues
     211                    $toRemove = [];
     212
     213                    foreach( $nodes as $node ) {
     214                        $toRemove[] = $node;
     215                    }
     216
     217                    foreach( $toRemove as $node ) {
     218                        if ($node->parentNode) {
     219                            $node->parentNode->removeChild($node);
     220                            $removed = true;
     221                        }
     222                    }
     223                } while( $removed );
     224
     225                $body = $dom->getElementsByTagName('body')->item(0);
     226
     227                if ( isset($body->childNodes) ) {
     228                    foreach( $body->childNodes as $node ) {
     229                        $clean_html .= $dom->saveHTML($node);
     230                    }
    183231                }
    184             }
    185 
    186             $body = $dom->getElementsByTagName('body')->item(0);
    187 
    188             if ( isset($body->childNodes) ) {
    189                 foreach( $body->childNodes as $node ) {
    190                     $clean_html .= $dom->saveHTML($node);
     232
     233                $this->output = trim($clean_html);
     234            } else {
     235                if ( defined('WP_DEBUG') && WP_DEBUG ) {
     236                    trigger_error('WP Popular Posts - looks like PHP\'s mbstring extension isn\'t enabled on this site. Please enable it for the plugin to be able to properly format your popular post list.', E_USER_WARNING);
    191237                }
    192238            }
    193239
    194             $this->output = trim($clean_html);
    195         } else {
    196             if ( defined('WP_DEBUG') && WP_DEBUG ) {
    197                 trigger_error('WP Popular Posts - looks like PHP\'s mbstring extension isn\'t enabled on this site. Please enable it for the plugin to be able to properly format your popular post list.', E_USER_WARNING);
    198             }
    199         }
    200 
    201         // Sanitize HTML
    202         $this->output = Helper::sanitize_html($this->output, $this->public_options);
     240            // Remove excess line jumps
     241            $this->output = preg_replace('/\R+/', "\n", $this->output);
     242
     243            // Sanitize HTML
     244            $this->output = Helper::sanitize_html($this->output, $this->public_options);
     245        }
    203246
    204247        return $this->output;
     
    433476        $prettify_numbers = apply_filters('wpp_prettify_numbers', true);
    434477
    435         /** Legacy, should be removed */
     478        /**
     479         * @ToDo
     480         *
     481         * Remove this filter, it's a typo and the correct one has been around since 6.3.4
     482         *
     483         * @since  7.3.7
     484         */
    436485        if ( has_filter('wpp_pretiffy_numbers') ) {
    437486            $prettify_numbers = apply_filters('wpp_pretiffy_numbers', true);
     487
     488            if ( defined('WP_DEBUG') && WP_DEBUG ) {
     489                trigger_error('WP Popular Posts - wpp_pretiffy_numbers has been deprecated. Please use wpp_prettify_numbers instead.', E_USER_WARNING);
     490            }
    438491        }
    439492
     
    868921        $prettify_numbers = apply_filters('wpp_prettify_numbers', true);
    869922
    870         /* Legacy, should be removed */
     923        /**
     924         * @ToDo
     925         *
     926         * Remove this filter, it's a typo and the correct one has been around since 6.3.4
     927         *
     928         * @since  7.3.7
     929         */
    871930        if ( has_filter('wpp_pretiffy_numbers') ) {
    872931            $prettify_numbers = apply_filters('wpp_pretiffy_numbers', true);
     932
     933            if ( defined('WP_DEBUG') && WP_DEBUG ) {
     934                trigger_error('WP Popular Posts - wpp_pretiffy_numbers has been deprecated. Please use wpp_prettify_numbers instead..', E_USER_WARNING);
     935            }
    873936        }
    874937
  • wordpress-popular-posts/trunk/src/Settings.php

    r3204883 r3461887  
    9797                'limit' => 10,
    9898                'post_type' => 'post',
    99                 'freshness' => false
     99                'freshness' => false,
     100                'y_scale' => false
    100101            ],
    101102            'tools' => [
  • wordpress-popular-posts/trunk/wordpress-popular-posts.php

    r3383614 r3461887  
    1717 * Plugin URI:        https://wordpress.org/plugins/wordpress-popular-posts/
    1818 * Description:       A highly customizable plugin that displays your most popular posts.
    19  * Version:           7.3.6
     19 * Version:           7.3.7
    2020 * Requires at least: 6.2
    2121 * Requires PHP:      7.4
     
    3232}
    3333
    34 define('WPP_VERSION', '7.3.6');
     34define('WPP_VERSION', '7.3.7');
    3535
    3636$wpp_main_plugin_file = __FILE__;
Note: See TracChangeset for help on using the changeset viewer.