Changeset 3478985
- Timestamp:
- 03/10/2026 10:59:17 AM (3 weeks ago)
- Location:
- post-views-counter/trunk
- Files:
-
- 1 deleted
- 11 edited
-
includes/class-admin.php (modified) (1 diff)
-
includes/class-columns-modal.php (modified) (3 diffs)
-
includes/class-columns.php (modified) (3 diffs)
-
includes/class-counter.php (modified) (8 diffs)
-
includes/class-frontend.php (modified) (2 diffs)
-
includes/class-settings-general.php (modified) (3 diffs)
-
includes/class-toolbar.php (modified) (2 diffs)
-
includes/class-traffic-signals.php (modified) (2 diffs)
-
js/admin-settings.js (modified) (1 diff)
-
js/dummy.js (deleted)
-
post-views-counter.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-views-counter/trunk/includes/class-admin.php
r3429711 r3478985 99 99 100 100 // get countable post types 101 $post_types = $pvc->options['general']['post_types_count'];101 $post_types = (array) $pvc->options['general']['post_types_count']; 102 102 103 103 // check if post exists -
post-views-counter/trunk/includes/class-columns-modal.php
r3452736 r3478985 38 38 $screen = get_current_screen(); 39 39 $pvc = Post_Views_Counter(); 40 $post_types = (array) $pvc->options['general']['post_types_count']; 40 41 41 42 // break if display is not allowed 42 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $screen->post_type, $p vc->options['general']['post_types_count'], true ) )43 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $screen->post_type, $post_types, true ) ) 43 44 return; 44 45 … … 92 93 // get PVC instance 93 94 $pvc = Post_Views_Counter(); 95 $post_types = (array) $pvc->options['general']['post_types_count']; 94 96 95 97 // get post ID … … 110 112 111 113 // ensure post type is tracked 112 if ( ! in_array( $post->post_type, $p vc->options['general']['post_types_count'], true ) )114 if ( ! in_array( $post->post_type, $post_types, true ) ) 113 115 wp_send_json_error( [ 'message' => __( 'Post type is not tracked.', 'post-views-counter' ) ] ); 114 116 -
post-views-counter/trunk/includes/class-columns.php
r3453103 r3478985 39 39 // get main instance 40 40 $pvc = Post_Views_Counter(); 41 $post_types = (array) $pvc->options['general']['post_types_count']; 41 42 42 43 // break if display is not allowed 43 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $post->post_type, $p vc->options['general']['post_types_count']) )44 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $post->post_type, $post_types, true ) ) 44 45 return; 45 46 … … 210 211 // get main instance 211 212 $pvc = Post_Views_Counter(); 213 $post_types = (array) $pvc->options['general']['post_types_count']; 212 214 213 215 // break if display is disabled 214 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $post_type, $p vc->options['general']['post_types_count']) )216 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $post_type, $post_types, true ) ) 215 217 return $columns; 216 218 … … 327 329 // get main instance 328 330 $pvc = Post_Views_Counter(); 331 $post_types = (array) $pvc->options['general']['post_types_count']; 329 332 330 333 // break if display is not allowed 331 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $post_type, $p vc->options['general']['post_types_count']) )334 if ( ! $pvc->options['display']['post_views_column'] || ! in_array( $post_type, $post_types, true ) ) 332 335 return; 333 336 -
post-views-counter/trunk/includes/class-counter.php
r3470602 r3478985 271 271 272 272 // whether to count this ip 273 if ( ! empty( $ips ) && filter_var( preg_replace( '/[^0-9a-fA-F:., ]/', '', $user_ip ), FILTER_VALIDATE_IP) ) {273 if ( ! empty( $ips ) && $this->validate_user_ip( $user_ip ) ) { 274 274 // check ips 275 275 foreach ( $ips as $ip ) { 276 if ( strpos( $ip, '*' ) !== false ) { 277 if ( $this->ipv4_in_range( $user_ip, $ip ) ) 278 return false; 279 } else { 280 if ( $user_ip === $ip ) 281 return false; 282 } 276 if ( $this->is_excluded_ip( $user_ip, $ip ) ) 277 return false; 283 278 } 284 279 } 285 280 286 281 // get groups to check them faster 287 $groups = $pvc->options['general']['exclude']['groups'];282 $groups = isset( $pvc->options['general']['exclude']['groups'] ) && is_array( $pvc->options['general']['exclude']['groups'] ) ? $pvc->options['general']['exclude']['groups'] : []; 288 283 289 284 // whether to count this user … … 1225 1220 */ 1226 1221 public function is_user_role_excluded( $user_id, $option = [] ) { 1222 $option = is_array( $option ) ? $option : []; 1223 1227 1224 // get user by ID 1228 1225 $user = get_user_by( 'id', $user_id ); … … 1263 1260 1264 1261 /** 1262 * Normalize an IP address for consistent comparisons. 1263 * 1264 * @param string $ip 1265 * 1266 * @return string 1267 */ 1268 public function normalize_ip( $ip ) { 1269 $ip = $this->sanitize_ip( trim( $ip ) ); 1270 1271 if ( $ip === '' || filter_var( $ip, FILTER_VALIDATE_IP ) === false ) 1272 return ''; 1273 1274 if ( function_exists( 'inet_pton' ) && function_exists( 'inet_ntop' ) ) { 1275 $packed_ip = inet_pton( $ip ); 1276 1277 if ( $packed_ip !== false ) { 1278 $normalized_ip = inet_ntop( $packed_ip ); 1279 1280 if ( is_string( $normalized_ip ) ) 1281 $ip = $normalized_ip; 1282 } 1283 } 1284 1285 return strtolower( $ip ); 1286 } 1287 1288 /** 1289 * Validate and normalize an IP exclusion rule. 1290 * 1291 * Exact IPv4 and IPv6 addresses are supported. Wildcards remain IPv4-only. 1292 * 1293 * @param string $ip 1294 * 1295 * @return string 1296 */ 1297 public function validate_excluded_ip( $ip ) { 1298 $ip = $this->sanitize_ip( trim( $ip ) ); 1299 1300 if ( $ip === '' ) 1301 return ''; 1302 1303 if ( strpos( $ip, '*' ) !== false ) { 1304 $wildcard_ip = str_replace( '*', '0', $ip ); 1305 1306 if ( filter_var( $wildcard_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) !== false ) 1307 return $ip; 1308 1309 return ''; 1310 } 1311 1312 return $this->normalize_ip( $ip ); 1313 } 1314 1315 /** 1316 * Check whether a visitor IP matches an exclusion rule. 1317 * 1318 * @param string $user_ip 1319 * @param string $excluded_ip 1320 * 1321 * @return bool 1322 */ 1323 public function is_excluded_ip( $user_ip, $excluded_ip ) { 1324 $user_ip = $this->normalize_ip( $user_ip ); 1325 $excluded_ip = $this->validate_excluded_ip( $excluded_ip ); 1326 1327 if ( $user_ip === '' || $excluded_ip === '' ) 1328 return false; 1329 1330 if ( strpos( $excluded_ip, '*' ) !== false ) { 1331 if ( filter_var( $user_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) === false ) 1332 return false; 1333 1334 return $this->ipv4_in_range( $user_ip, $excluded_ip ); 1335 } 1336 1337 if ( function_exists( 'inet_pton' ) ) { 1338 $user_ip_binary = inet_pton( $user_ip ); 1339 $excluded_ip_binary = inet_pton( $excluded_ip ); 1340 1341 if ( $user_ip_binary !== false && $excluded_ip_binary !== false ) 1342 return hash_equals( $excluded_ip_binary, $user_ip_binary ); 1343 } 1344 1345 return ( $user_ip === strtolower( $excluded_ip ) ); 1346 } 1347 1348 /** 1265 1349 * Get user real IP address. 1266 1350 * … … 1283 1367 if ( $strategy === 'remote_addr' ) { 1284 1368 if ( $this->validate_user_ip( $remote_addr ) ) 1285 return $ remote_addr;1369 return $this->normalize_ip( $remote_addr ); 1286 1370 1287 1371 return ''; … … 1313 1397 // Validate the IP 1314 1398 if ( $this->validate_user_ip( $header_ip ) ) 1315 return $ header_ip;1399 return $this->normalize_ip( $header_ip ); 1316 1400 } 1317 1401 } … … 1320 1404 // Fallback to REMOTE_ADDR if valid 1321 1405 if ( $this->validate_user_ip( $remote_addr ) ) 1322 return $ remote_addr;1406 return $this->normalize_ip( $remote_addr ); 1323 1407 1324 1408 return ''; … … 1379 1463 1380 1464 /** 1381 * Ensure an IP address is both a valid IP and does not fall within a private network range.1465 * Ensure an IP address is public and routable. 1382 1466 * 1383 1467 * @param string $ip … … 1386 1470 */ 1387 1471 public function validate_user_ip( $ip ) { 1388 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) === false ) 1472 $ip = $this->normalize_ip( $ip ); 1473 1474 if ( $ip === '' ) 1475 return false; 1476 1477 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) === false ) 1389 1478 return false; 1390 1479 -
post-views-counter/trunk/includes/class-frontend.php
r3423937 r3478985 140 140 141 141 // get groups to check it faster 142 $groups = $pvc->options['display']['restrict_display']['groups'];142 $groups = isset( $pvc->options['display']['restrict_display']['groups'] ) && is_array( $pvc->options['display']['restrict_display']['groups'] ) ? $pvc->options['display']['restrict_display']['groups'] : []; 143 143 144 144 // whether to display views … … 211 211 212 212 // get countable post types 213 $post_types = $pvc->options['general']['post_types_count'];213 $post_types = (array) $pvc->options['general']['post_types_count']; 214 214 215 215 // whether to count this post type or not -
post-views-counter/trunk/includes/class-settings-general.php
r3443433 r3478985 524 524 // get ip addresses 525 525 $ips = $this->pvc->options['general']['exclude_ips']; 526 $current_ip = ''; 527 528 if ( isset( $this->pvc->counter ) && method_exists( $this->pvc->counter, 'get_user_ip' ) ) 529 $current_ip = $this->pvc->counter->get_user_ip(); 530 531 if ( $current_ip === '' && isset( $_SERVER['REMOTE_ADDR'] ) ) 532 $current_ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); 526 533 527 534 $html = '<div class="pvc-ip-box-group">'; … … 546 553 $html .= ' 547 554 <div class="pvc-field-group pvc-buttons-group"> 548 <input type="button" class="button outline pvc-add-exclude-ip" value="' . esc_attr__( 'Add new', 'post-views-counter' ) . '" /> <input type="button" class="button outline pvc-add-current-ip" value="' . esc_attr__( 'Add my current IP', 'post-views-counter' ) . '" data-rel="' . esc_attr( $ _SERVER['REMOTE_ADDR']) . '" />555 <input type="button" class="button outline pvc-add-exclude-ip" value="' . esc_attr__( 'Add new', 'post-views-counter' ) . '" /> <input type="button" class="button outline pvc-add-current-ip" value="' . esc_attr__( 'Add my current IP', 'post-views-counter' ) . '" data-rel="' . esc_attr( $current_ip ) . '" /> 549 556 </div>'; 550 557 551 $html .= '<p class="description">' . esc_html__( 'Add IP addresses or wildcards (e.g. 192.168.0.*) to exclude them from counting views.', 'post-views-counter' ) . '</p>';558 $html .= '<p class="description">' . esc_html__( 'Add IPv4 or IPv6 addresses to exclude them from counting views. Wildcards are supported for IPv4 only (e.g. 192.168.0.*).', 'post-views-counter' ) . '</p>'; 552 559 553 560 return $html; … … 567 574 568 575 foreach ( $input['exclude_ips'] as $ip ) { 569 if ( strpos( $ip, '*' ) !== false ) {570 $new_ip = str_replace( '*', '0', $ip ); 571 572 if ( filter_var( $new_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) )573 $ips[] = $ip; 574 } elseif ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ))575 $ips[] = $ ip;576 $validated_ip = ''; 577 578 if ( isset( $this->pvc->counter ) && method_exists( $this->pvc->counter, 'validate_excluded_ip' ) ) 579 $validated_ip = $this->pvc->counter->validate_excluded_ip( $ip ); 580 581 if ( $validated_ip !== '' ) 582 $ips[] = $validated_ip; 576 583 } 577 584 -
post-views-counter/trunk/includes/class-toolbar.php
r3402454 r3478985 74 74 75 75 // get countable post types 76 $post_types = $pvc->options['general']['post_types_count'];76 $post_types = (array) $pvc->options['general']['post_types_count']; 77 77 78 78 // break if display is not allowed … … 170 170 171 171 // get countable post types 172 $post_types = $pvc->options['general']['post_types_count'];172 $post_types = (array) $pvc->options['general']['post_types_count']; 173 173 174 174 // break if display is not allowed -
post-views-counter/trunk/includes/class-traffic-signals.php
r3453103 r3478985 235 235 $screen = get_current_screen(); 236 236 $pvc = Post_Views_Counter(); 237 $post_types = (array) $pvc->options['general']['post_types_count']; 237 238 238 239 // check if traffic signals should be displayed … … 241 242 242 243 // check if this post type has view counting enabled 243 if ( ! in_array( $screen->post_type, $p vc->options['general']['post_types_count'], true ) )244 if ( ! in_array( $screen->post_type, $post_types, true ) ) 244 245 return; 245 246 -
post-views-counter/trunk/js/admin-settings.js
r3443281 r3478985 1 1 ;(function($, window, document){ 2 const e=(e,t=0,n=1)=>e>n?n:e<t?t:e,t=(e,t=0,n=Math.pow(10,t))=>Math.round(n*e)/n,n=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?t(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?t(parseInt(e.substring(6,8),16)/255,2):1}),r=e=>{const{h:n,s:r,l:o}=(({h:e,s:n,v:r,a:o})=>{const i=(200-n)*r/100;return{h:t(e),s:t(i>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0),l:t(i/2),a:t(o,2)}})(e);return`hsl(${n}, ${r}%, ${o}%)`},o=({h:e,s:n,v:r,a:o})=>{e=e/360*6,n/=100,r/=100;const i=Math.floor(e),a=r*(1-n),s=r*(1-(e-i)*n),c=r*(1-(1-e+i)*n),u=i%6;return{r:t(255*[r,s,a,a,c,r][u]),g:t(255*[c,r,r,s,a,a][u]),b:t(255*[a,a,c,r,r,s][u]),a:t(o,2)}},i=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},a=({r:e,g:n,b:r,a:o})=>{const a=o<1?i(t(255*o)):"";return"#"+i(e)+i(n)+i(r)+a},s=({r:e,g:n,b:r,a:o})=>{const i=Math.max(e,n,r),a=i-Math.min(e,n,r),s=a?i===e?(n-r)/a:i===n?2+(r-e)/a:4+(e-n)/a:0;return{h:t(60*(s<0?s+6:s)),s:t(i?a/i*100:0),v:t(i/255*100),a:o}},c=(e,t)=>{if(e===t)return!0;for(const n in e)if(e[n]!==t[n])return!1;return!0},u={},l=e=>{let t=u[e];return t||(t=document.createElement("template"),t.innerHTML=e,u[e]=t),t},d=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};let f=!1;const v=e=>"touches"in e,p=(t,n)=>{const r=v(n)?n.touches[0]:n,o=t.el.getBoundingClientRect();d(t.el,"move",t.getMove({x:e((r.pageX-(o.left+window.pageXOffset))/o.width),y:e((r.pageY-(o.top+window.pageYOffset))/o.height)}))};class h{constructor(e,t,n,r){const o=l(`<div role="slider" tabindex="0" part="${t}" ${n}><div part="${t}-pointer"></div></div>`);e.appendChild(o.content.cloneNode(!0));const i=e.querySelector(`[part=${t}]`);i.addEventListener("mousedown",this),i.addEventListener("touchstart",this),i.addEventListener("keydown",this),this.el=i,this.xy=r,this.nodes=[i.firstChild,i]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(f?"touchmove":"mousemove",this),t(f?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(f&&!v(e)||(f||(f=v(e)),0)))(e)||!f&&0!=e.button)return;this.el.focus(),p(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),p(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const n=t.keyCode;n>40||e.xy&&n<37||n<33||(t.preventDefault(),d(e.el,"move",e.getMove({x:39===n?.01:37===n?-.01:34===n?.05:33===n?-.05:35===n?1:36===n?-1:0,y:40===n?.01:38===n?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const n in e)this.nodes[t].style.setProperty(n,e[n])})}}class m extends h{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:r({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${t(e)}`)}getMove(t,n){return{h:n?e(this.h+360*t.x,0,360):360*t.x}}}class g extends h{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:r(e)},{"background-color":r({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${t(e.s)}%, Brightness ${t(e.v)}%`)}getMove(t,n){return{s:n?e(this.hsva.s+100*t.x,0,100):100*t.x,v:n?e(this.hsva.v-100*t.y,0,100):Math.round(100-100*t.y)}}}const b=Symbol("same"),y=Symbol("color"),x=Symbol("hsva"), E=Symbol("update"),w=Symbol("parts"),L=Symbol("css"),A=Symbol("sliders");class S extends HTMLElement{static get observedAttributes(){return["color"]}get[L](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[A](){return[g,m]}get color(){return this[y]}set color(e){if(!this[b](e)){const t=this.colorModel.toHsva(e);this[E](t),this[y]=e}}constructor(){super();const e=l(`<style>${this[L].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[w]=this[A].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,n){const r=this.colorModel.fromAttr(n);this[b](r)||(this.color=r)}handleEvent(e){const t=this[x],n={...t,...e.detail};let r;this[E](n),c(n,t)||this[b](r=this.colorModel.fromHsva(n))||(this[y]=r,d(this,"color-changed",{value:r}))}[b](e){return this.color&&this.colorModel.equal(e,this.color)}[E](e){this[x]=e,this[w].forEach(t=>t.update(e))}}const k={defaultColor:"#000",toHsva:e=>s(n(e)),fromHsva:({h:e,s:t,v:n})=>a(o({h:e,s:t,v:n,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||c(n(e),n(t)),fromAttr:e=>e};class q extends S{get colorModel(){return k}}function _(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return C(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},M(e)}customElements.define("hex-color-picker",class extends q{});var $,I=/^[0-9a-f]{3}([0-9a-f]{3})?$/i,P=function(e){if(!e)return"";var t=e.trim();if(!t)return"";var n=t.startsWith("#")?t.slice(1):t;return I.test(n)?"#".concat(n.toLowerCase()):""};function O(){var e=document.querySelector("[data-settings-prefix]"),t=e?e.dataset.settingsPrefix:"";if(t){var n=".".concat(t,"-hex-color-picker"),r=".".concat(t,"-field-type-color"),o=".".concat(t,"-color-input"),i=".".concat(t,"-color-swatch"),a=".".concat(t,"-color-popover"),s=".".concat(t,"-color-control"),c="".concat(t,"ColorInitialized");document.querySelectorAll(r).forEach(function(e){if("true"!==e.dataset[c]){var t=e.querySelector(o),r=e.querySelector(i),u=e.querySelector(a),l=e.querySelector(n),d=e.querySelector(s);if(t&&r&&u&&l&&d){l.addEventListener("mousedown",function(e){return e.stopPropagation()}),e.dataset[c]="true";var f=P(t.value)||"#000000",v=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.setInput,i=void 0===o||o,a=n.dispatch,s=void 0===a||a,c=n.setPicker,u=void 0===c||c,d=P(e);return!!d&&(f=d,i&&(t.value=d),r.style.backgroundColor=d,u&&l.color!==d&&(l.color=d),s&&t.dispatchEvent(new Event("input",{bubbles:!0})),!0)},p=function(){e.classList.contains("is-open")||(e.classList.add("is-open"),u.removeAttribute("aria-hidden"),r.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",m,!0),document.addEventListener("keydown",g))},h=function(){e.classList.contains("is-open")&&(e.classList.remove("is-open"),u.setAttribute("aria-hidden","true"),r.setAttribute("aria-expanded","false"),document.removeEventListener("mousedown",m,!0),document.removeEventListener("keydown",g))},m=function(e){var t="function"==typeof e.composedPath?e.composedPath():[];d.contains(e.target)||t.includes(d)||t.includes(u)||t.includes(l)||h()},g=function(e){"Escape"===e.key&&h()};v(f,{setInput:!0,dispatch:!1}),r.addEventListener("click",function(t){t.preventDefault(),e.classList.contains("is-open")?h():p()}),t.addEventListener("click",p),t.addEventListener("input",function(){var e=P(t.value);e&&(t.value!==e&&(t.value=e),f=e,r.style.backgroundColor=e,l.color!==e&&(l.color=e))}),t.addEventListener("blur",function(){v(t.value,{setInput:!0,dispatch:!1})||v(f,{setInput:!0,dispatch:!1})}),l.addEventListener("color-changed",function(e){v(e.detail.value,{setPicker:!1})})}}})}}function H(){document.querySelectorAll('input[type="range"][data-range-output]').forEach(function(e){var t=e.getAttribute("data-range-output"),n=document.getElementById(t);n&&e.addEventListener("input",function(){n.textContent=e.value})})}function D(){var e=document.querySelector("[data-settings-prefix]"),t=e?e.dataset.settingsPrefix:"";if(t){var n="data-".concat(t,"-logic"),r="data-".concat(t,"-fallback-option"),o="".concat(t,"-hidden"),i="".concat(t,"CondDisabled"),a="_".concat(t,"AnimHandler"),s=[],c=new Map;document.querySelectorAll("[".concat(n,"]")).forEach(function(e){var o,i,a=function(e){var t=e.getAttribute(n);if(!t)return[];try{var r=JSON.parse(t);if(Array.isArray(r))return r;if(r&&"object"===M(r))return[r]}catch(o){return[]}return[]}(e);if(a.length){var u=a.map(function(e){return{field:e.field,operator:e.operator,value:e.value,scope:e.scope||"field",action:e.action||"",target:e.target||"",container:e.container||""}}),l=(null===(o=u.find(function(e){return e.container}))||void 0===o?void 0:o.container)||"",d=null;"self"===l?d=e:l&&(d=e.querySelector(l)||document.querySelector(l)),d||(d=e.closest("tr")||e);var f=e.getAttribute("data-".concat(t,"-animation")),v=(null===(i=u.find(function(e){return e.action}))||void 0===i?void 0:i.action)||"show",p=e.getAttribute(r)||"",h={el:e,row:d,logic:u,animation:f,defaultAction:v,fallbackOption:p};s.push(h),u.forEach(function(e){c.has(e.field)||c.set(e.field,[]);var t=c.get(e.field);t.includes(h)||t.push(h)})}});var u=function(e){var t=function(e){var t=document.getElementById(e);if(t)return"checkbox"===t.type||"radio"===t.type?t.checked?t.value:"":t.value;var n=document.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]'));if(n.length>0){var r,o=_(n);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i.checked)return i.value}}catch(c){o.e(c)}finally{o.f()}return null}var a=document.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]'));if(a.length>0){var s=[];return a.forEach(function(e){e.checked&&s.push(e.value)}),s}return null}(e.field);if(null===t)return!1;switch(e.operator){case"is":return t===e.value;case"isnot":return t!==e.value;case"contains":return("string"==typeof t||Array.isArray(t))&&t.includes(e.value);case"containsnot":return("string"==typeof t||Array.isArray(t))&&!t.includes(e.value);default:return!1}},l=function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=e.row,s=e.animation,c=i.classList.contains(o);if(n===!c)return Promise.resolve();if(!r||!s||!["fade","slide"].includes(s))return i.classList.toggle(o,!n),Promise.resolve();var u="".concat(t,"-anim-in"),l="".concat(t,"-anim-out"),d="".concat(t,"-anim-").concat(s);return new Promise(function(e){i[a]&&(i.removeEventListener("animationend",i[a]),i[a]=null);var t=function(){i.classList.remove(u,l,d),n?i.classList.remove(o):i.classList.add(o),i.removeEventListener("animationend",t),i[a]=null,e()};i.classList.remove(u,l,d),n?(i.classList.remove(o),i.classList.add(u,d)):i.classList.add(l,d),i[a]=t,i.addEventListener("animationend",t,{once:!0})})},d=function(e,t){e.el.querySelectorAll("input, select, textarea, button").forEach(function(e){t?e.disabled||(e.dataset[i]="true",e.disabled=!0):"true"===e.dataset[i]&&(e.disabled=!1,delete e.dataset[i])})},f=function(e,t,n,r){var a=e.action||r;if(a){var s=function(e,t){if(e.target)return Array.from(document.querySelectorAll(e.target));var n=t.el.querySelectorAll('input[type="radio"]');if(n.length)return Array.from(n).filter(function(t){return t.value===e.value});var r=t.el.querySelectorAll('input[type="checkbox"]');if(r.length)return Array.from(r).filter(function(t){return t.value===e.value});var o=t.el.querySelector("select");return o?Array.from(o.options).filter(function(t){return t.value===e.value}):[]}(e,t);s.length&&s.forEach(function(e){if("disable"===a||"enable"===a)!function(e,t){t?e.disabled||(e.dataset[i]="true",e.disabled=!0):"true"===e.dataset[i]&&(e.disabled=!1,delete e.dataset[i])}(e,"disable"===a?n:!n);else if("show"===a||"hide"===a){var t="show"===a?n:!n;e.classList.toggle(o,!t)}})}},v=function(e){if(e.fallbackOption){var t=e.el.querySelectorAll('input[type="radio"]');if(t.length){var n=Array.from(t).find(function(e){return e.checked});if(!n||n.disabled){var r=Array.from(t).find(function(t){return t.value===e.fallbackOption&&!t.disabled});r||(r=Array.from(t).find(function(e){return!e.disabled})||null),r&&!r.checked&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}}else{var o=e.el.querySelector("select");if(o){var i=o.options[o.selectedIndex];if(i&&!i.disabled)return;var a=Array.from(o.options).find(function(t){return t.value===e.fallbackOption&&!t.disabled});a||(a=Array.from(o.options).find(function(e){return!e.disabled})),a&&(o.value=a.value,o.dispatchEvent(new Event("change",{bubbles:!0})))}}}},p=new Set,h=new Map;c.forEach(function(e,t){if(!p.has(t)){h.has(t)||h.set(t,{seq:0});!function(e,t){var n=document.getElementById(e);if(n)return n.addEventListener("change",t),void n.addEventListener("input",t);document.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",t)}),document.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",t)})}(t,function(){var n=h.get(t),r=++n.seq,i=[],a=[];if(e.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);f(t,e,n,e.defaultAction)}),v(e),r.length){var s=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,c=r.every(function(e){return u(e)});if("enable"!==s&&"disable"!==s){var l=e.row.classList.contains(o),p="show"===s?c:!c;p&&l?a.push(e):p||l||i.push(e)}else{d(e,"disable"===s?c:!c)}}}),i.length>0){var s=i.map(function(e){return l(e,!1,!0)});Promise.all(s).then(function(){n.seq===r&&a.forEach(function(e){return l(e,!0,!0)})})}else a.forEach(function(e){return l(e,!0,!0)})}),p.add(t)}}),s.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);f(t,e,n,e.defaultAction)}),v(e),r.length){var o=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,i=r.every(function(e){return u(e)});if("enable"!==o&&"disable"!==o)l(e,"show"===o?i:!i,!1);else d(e,"disable"===o?i:!i)}})}}function j(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"slide",r=document.querySelector("[data-settings-prefix]"),o=r?r.dataset.settingsPrefix:"";if(!o)return e.style.display=t?"":"none",Promise.resolve();var i="".concat(o,"-hidden"),a="".concat(o,"-anim-in"),s="".concat(o,"-anim-out"),c="".concat(o,"-anim-").concat(n),u="_".concat(o,"AnimHandler");return new Promise(function(n){e[u]&&(e.removeEventListener("animationend",e[u]),e[u]=null);var r=function(){e.classList.remove(a,s,c),t?e.classList.remove(i):e.classList.add(i),e.removeEventListener("animationend",r),e[u]=null,n()};e.classList.remove(a,s,c),t?(e.classList.remove(i),e.classList.add(a,c)):e.classList.add(s,c),e[u]=r,e.addEventListener("animationend",r,{once:!0})})}document.addEventListener("DOMContentLoaded",function(){O(),H(),D()}),document.addEventListener("wpAjaxContentLoaded",function(){O(),H(),D()}),($=jQuery)(function(){var e=$("#pvc-general-exclude-ips-setting"),t=e.find(".pvc-ip-box").length,n=function(){e.find(".pvc-remove-exclude-ip").each(function(e,n){0===e?n.classList.add("pvc-hidden"):t>1?n.classList.remove("pvc-hidden"):n.classList.add("pvc-hidden")})};n(),$(document).on("click",".reset_pvc_settings",function(){var e=confirm(pvcArgsSettings.resetToDefaults);return e&&$(this).hasClass("reset_post_views_counter_settings_other")&&$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')),e}),$(document).on("click",'input[name="post_views_counter_reset_views"]',function(){return confirm(pvcArgsSettings.resetViews)}),$(document).on("click",'input[name="post_views_counter_import_views"]',function(){return confirm(pvcArgsSettings.importViews)}),$(document).on("click",".pvc-remove-exclude-ip",function(e){e.preventDefault();var r=$(this).closest(".pvc-ip-box")[0];j(r,!1).then(function(){r.remove(),t--,n()})}),$(document).on("click",".pvc-add-exclude-ip",function(){var e=$(this).parents("#pvc-general-exclude-ips-setting"),r=e.find('.pvc-ip-box:last input[type="text"]');if(function(e){if(!e)return!1;var t=-1!==e.indexOf("*")?e.replace(/\*/g,"0"):e;return Boolean(t.match(/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/))}(r.val().trim())){t++;var o=e.find(".pvc-ip-box:last").clone();o.find("input").val(""),o[0].classList.add("pvc-hidden"),e.find(".pvc-ip-box:last").after(o),j(o[0],!0),n()}else r.focus()}),$(document).on("click",".pvc-add-current-ip",function(){$(this).parents("#pvc-general-exclude-ips-setting").find(".pvc-ip-box").last().find("input").val($(this).attr("data-rel"))}),$('input[name="post_views_counter_settings_display[menu_position]"], input[name="post_views_counter_settings_other[menu_position]"]').on("change",function(){"top"===$(this).val()?$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')):$('input[data-pvc-menu="submenu"]').before($('input[data-pvc-menu="topmenu"]'))})});2 const e=(e,t=0,n=1)=>e>n?n:e<t?t:e,t=(e,t=0,n=Math.pow(10,t))=>Math.round(n*e)/n,n=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?t(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?t(parseInt(e.substring(6,8),16)/255,2):1}),r=e=>{const{h:n,s:r,l:o}=(({h:e,s:n,v:r,a:o})=>{const i=(200-n)*r/100;return{h:t(e),s:t(i>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0),l:t(i/2),a:t(o,2)}})(e);return`hsl(${n}, ${r}%, ${o}%)`},o=({h:e,s:n,v:r,a:o})=>{e=e/360*6,n/=100,r/=100;const i=Math.floor(e),a=r*(1-n),s=r*(1-(e-i)*n),c=r*(1-(1-e+i)*n),u=i%6;return{r:t(255*[r,s,a,a,c,r][u]),g:t(255*[c,r,r,s,a,a][u]),b:t(255*[a,a,c,r,r,s][u]),a:t(o,2)}},i=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},a=({r:e,g:n,b:r,a:o})=>{const a=o<1?i(t(255*o)):"";return"#"+i(e)+i(n)+i(r)+a},s=({r:e,g:n,b:r,a:o})=>{const i=Math.max(e,n,r),a=i-Math.min(e,n,r),s=a?i===e?(n-r)/a:i===n?2+(r-e)/a:4+(e-n)/a:0;return{h:t(60*(s<0?s+6:s)),s:t(i?a/i*100:0),v:t(i/255*100),a:o}},c=(e,t)=>{if(e===t)return!0;for(const n in e)if(e[n]!==t[n])return!1;return!0},u={},l=e=>{let t=u[e];return t||(t=document.createElement("template"),t.innerHTML=e,u[e]=t),t},d=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};let f=!1;const v=e=>"touches"in e,p=(t,n)=>{const r=v(n)?n.touches[0]:n,o=t.el.getBoundingClientRect();d(t.el,"move",t.getMove({x:e((r.pageX-(o.left+window.pageXOffset))/o.width),y:e((r.pageY-(o.top+window.pageYOffset))/o.height)}))};class h{constructor(e,t,n,r){const o=l(`<div role="slider" tabindex="0" part="${t}" ${n}><div part="${t}-pointer"></div></div>`);e.appendChild(o.content.cloneNode(!0));const i=e.querySelector(`[part=${t}]`);i.addEventListener("mousedown",this),i.addEventListener("touchstart",this),i.addEventListener("keydown",this),this.el=i,this.xy=r,this.nodes=[i.firstChild,i]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(f?"touchmove":"mousemove",this),t(f?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(f&&!v(e)||(f||(f=v(e)),0)))(e)||!f&&0!=e.button)return;this.el.focus(),p(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),p(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const n=t.keyCode;n>40||e.xy&&n<37||n<33||(t.preventDefault(),d(e.el,"move",e.getMove({x:39===n?.01:37===n?-.01:34===n?.05:33===n?-.05:35===n?1:36===n?-1:0,y:40===n?.01:38===n?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const n in e)this.nodes[t].style.setProperty(n,e[n])})}}class m extends h{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:r({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${t(e)}`)}getMove(t,n){return{h:n?e(this.h+360*t.x,0,360):360*t.x}}}class g extends h{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:r(e)},{"background-color":r({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${t(e.s)}%, Brightness ${t(e.v)}%`)}getMove(t,n){return{s:n?e(this.hsva.s+100*t.x,0,100):100*t.x,v:n?e(this.hsva.v-100*t.y,0,100):Math.round(100-100*t.y)}}}const b=Symbol("same"),y=Symbol("color"),x=Symbol("hsva"),w=Symbol("update"),E=Symbol("parts"),L=Symbol("css"),A=Symbol("sliders");class S extends HTMLElement{static get observedAttributes(){return["color"]}get[L](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[A](){return[g,m]}get color(){return this[y]}set color(e){if(!this[b](e)){const t=this.colorModel.toHsva(e);this[w](t),this[y]=e}}constructor(){super();const e=l(`<style>${this[L].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[E]=this[A].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,n){const r=this.colorModel.fromAttr(n);this[b](r)||(this.color=r)}handleEvent(e){const t=this[x],n={...t,...e.detail};let r;this[w](n),c(n,t)||this[b](r=this.colorModel.fromHsva(n))||(this[y]=r,d(this,"color-changed",{value:r}))}[b](e){return this.color&&this.colorModel.equal(e,this.color)}[w](e){this[x]=e,this[E].forEach(t=>t.update(e))}}const k={defaultColor:"#000",toHsva:e=>s(n(e)),fromHsva:({h:e,s:t,v:n})=>a(o({h:e,s:t,v:n,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||c(n(e),n(t)),fromAttr:e=>e};class q extends S{get colorModel(){return k}}function _(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return C(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},M(e)}customElements.define("hex-color-picker",class extends q{});var $,I=/^[0-9a-f]{3}([0-9a-f]{3})?$/i,P=function(e){if(!e)return"";var t=e.trim();if(!t)return"";var n=t.startsWith("#")?t.slice(1):t;return I.test(n)?"#".concat(n.toLowerCase()):""};function O(){var e=document.querySelector("[data-settings-prefix]"),t=e?e.dataset.settingsPrefix:"";if(t){var n=".".concat(t,"-hex-color-picker"),r=".".concat(t,"-field-type-color"),o=".".concat(t,"-color-input"),i=".".concat(t,"-color-swatch"),a=".".concat(t,"-color-popover"),s=".".concat(t,"-color-control"),c="".concat(t,"ColorInitialized");document.querySelectorAll(r).forEach(function(e){if("true"!==e.dataset[c]){var t=e.querySelector(o),r=e.querySelector(i),u=e.querySelector(a),l=e.querySelector(n),d=e.querySelector(s);if(t&&r&&u&&l&&d){l.addEventListener("mousedown",function(e){return e.stopPropagation()}),e.dataset[c]="true";var f=P(t.value)||"#000000",v=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.setInput,i=void 0===o||o,a=n.dispatch,s=void 0===a||a,c=n.setPicker,u=void 0===c||c,d=P(e);return!!d&&(f=d,i&&(t.value=d),r.style.backgroundColor=d,u&&l.color!==d&&(l.color=d),s&&t.dispatchEvent(new Event("input",{bubbles:!0})),!0)},p=function(){e.classList.contains("is-open")||(e.classList.add("is-open"),u.removeAttribute("aria-hidden"),r.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",m,!0),document.addEventListener("keydown",g))},h=function(){e.classList.contains("is-open")&&(e.classList.remove("is-open"),u.setAttribute("aria-hidden","true"),r.setAttribute("aria-expanded","false"),document.removeEventListener("mousedown",m,!0),document.removeEventListener("keydown",g))},m=function(e){var t="function"==typeof e.composedPath?e.composedPath():[];d.contains(e.target)||t.includes(d)||t.includes(u)||t.includes(l)||h()},g=function(e){"Escape"===e.key&&h()};v(f,{setInput:!0,dispatch:!1}),r.addEventListener("click",function(t){t.preventDefault(),e.classList.contains("is-open")?h():p()}),t.addEventListener("click",p),t.addEventListener("input",function(){var e=P(t.value);e&&(t.value!==e&&(t.value=e),f=e,r.style.backgroundColor=e,l.color!==e&&(l.color=e))}),t.addEventListener("blur",function(){v(t.value,{setInput:!0,dispatch:!1})||v(f,{setInput:!0,dispatch:!1})}),l.addEventListener("color-changed",function(e){v(e.detail.value,{setPicker:!1})})}}})}}function H(){document.querySelectorAll('input[type="range"][data-range-output]').forEach(function(e){var t=e.getAttribute("data-range-output"),n=document.getElementById(t);n&&e.addEventListener("input",function(){n.textContent=e.value})})}function D(){var e=document.querySelector("[data-settings-prefix]"),t=e?e.dataset.settingsPrefix:"";if(t){var n="data-".concat(t,"-logic"),r="data-".concat(t,"-fallback-option"),o="".concat(t,"-hidden"),i="".concat(t,"CondDisabled"),a="_".concat(t,"AnimHandler"),s=[],c=new Map;document.querySelectorAll("[".concat(n,"]")).forEach(function(e){var o,i,a=function(e){var t=e.getAttribute(n);if(!t)return[];try{var r=JSON.parse(t);if(Array.isArray(r))return r;if(r&&"object"===M(r))return[r]}catch(o){return[]}return[]}(e);if(a.length){var u=a.map(function(e){return{field:e.field,operator:e.operator,value:e.value,scope:e.scope||"field",action:e.action||"",target:e.target||"",container:e.container||""}}),l=(null===(o=u.find(function(e){return e.container}))||void 0===o?void 0:o.container)||"",d=null;"self"===l?d=e:l&&(d=e.querySelector(l)||document.querySelector(l)),d||(d=e.closest("tr")||e);var f=e.getAttribute("data-".concat(t,"-animation")),v=(null===(i=u.find(function(e){return e.action}))||void 0===i?void 0:i.action)||"show",p=e.getAttribute(r)||"",h={el:e,row:d,logic:u,animation:f,defaultAction:v,fallbackOption:p};s.push(h),u.forEach(function(e){c.has(e.field)||c.set(e.field,[]);var t=c.get(e.field);t.includes(h)||t.push(h)})}});var u=function(e){var t=function(e){var t=document.getElementById(e);if(t)return"checkbox"===t.type||"radio"===t.type?t.checked?t.value:"":t.value;var n=document.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]'));if(n.length>0){var r,o=_(n);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i.checked)return i.value}}catch(c){o.e(c)}finally{o.f()}return null}var a=document.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]'));if(a.length>0){var s=[];return a.forEach(function(e){e.checked&&s.push(e.value)}),s}return null}(e.field);if(null===t)return!1;switch(e.operator){case"is":return t===e.value;case"isnot":return t!==e.value;case"contains":return("string"==typeof t||Array.isArray(t))&&t.includes(e.value);case"containsnot":return("string"==typeof t||Array.isArray(t))&&!t.includes(e.value);default:return!1}},l=function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=e.row,s=e.animation,c=i.classList.contains(o);if(n===!c)return Promise.resolve();if(!r||!s||!["fade","slide"].includes(s))return i.classList.toggle(o,!n),Promise.resolve();var u="".concat(t,"-anim-in"),l="".concat(t,"-anim-out"),d="".concat(t,"-anim-").concat(s);return new Promise(function(e){i[a]&&(i.removeEventListener("animationend",i[a]),i[a]=null);var t=function(){i.classList.remove(u,l,d),n?i.classList.remove(o):i.classList.add(o),i.removeEventListener("animationend",t),i[a]=null,e()};i.classList.remove(u,l,d),n?(i.classList.remove(o),i.classList.add(u,d)):i.classList.add(l,d),i[a]=t,i.addEventListener("animationend",t,{once:!0})})},d=function(e,t){e.el.querySelectorAll("input, select, textarea, button").forEach(function(e){t?e.disabled||(e.dataset[i]="true",e.disabled=!0):"true"===e.dataset[i]&&(e.disabled=!1,delete e.dataset[i])})},f=function(e,t,n,r){var a=e.action||r;if(a){var s=function(e,t){if(e.target)return Array.from(document.querySelectorAll(e.target));var n=t.el.querySelectorAll('input[type="radio"]');if(n.length)return Array.from(n).filter(function(t){return t.value===e.value});var r=t.el.querySelectorAll('input[type="checkbox"]');if(r.length)return Array.from(r).filter(function(t){return t.value===e.value});var o=t.el.querySelector("select");return o?Array.from(o.options).filter(function(t){return t.value===e.value}):[]}(e,t);s.length&&s.forEach(function(e){if("disable"===a||"enable"===a)!function(e,t){t?e.disabled||(e.dataset[i]="true",e.disabled=!0):"true"===e.dataset[i]&&(e.disabled=!1,delete e.dataset[i])}(e,"disable"===a?n:!n);else if("show"===a||"hide"===a){var t="show"===a?n:!n;e.classList.toggle(o,!t)}})}},v=function(e){if(e.fallbackOption){var t=e.el.querySelectorAll('input[type="radio"]');if(t.length){var n=Array.from(t).find(function(e){return e.checked});if(!n||n.disabled){var r=Array.from(t).find(function(t){return t.value===e.fallbackOption&&!t.disabled});r||(r=Array.from(t).find(function(e){return!e.disabled})||null),r&&!r.checked&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}}else{var o=e.el.querySelector("select");if(o){var i=o.options[o.selectedIndex];if(i&&!i.disabled)return;var a=Array.from(o.options).find(function(t){return t.value===e.fallbackOption&&!t.disabled});a||(a=Array.from(o.options).find(function(e){return!e.disabled})),a&&(o.value=a.value,o.dispatchEvent(new Event("change",{bubbles:!0})))}}}},p=new Set,h=new Map;c.forEach(function(e,t){if(!p.has(t)){h.has(t)||h.set(t,{seq:0});!function(e,t){var n=document.getElementById(e);if(n)return n.addEventListener("change",t),void n.addEventListener("input",t);document.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",t)}),document.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",t)})}(t,function(){var n=h.get(t),r=++n.seq,i=[],a=[];if(e.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);f(t,e,n,e.defaultAction)}),v(e),r.length){var s=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,c=r.every(function(e){return u(e)});if("enable"!==s&&"disable"!==s){var l=e.row.classList.contains(o),p="show"===s?c:!c;p&&l?a.push(e):p||l||i.push(e)}else{d(e,"disable"===s?c:!c)}}}),i.length>0){var s=i.map(function(e){return l(e,!1,!0)});Promise.all(s).then(function(){n.seq===r&&a.forEach(function(e){return l(e,!0,!0)})})}else a.forEach(function(e){return l(e,!0,!0)})}),p.add(t)}}),s.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);f(t,e,n,e.defaultAction)}),v(e),r.length){var o=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,i=r.every(function(e){return u(e)});if("enable"!==o&&"disable"!==o)l(e,"show"===o?i:!i,!1);else d(e,"disable"===o?i:!i)}})}}function j(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"slide",r=document.querySelector("[data-settings-prefix]"),o=r?r.dataset.settingsPrefix:"";if(!o)return e.style.display=t?"":"none",Promise.resolve();var i="".concat(o,"-hidden"),a="".concat(o,"-anim-in"),s="".concat(o,"-anim-out"),c="".concat(o,"-anim-").concat(n),u="_".concat(o,"AnimHandler");return new Promise(function(n){e[u]&&(e.removeEventListener("animationend",e[u]),e[u]=null);var r=function(){e.classList.remove(a,s,c),t?e.classList.remove(i):e.classList.add(i),e.removeEventListener("animationend",r),e[u]=null,n()};e.classList.remove(a,s,c),t?(e.classList.remove(i),e.classList.add(a,c)):e.classList.add(s,c),e[u]=r,e.addEventListener("animationend",r,{once:!0})})}document.addEventListener("DOMContentLoaded",function(){O(),H(),D()}),document.addEventListener("wpAjaxContentLoaded",function(){O(),H(),D()}),($=jQuery)(function(){var e=$("#pvc-general-exclude-ips-setting"),t=window.pvcArgsSettings||{},n=e.find(".pvc-ip-box").length,r=function(){e.find(".pvc-remove-exclude-ip").each(function(e,t){0===e?t.classList.add("pvc-hidden"):n>1?t.classList.remove("pvc-hidden"):t.classList.add("pvc-hidden")})};r(),$(document).on("click",".reset_pvc_settings",function(){var e=confirm(t.resetToDefaults);return e&&$(this).hasClass("reset_post_views_counter_settings_other")&&$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')),e}),$(document).on("click",'input[name="post_views_counter_reset_views"]',function(){return confirm(t.resetViews)}),$(document).on("click",'input[name="post_views_counter_import_views"]',function(){return confirm(t.importViews)}),$(document).on("click",".pvc-remove-exclude-ip",function(e){e.preventDefault();var t=$(this).closest(".pvc-ip-box")[0];j(t,!1).then(function(){return t.remove(),n--,r(),null}).catch(function(){return null})});var o=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,i=function(e){if(!e)return!1;var t=e.trim();return function(e){var t=-1!==e.indexOf("*")?e.replace(/\*/g,"0"):e;return o.test(t)}(t)||function(e){if(-1===e.indexOf(":")||-1!==e.indexOf("*"))return!1;try{return""!==new URL("http://[".concat(e,"]")).hostname}catch(t){return!1}}(t)};$(document).on("click",".pvc-add-exclude-ip",function(){var e=$(this).parents("#pvc-general-exclude-ips-setting"),t=e.find('.pvc-ip-box:last input[type="text"]'),o=t.val().trim();if(i(o)){n++;var a=e.find(".pvc-ip-box:last").clone();a.find("input").val(""),a[0].classList.add("pvc-hidden"),e.find(".pvc-ip-box:last").after(a),j(a[0],!0),r()}else t.focus()}),$(document).on("click",".pvc-add-current-ip",function(){$(this).parents("#pvc-general-exclude-ips-setting").find(".pvc-ip-box").last().find("input").val($(this).attr("data-rel"))}),$('input[name="post_views_counter_settings_display[menu_position]"], input[name="post_views_counter_settings_other[menu_position]"]').on("change",function(){"top"===$(this).val()?$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')):$('input[data-pvc-menu="submenu"]').before($('input[data-pvc-menu="topmenu"]'))})}); 3 3 4 4 })(jQuery, window, document); -
post-views-counter/trunk/post-views-counter.php
r3470602 r3478985 3 3 Plugin Name: Post Views Counter 4 4 Description: Post Views Counter allows you to collect and display how many times a post, page, or other content has been viewed in a simple, fast and reliable way. 5 Version: 1.7. 75 Version: 1.7.8 6 6 Author: dFactory 7 7 Author URI: https://dfactory.co/ … … 13 13 14 14 Post Views Counter 15 Copyright (C) 2014-202 5, Digital Factory - info@digitalfactory.pl15 Copyright (C) 2014-2026, Digital Factory - info@digitalfactory.pl 16 16 17 17 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: … … 31 31 * 32 32 * @class Post_Views_Counter 33 * @version 1.7. 733 * @version 1.7.8 34 34 */ 35 35 final class Post_Views_Counter { … … 112 112 'integrations' => [] 113 113 ], 114 'version' => '1.7. 7'114 'version' => '1.7.8' 115 115 ]; 116 116 -
post-views-counter/trunk/readme.txt
r3470602 r3478985 5 5 Requires PHP: 7.0 6 6 Tested up to: 6.9.1 7 Stable tag: 1.7. 77 Stable tag: 1.7.8 8 8 License: MIT License 9 9 License URI: http://opensource.org/licenses/MIT … … 93 93 == Changelog == 94 94 95 = 1.7.8 = 96 * Fix: Harden option-backed in_array() checks to prevent PHP 8.x TypeErrors. 97 * Fix: Add IPv6 support for excluded IP matching in settings and counting. 98 * Tweak: Update internal build tooling. 99 95 100 = 1.7.7 = 96 101 * Fix: Prevent undefined array key warnings when saving Display settings menu position. … … 456 461 == Upgrade Notice == 457 462 458 = 1.7. 7=459 Fixes PHP warnings triggered by partial Display settings saves and improves validation robustness.463 = 1.7.8 = 464 Improves PHP 8.x compatibility, fixes IPv6 excluded IP handling, and updates internal build tooling.
Note: See TracChangeset
for help on using the changeset viewer.