Changeset 3461887
- Timestamp:
- 02/15/2026 03:10:20 PM (4 days ago)
- Location:
- wordpress-popular-posts
- Files:
-
- 18 edited
- 1 copied
-
tags/7.3.7 (copied) (copied from wordpress-popular-posts/trunk)
-
tags/7.3.7/assets/css/wpp.css (modified) (1 diff)
-
tags/7.3.7/assets/js/chart.js (modified) (11 diffs)
-
tags/7.3.7/i18n/wordpress-popular-posts.pot (modified) (17 diffs)
-
tags/7.3.7/readme.txt (modified) (3 diffs)
-
tags/7.3.7/src/Admin/admin-page.php (modified) (1 diff)
-
tags/7.3.7/src/Admin/screen-stats.php (modified) (2 diffs)
-
tags/7.3.7/src/Output.php (modified) (3 diffs)
-
tags/7.3.7/src/Settings.php (modified) (1 diff)
-
tags/7.3.7/wordpress-popular-posts.php (modified) (2 diffs)
-
trunk/assets/css/wpp.css (modified) (1 diff)
-
trunk/assets/js/chart.js (modified) (11 diffs)
-
trunk/i18n/wordpress-popular-posts.pot (modified) (17 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Admin/admin-page.php (modified) (1 diff)
-
trunk/src/Admin/screen-stats.php (modified) (2 diffs)
-
trunk/src/Output.php (modified) (3 diffs)
-
trunk/src/Settings.php (modified) (1 diff)
-
trunk/wordpress-popular-posts.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-popular-posts/tags/7.3.7/assets/css/wpp.css
r3377714 r3461887 51 51 } 52 52 53 .wpp-excerpt:empty {54 display: none;55 }56 57 53 /* Stats tag styles */ 58 54 .wpp-meta, .post-stats { 59 55 display: block; 60 56 font-size: 0.8em; 61 }62 63 .wpp-meta:empty, .post-stats:empty {64 display: none;65 57 } 66 58 -
wordpress-popular-posts/tags/7.3.7/assets/js/chart.js
r2751127 r3461887 1 var WPPChart = (function(){2 "use strict";1 const WPPChart = (() => { 2 'use strict'; 3 3 4 4 /** … … 6 6 */ 7 7 8 var defaults = { 8 let chart = null, 9 element = null, 10 cvs = null; 11 12 const defaults = { 9 13 type: 'line', 10 14 data: { … … 12 16 datasets: [ 13 17 { 14 label: "",18 label: '', 15 19 fill: true, 16 20 lineTension: 0.2, 17 21 borderWidth: 3, 18 backgroundColor: "rgba(221, 66, 66, 0.8)",19 borderColor: "#881111",22 backgroundColor: 'rgba(221, 66, 66, 0.8)', 23 borderColor: '#881111', 20 24 borderCapStyle: 'butt', 21 25 borderDash: [], 22 26 borderDashOffset: 0.0, 23 27 borderJoinStyle: 'miter', 24 pointBorderColor: "#881111",25 pointBackgroundColor: "#fff",28 pointBorderColor: '#881111', 29 pointBackgroundColor: '#fff', 26 30 pointBorderWidth: 2, 27 31 pointHoverRadius: 4, 28 pointHoverBackgroundColor: "#881111",29 pointHoverBorderColor: "#881111",32 pointHoverBackgroundColor: '#881111', 33 pointHoverBorderColor: '#881111', 30 34 pointHoverBorderWidth: 3, 31 35 pointRadius: 3, … … 34 38 }, 35 39 { 36 label: "",40 label: '', 37 41 fill: true, 38 42 lineTension: 0.2, 39 43 borderWidth: 3, 40 backgroundColor: "rgba(136, 17, 17, 0.3)",41 borderColor: "#a80000",44 backgroundColor: 'rgba(136, 17, 17, 0.3)', 45 borderColor: '#a80000', 42 46 borderCapStyle: 'butt', 43 47 borderDash: [], 44 48 borderDashOffset: 0.0, 45 49 borderJoinStyle: 'miter', 46 pointBorderColor: "#a80000",47 pointBackgroundColor: "#fff",50 pointBorderColor: '#a80000', 51 pointBackgroundColor: '#fff', 48 52 pointBorderWidth: 2, 49 53 pointHoverRadius: 4, 50 pointHoverBackgroundColor: "#a80000",51 pointHoverBorderColor: "#a80000",54 pointHoverBackgroundColor: '#a80000', 55 pointHoverBorderColor: '#a80000', 52 56 pointHoverBorderWidth: 3, 53 57 pointRadius: 3, … … 92 96 } 93 97 }, 94 y: {98 y: { 95 99 grid: { 96 100 display: false, … … 102 106 } 103 107 } 104 } 108 }, 105 109 }, 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; 114 111 115 112 // Source: http://stackoverflow.com/a/5624139 116 var HexToRGB = function( hex ){117 varshorthandRegex = /^#?([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 ) => { 120 117 return r + r + g + g + b + b; 121 118 }); 122 119 123 varresult = /^#?([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); 124 121 125 122 return result ? { … … 134 131 */ 135 132 136 var init = function(container, options){137 if ( ! canRender ()) {133 const init = (container) => { 134 if ( ! canRender ) { 138 135 throw new Error('Your browser is too old, WPPChart cannot create its data chart.'); 139 136 } … … 157 154 }; 158 155 159 var populate = function(data){156 const populate = (data) => { 160 157 if ( chart ) { 161 158 chart.destroy(); 162 159 } 163 160 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 } 165 179 166 180 config.data.labels = data.labels; … … 170 184 config.data.datasets[1].data = data.datasets[1].data; 171 185 172 varcolors_arr = wpp_chart_params.colors.slice(-2);173 174 varrgb_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)`; 176 190 config.data.datasets[1].borderColor = colors_arr[0]; 177 191 config.data.datasets[1].pointBorderColor = colors_arr[0]; … … 179 193 config.data.datasets[1].pointHoverBorderColor = colors_arr[0]; 180 194 181 varrgb_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)`; 183 197 config.data.datasets[0].borderColor = colors_arr[1]; 184 198 config.data.datasets[0].pointBorderColor = colors_arr[1]; … … 194 208 195 209 return { 196 init : init,197 populate : populate,198 canRender: canRender210 init, 211 populate, 212 canRender: () => canRender 199 213 }; 200 214 })(); -
wordpress-popular-posts/tags/7.3.7/i18n/wordpress-popular-posts.pot
r3383614 r3461887 6 6 "Project-Id-Version: WP Popular Posts\n" 7 7 "Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-popular-posts\n" 8 "POT-Creation-Date: 202 5-10-23 14:50-0400\n"8 "POT-Creation-Date: 2026-02-15 10:23-0400\n" 9 9 "PO-Revision-Date: 2015-04-24 13:30-0430\n" 10 10 "Last-Translator: Héctor Cabrera <[email protected]>\n" … … 77 77 msgstr "" 78 78 79 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php: 8579 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:91 80 80 #: src/Block/Widget/edit.js:200 81 81 #: src/Compatibility/Elementor/widgets/widget-controls.php:58 … … 83 83 msgstr "" 84 84 85 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php: 8885 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:94 86 86 #: src/Block/Widget/edit.js:201 87 87 #: src/Compatibility/Elementor/widgets/widget-controls.php:59 … … 94 94 msgstr "" 95 95 96 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:9 196 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:97 97 97 #: src/Block/Widget/edit.js:203 98 98 #: src/Compatibility/Elementor/widgets/widget-controls.php:61 … … 110 110 msgstr "" 111 111 112 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:5 1112 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:57 113 113 #: src/Admin/screen-tools.php:185 src/Block/Widget/edit.js:220 114 114 #: src/Compatibility/Elementor/widgets/widget-controls.php:88 … … 116 116 msgstr "" 117 117 118 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:5 2118 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:58 119 119 #: src/Admin/screen-tools.php:186 src/Block/Widget/edit.js:221 120 120 #: src/Compatibility/Elementor/widgets/widget-controls.php:89 … … 122 122 msgstr "" 123 123 124 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:5 3124 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:59 125 125 #: src/Admin/screen-tools.php:187 src/Block/Widget/edit.js:222 126 126 #: src/Compatibility/Elementor/widgets/widget-controls.php:90 … … 380 380 msgstr[1] "" 381 381 382 #: src/Admin/Admin.php:295 src/Admin/screen-stats.php:1 04382 #: src/Admin/Admin.php:295 src/Admin/screen-stats.php:110 383 383 msgid "Trending now" 384 384 msgstr "" … … 458 458 459 459 #: src/Admin/Admin.php:629 src/Admin/Admin.php:1035 src/Admin/Admin.php:1039 460 #: src/Output.php: 895src/Shortcode/ViewsCount.php:79460 #: src/Output.php:958 src/Shortcode/ViewsCount.php:79 461 461 #, php-format 462 462 msgid "%s view" … … 466 466 467 467 #: src/Admin/Admin.php:629 src/Admin/Admin.php:1037 src/Admin/Admin.php:1039 468 #: src/Output.php: 878468 #: src/Output.php:941 469 469 #, php-format 470 470 msgid "%s comment" … … 514 514 msgstr "" 515 515 516 #: src/Admin/admin-page.php:7 src/Admin/admin-page.php:12 2516 #: src/Admin/admin-page.php:7 src/Admin/admin-page.php:123 517 517 msgid "Stats" 518 518 msgstr "" 519 519 520 #: src/Admin/admin-page.php:8 src/Admin/admin-page.php:12 3520 #: src/Admin/admin-page.php:8 src/Admin/admin-page.php:124 521 521 msgid "Tools" 522 522 msgstr "" … … 526 526 msgstr "" 527 527 528 #: src/Admin/admin-page.php:3 2 src/Admin/admin-page.php:44 src/Admin/admin-page.php:80529 #: src/Admin/admin-page.php:11 2528 #: 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 530 530 msgid "Settings saved." 531 531 msgstr "" 532 532 533 #: src/Admin/admin-page.php:6 0533 #: src/Admin/admin-page.php:61 534 534 msgid "Please provide the name of your custom field." 535 535 msgstr "" … … 547 547 msgstr "" 548 548 549 #: src/Admin/screen-stats.php:32 src/Admin/screen-stats.php:65 549 #: src/Admin/screen-stats.php:31 550 msgid "Display Y scale" 551 msgstr "" 552 553 #: src/Admin/screen-stats.php:38 src/Admin/screen-stats.php:71 550 554 #: src/Admin/screen-tools.php:111 src/Admin/screen-tools.php:226 551 555 #: src/Admin/screen-tools.php:273 … … 553 557 msgstr "" 554 558 555 #: src/Admin/screen-stats.php:3 3 src/Admin/screen-stats.php:68559 #: src/Admin/screen-stats.php:39 src/Admin/screen-stats.php:74 556 560 msgid "Cancel" 557 561 msgstr "" 558 562 559 #: src/Admin/screen-stats.php:4 0563 #: src/Admin/screen-stats.php:46 560 564 msgid "Custom Time Range Settings" 561 565 msgstr "" 562 566 563 #: src/Admin/screen-stats.php:4 3567 #: src/Admin/screen-stats.php:49 564 568 msgid "Custom Time Range" 565 569 msgstr "" 566 570 567 #: src/Admin/screen-stats.php: 44571 #: src/Admin/screen-stats.php:50 568 572 msgid "Date Range" 569 573 msgstr "" 570 574 571 #: src/Admin/screen-stats.php: 58575 #: src/Admin/screen-stats.php:64 572 576 msgid "Select a date..." 573 577 msgstr "" 574 578 575 #: src/Admin/screen-stats.php: 79579 #: src/Admin/screen-stats.php:85 576 580 msgid "Today" 577 581 msgstr "" 578 582 579 #: src/Admin/screen-stats.php:8 2583 #: src/Admin/screen-stats.php:88 580 584 msgid "Last 24 hours" 581 585 msgstr "" 582 586 583 #: src/Admin/screen-stats.php: 96587 #: src/Admin/screen-stats.php:102 584 588 #, php-format 585 589 msgid "" … … 589 593 msgstr "" 590 594 591 #: src/Admin/screen-stats.php:10 2595 #: src/Admin/screen-stats.php:108 592 596 msgid "See your most viewed posts within the selected time range" 593 597 msgstr "" 594 598 595 #: src/Admin/screen-stats.php:10 2599 #: src/Admin/screen-stats.php:108 596 600 msgid "Most viewed" 597 601 msgstr "" 598 602 599 #: src/Admin/screen-stats.php:10 3603 #: src/Admin/screen-stats.php:109 600 604 msgid "See your most commented posts within the selected time range" 601 605 msgstr "" 602 606 603 #: src/Admin/screen-stats.php:10 3607 #: src/Admin/screen-stats.php:109 604 608 msgid "Most commented" 605 609 msgstr "" 606 610 607 #: src/Admin/screen-stats.php:1 04611 #: src/Admin/screen-stats.php:110 608 612 msgid "See your most viewed posts within the last hour" 609 613 msgstr "" 610 614 611 #: src/Admin/screen-stats.php:1 05615 #: src/Admin/screen-stats.php:111 612 616 msgid "See your most viewed posts of all time" 613 617 msgstr "" 614 618 615 #: src/Admin/screen-stats.php:1 05619 #: src/Admin/screen-stats.php:111 616 620 msgid "Hall of Fame" 617 621 msgstr "" … … 876 880 msgstr "" 877 881 878 #: src/Output.php: 276882 #: src/Output.php:319 879 883 msgid "Sorry. No data so far." 880 884 msgstr "" 881 885 882 #: src/Output.php:7 06886 #: src/Output.php:759 883 887 #, php-format 884 888 msgid "%s ago" 885 889 msgstr "" 886 890 887 #: src/Output.php: 889891 #: src/Output.php:952 888 892 #, php-format 889 893 msgid "%s view per day" … … 892 896 msgstr[1] "" 893 897 894 #: src/Output.php:9 07898 #: src/Output.php:970 895 899 #, php-format 896 900 msgid "by %s" 897 901 msgstr "" 898 902 899 #: src/Output.php:9 12903 #: src/Output.php:975 900 904 #, php-format 901 905 msgid "posted %s" 902 906 msgstr "" 903 907 904 #: src/Output.php:9 12908 #: src/Output.php:975 905 909 #, php-format 906 910 msgid "posted on %s" 907 911 msgstr "" 908 912 909 #: src/Output.php:9 17913 #: src/Output.php:980 910 914 #, php-format 911 915 msgid "under %s" -
wordpress-popular-posts/tags/7.3.7/readme.txt
r3413514 r3461887 4 4 Tags: popular, posts, widget, popularity, top 5 5 Requires at least: 6.2 6 Tested up to: 6.9 6 Tested up to: 6.9.1 7 7 Requires PHP: 7.4 8 Stable tag: 7.3. 68 Stable tag: 7.3.7 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 15 15 16 16 WP 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 20 See the [announcement](https://cabrerahector.com/wordpress/wordpress-popular-posts-renamed-to-wp-popular-posts/) for more details. 17 21 18 22 = Main Features = … … 113 117 == Changelog == 114 118 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 115 130 **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 =118 131 119 132 - Improves security around thumbnail generation (props to smile9381!) -
wordpress-popular-posts/tags/7.3.7/src/Admin/admin-page.php
r3383614 r3461887 28 28 $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? 'post' : sanitize_text_field($_POST['stats_type']); 29 29 $this->config['stats']['freshness'] = isset($_POST['stats_freshness']); 30 $this->config['stats']['y_scale'] = isset($_POST['stats_y_scale']); 30 31 31 32 update_option('wpp_settings_config', $this->config); -
wordpress-popular-posts/tags/7.3.7/src/Admin/screen-stats.php
r3264124 r3461887 24 24 <label for="stats_freshness"> 25 25 <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> 26 32 </label> 27 33 … … 93 99 </ul> 94 100 95 <div id="wpp-chart" >101 <div id="wpp-chart" data-y-scale="<?php echo absint($this->config['stats']['y_scale']); ?>"> 96 102 <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> 97 103 </div> -
wordpress-popular-posts/tags/7.3.7/src/Output.php
r3377030 r3461887 154 154 public function get_output() 155 155 { 156 $this->output = $this->get_clean_output(); 156 157 $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 } 183 231 } 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); 191 237 } 192 238 } 193 239 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 } 203 246 204 247 return $this->output; … … 433 476 $prettify_numbers = apply_filters('wpp_prettify_numbers', true); 434 477 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 */ 436 485 if ( has_filter('wpp_pretiffy_numbers') ) { 437 486 $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 } 438 491 } 439 492 … … 868 921 $prettify_numbers = apply_filters('wpp_prettify_numbers', true); 869 922 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 */ 871 930 if ( has_filter('wpp_pretiffy_numbers') ) { 872 931 $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 } 873 936 } 874 937 -
wordpress-popular-posts/tags/7.3.7/src/Settings.php
r3204883 r3461887 97 97 'limit' => 10, 98 98 'post_type' => 'post', 99 'freshness' => false 99 'freshness' => false, 100 'y_scale' => false 100 101 ], 101 102 'tools' => [ -
wordpress-popular-posts/tags/7.3.7/wordpress-popular-posts.php
r3383614 r3461887 17 17 * Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/ 18 18 * Description: A highly customizable plugin that displays your most popular posts. 19 * Version: 7.3. 619 * Version: 7.3.7 20 20 * Requires at least: 6.2 21 21 * Requires PHP: 7.4 … … 32 32 } 33 33 34 define('WPP_VERSION', '7.3. 6');34 define('WPP_VERSION', '7.3.7'); 35 35 36 36 $wpp_main_plugin_file = __FILE__; -
wordpress-popular-posts/trunk/assets/css/wpp.css
r3377714 r3461887 51 51 } 52 52 53 .wpp-excerpt:empty {54 display: none;55 }56 57 53 /* Stats tag styles */ 58 54 .wpp-meta, .post-stats { 59 55 display: block; 60 56 font-size: 0.8em; 61 }62 63 .wpp-meta:empty, .post-stats:empty {64 display: none;65 57 } 66 58 -
wordpress-popular-posts/trunk/assets/js/chart.js
r2751127 r3461887 1 var WPPChart = (function(){2 "use strict";1 const WPPChart = (() => { 2 'use strict'; 3 3 4 4 /** … … 6 6 */ 7 7 8 var defaults = { 8 let chart = null, 9 element = null, 10 cvs = null; 11 12 const defaults = { 9 13 type: 'line', 10 14 data: { … … 12 16 datasets: [ 13 17 { 14 label: "",18 label: '', 15 19 fill: true, 16 20 lineTension: 0.2, 17 21 borderWidth: 3, 18 backgroundColor: "rgba(221, 66, 66, 0.8)",19 borderColor: "#881111",22 backgroundColor: 'rgba(221, 66, 66, 0.8)', 23 borderColor: '#881111', 20 24 borderCapStyle: 'butt', 21 25 borderDash: [], 22 26 borderDashOffset: 0.0, 23 27 borderJoinStyle: 'miter', 24 pointBorderColor: "#881111",25 pointBackgroundColor: "#fff",28 pointBorderColor: '#881111', 29 pointBackgroundColor: '#fff', 26 30 pointBorderWidth: 2, 27 31 pointHoverRadius: 4, 28 pointHoverBackgroundColor: "#881111",29 pointHoverBorderColor: "#881111",32 pointHoverBackgroundColor: '#881111', 33 pointHoverBorderColor: '#881111', 30 34 pointHoverBorderWidth: 3, 31 35 pointRadius: 3, … … 34 38 }, 35 39 { 36 label: "",40 label: '', 37 41 fill: true, 38 42 lineTension: 0.2, 39 43 borderWidth: 3, 40 backgroundColor: "rgba(136, 17, 17, 0.3)",41 borderColor: "#a80000",44 backgroundColor: 'rgba(136, 17, 17, 0.3)', 45 borderColor: '#a80000', 42 46 borderCapStyle: 'butt', 43 47 borderDash: [], 44 48 borderDashOffset: 0.0, 45 49 borderJoinStyle: 'miter', 46 pointBorderColor: "#a80000",47 pointBackgroundColor: "#fff",50 pointBorderColor: '#a80000', 51 pointBackgroundColor: '#fff', 48 52 pointBorderWidth: 2, 49 53 pointHoverRadius: 4, 50 pointHoverBackgroundColor: "#a80000",51 pointHoverBorderColor: "#a80000",54 pointHoverBackgroundColor: '#a80000', 55 pointHoverBorderColor: '#a80000', 52 56 pointHoverBorderWidth: 3, 53 57 pointRadius: 3, … … 92 96 } 93 97 }, 94 y: {98 y: { 95 99 grid: { 96 100 display: false, … … 102 106 } 103 107 } 104 } 108 }, 105 109 }, 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; 114 111 115 112 // Source: http://stackoverflow.com/a/5624139 116 var HexToRGB = function( hex ){117 varshorthandRegex = /^#?([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 ) => { 120 117 return r + r + g + g + b + b; 121 118 }); 122 119 123 varresult = /^#?([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); 124 121 125 122 return result ? { … … 134 131 */ 135 132 136 var init = function(container, options){137 if ( ! canRender ()) {133 const init = (container) => { 134 if ( ! canRender ) { 138 135 throw new Error('Your browser is too old, WPPChart cannot create its data chart.'); 139 136 } … … 157 154 }; 158 155 159 var populate = function(data){156 const populate = (data) => { 160 157 if ( chart ) { 161 158 chart.destroy(); 162 159 } 163 160 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 } 165 179 166 180 config.data.labels = data.labels; … … 170 184 config.data.datasets[1].data = data.datasets[1].data; 171 185 172 varcolors_arr = wpp_chart_params.colors.slice(-2);173 174 varrgb_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)`; 176 190 config.data.datasets[1].borderColor = colors_arr[0]; 177 191 config.data.datasets[1].pointBorderColor = colors_arr[0]; … … 179 193 config.data.datasets[1].pointHoverBorderColor = colors_arr[0]; 180 194 181 varrgb_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)`; 183 197 config.data.datasets[0].borderColor = colors_arr[1]; 184 198 config.data.datasets[0].pointBorderColor = colors_arr[1]; … … 194 208 195 209 return { 196 init : init,197 populate : populate,198 canRender: canRender210 init, 211 populate, 212 canRender: () => canRender 199 213 }; 200 214 })(); -
wordpress-popular-posts/trunk/i18n/wordpress-popular-posts.pot
r3383614 r3461887 6 6 "Project-Id-Version: WP Popular Posts\n" 7 7 "Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-popular-posts\n" 8 "POT-Creation-Date: 202 5-10-23 14:50-0400\n"8 "POT-Creation-Date: 2026-02-15 10:23-0400\n" 9 9 "PO-Revision-Date: 2015-04-24 13:30-0430\n" 10 10 "Last-Translator: Héctor Cabrera <[email protected]>\n" … … 77 77 msgstr "" 78 78 79 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php: 8579 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:91 80 80 #: src/Block/Widget/edit.js:200 81 81 #: src/Compatibility/Elementor/widgets/widget-controls.php:58 … … 83 83 msgstr "" 84 84 85 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php: 8885 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:94 86 86 #: src/Block/Widget/edit.js:201 87 87 #: src/Compatibility/Elementor/widgets/widget-controls.php:59 … … 94 94 msgstr "" 95 95 96 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:9 196 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:97 97 97 #: src/Block/Widget/edit.js:203 98 98 #: src/Compatibility/Elementor/widgets/widget-controls.php:61 … … 110 110 msgstr "" 111 111 112 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:5 1112 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:57 113 113 #: src/Admin/screen-tools.php:185 src/Block/Widget/edit.js:220 114 114 #: src/Compatibility/Elementor/widgets/widget-controls.php:88 … … 116 116 msgstr "" 117 117 118 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:5 2118 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:58 119 119 #: src/Admin/screen-tools.php:186 src/Block/Widget/edit.js:221 120 120 #: src/Compatibility/Elementor/widgets/widget-controls.php:89 … … 122 122 msgstr "" 123 123 124 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:5 3124 #: assets/js/blocks/block-wpp-widget.js:1 src/Admin/screen-stats.php:59 125 125 #: src/Admin/screen-tools.php:187 src/Block/Widget/edit.js:222 126 126 #: src/Compatibility/Elementor/widgets/widget-controls.php:90 … … 380 380 msgstr[1] "" 381 381 382 #: src/Admin/Admin.php:295 src/Admin/screen-stats.php:1 04382 #: src/Admin/Admin.php:295 src/Admin/screen-stats.php:110 383 383 msgid "Trending now" 384 384 msgstr "" … … 458 458 459 459 #: src/Admin/Admin.php:629 src/Admin/Admin.php:1035 src/Admin/Admin.php:1039 460 #: src/Output.php: 895src/Shortcode/ViewsCount.php:79460 #: src/Output.php:958 src/Shortcode/ViewsCount.php:79 461 461 #, php-format 462 462 msgid "%s view" … … 466 466 467 467 #: src/Admin/Admin.php:629 src/Admin/Admin.php:1037 src/Admin/Admin.php:1039 468 #: src/Output.php: 878468 #: src/Output.php:941 469 469 #, php-format 470 470 msgid "%s comment" … … 514 514 msgstr "" 515 515 516 #: src/Admin/admin-page.php:7 src/Admin/admin-page.php:12 2516 #: src/Admin/admin-page.php:7 src/Admin/admin-page.php:123 517 517 msgid "Stats" 518 518 msgstr "" 519 519 520 #: src/Admin/admin-page.php:8 src/Admin/admin-page.php:12 3520 #: src/Admin/admin-page.php:8 src/Admin/admin-page.php:124 521 521 msgid "Tools" 522 522 msgstr "" … … 526 526 msgstr "" 527 527 528 #: src/Admin/admin-page.php:3 2 src/Admin/admin-page.php:44 src/Admin/admin-page.php:80529 #: src/Admin/admin-page.php:11 2528 #: 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 530 530 msgid "Settings saved." 531 531 msgstr "" 532 532 533 #: src/Admin/admin-page.php:6 0533 #: src/Admin/admin-page.php:61 534 534 msgid "Please provide the name of your custom field." 535 535 msgstr "" … … 547 547 msgstr "" 548 548 549 #: src/Admin/screen-stats.php:32 src/Admin/screen-stats.php:65 549 #: src/Admin/screen-stats.php:31 550 msgid "Display Y scale" 551 msgstr "" 552 553 #: src/Admin/screen-stats.php:38 src/Admin/screen-stats.php:71 550 554 #: src/Admin/screen-tools.php:111 src/Admin/screen-tools.php:226 551 555 #: src/Admin/screen-tools.php:273 … … 553 557 msgstr "" 554 558 555 #: src/Admin/screen-stats.php:3 3 src/Admin/screen-stats.php:68559 #: src/Admin/screen-stats.php:39 src/Admin/screen-stats.php:74 556 560 msgid "Cancel" 557 561 msgstr "" 558 562 559 #: src/Admin/screen-stats.php:4 0563 #: src/Admin/screen-stats.php:46 560 564 msgid "Custom Time Range Settings" 561 565 msgstr "" 562 566 563 #: src/Admin/screen-stats.php:4 3567 #: src/Admin/screen-stats.php:49 564 568 msgid "Custom Time Range" 565 569 msgstr "" 566 570 567 #: src/Admin/screen-stats.php: 44571 #: src/Admin/screen-stats.php:50 568 572 msgid "Date Range" 569 573 msgstr "" 570 574 571 #: src/Admin/screen-stats.php: 58575 #: src/Admin/screen-stats.php:64 572 576 msgid "Select a date..." 573 577 msgstr "" 574 578 575 #: src/Admin/screen-stats.php: 79579 #: src/Admin/screen-stats.php:85 576 580 msgid "Today" 577 581 msgstr "" 578 582 579 #: src/Admin/screen-stats.php:8 2583 #: src/Admin/screen-stats.php:88 580 584 msgid "Last 24 hours" 581 585 msgstr "" 582 586 583 #: src/Admin/screen-stats.php: 96587 #: src/Admin/screen-stats.php:102 584 588 #, php-format 585 589 msgid "" … … 589 593 msgstr "" 590 594 591 #: src/Admin/screen-stats.php:10 2595 #: src/Admin/screen-stats.php:108 592 596 msgid "See your most viewed posts within the selected time range" 593 597 msgstr "" 594 598 595 #: src/Admin/screen-stats.php:10 2599 #: src/Admin/screen-stats.php:108 596 600 msgid "Most viewed" 597 601 msgstr "" 598 602 599 #: src/Admin/screen-stats.php:10 3603 #: src/Admin/screen-stats.php:109 600 604 msgid "See your most commented posts within the selected time range" 601 605 msgstr "" 602 606 603 #: src/Admin/screen-stats.php:10 3607 #: src/Admin/screen-stats.php:109 604 608 msgid "Most commented" 605 609 msgstr "" 606 610 607 #: src/Admin/screen-stats.php:1 04611 #: src/Admin/screen-stats.php:110 608 612 msgid "See your most viewed posts within the last hour" 609 613 msgstr "" 610 614 611 #: src/Admin/screen-stats.php:1 05615 #: src/Admin/screen-stats.php:111 612 616 msgid "See your most viewed posts of all time" 613 617 msgstr "" 614 618 615 #: src/Admin/screen-stats.php:1 05619 #: src/Admin/screen-stats.php:111 616 620 msgid "Hall of Fame" 617 621 msgstr "" … … 876 880 msgstr "" 877 881 878 #: src/Output.php: 276882 #: src/Output.php:319 879 883 msgid "Sorry. No data so far." 880 884 msgstr "" 881 885 882 #: src/Output.php:7 06886 #: src/Output.php:759 883 887 #, php-format 884 888 msgid "%s ago" 885 889 msgstr "" 886 890 887 #: src/Output.php: 889891 #: src/Output.php:952 888 892 #, php-format 889 893 msgid "%s view per day" … … 892 896 msgstr[1] "" 893 897 894 #: src/Output.php:9 07898 #: src/Output.php:970 895 899 #, php-format 896 900 msgid "by %s" 897 901 msgstr "" 898 902 899 #: src/Output.php:9 12903 #: src/Output.php:975 900 904 #, php-format 901 905 msgid "posted %s" 902 906 msgstr "" 903 907 904 #: src/Output.php:9 12908 #: src/Output.php:975 905 909 #, php-format 906 910 msgid "posted on %s" 907 911 msgstr "" 908 912 909 #: src/Output.php:9 17913 #: src/Output.php:980 910 914 #, php-format 911 915 msgid "under %s" -
wordpress-popular-posts/trunk/readme.txt
r3413514 r3461887 4 4 Tags: popular, posts, widget, popularity, top 5 5 Requires at least: 6.2 6 Tested up to: 6.9 6 Tested up to: 6.9.1 7 7 Requires PHP: 7.4 8 Stable tag: 7.3. 68 Stable tag: 7.3.7 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 15 15 16 16 WP 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 20 See the [announcement](https://cabrerahector.com/wordpress/wordpress-popular-posts-renamed-to-wp-popular-posts/) for more details. 17 21 18 22 = Main Features = … … 113 117 == Changelog == 114 118 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 115 130 **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 =118 131 119 132 - Improves security around thumbnail generation (props to smile9381!) -
wordpress-popular-posts/trunk/src/Admin/admin-page.php
r3383614 r3461887 28 28 $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? 'post' : sanitize_text_field($_POST['stats_type']); 29 29 $this->config['stats']['freshness'] = isset($_POST['stats_freshness']); 30 $this->config['stats']['y_scale'] = isset($_POST['stats_y_scale']); 30 31 31 32 update_option('wpp_settings_config', $this->config); -
wordpress-popular-posts/trunk/src/Admin/screen-stats.php
r3264124 r3461887 24 24 <label for="stats_freshness"> 25 25 <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> 26 32 </label> 27 33 … … 93 99 </ul> 94 100 95 <div id="wpp-chart" >101 <div id="wpp-chart" data-y-scale="<?php echo absint($this->config['stats']['y_scale']); ?>"> 96 102 <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> 97 103 </div> -
wordpress-popular-posts/trunk/src/Output.php
r3377030 r3461887 154 154 public function get_output() 155 155 { 156 $this->output = $this->get_clean_output(); 156 157 $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 } 183 231 } 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); 191 237 } 192 238 } 193 239 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 } 203 246 204 247 return $this->output; … … 433 476 $prettify_numbers = apply_filters('wpp_prettify_numbers', true); 434 477 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 */ 436 485 if ( has_filter('wpp_pretiffy_numbers') ) { 437 486 $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 } 438 491 } 439 492 … … 868 921 $prettify_numbers = apply_filters('wpp_prettify_numbers', true); 869 922 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 */ 871 930 if ( has_filter('wpp_pretiffy_numbers') ) { 872 931 $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 } 873 936 } 874 937 -
wordpress-popular-posts/trunk/src/Settings.php
r3204883 r3461887 97 97 'limit' => 10, 98 98 'post_type' => 'post', 99 'freshness' => false 99 'freshness' => false, 100 'y_scale' => false 100 101 ], 101 102 'tools' => [ -
wordpress-popular-posts/trunk/wordpress-popular-posts.php
r3383614 r3461887 17 17 * Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/ 18 18 * Description: A highly customizable plugin that displays your most popular posts. 19 * Version: 7.3. 619 * Version: 7.3.7 20 20 * Requires at least: 6.2 21 21 * Requires PHP: 7.4 … … 32 32 } 33 33 34 define('WPP_VERSION', '7.3. 6');34 define('WPP_VERSION', '7.3.7'); 35 35 36 36 $wpp_main_plugin_file = __FILE__;
Note: See TracChangeset
for help on using the changeset viewer.