Skip to content

Commit 57d124a

Browse files
authored
Merge develop into transifex
2 parents 70508f3 + 23a823b commit 57d124a

File tree

53 files changed

+576
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+576
-396
lines changed

.github/workflows/lint_phpcs.yml

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
1-
name: PHP CodeSniffer lint
1+
name: PHP CodeSniffer
22

33
on:
44
pull_request:
5-
branches:
6-
- trunk
7-
- develop
8-
- branch-*
9-
- feature/*
10-
- enhancement/*
11-
- fix/*
5+
workflow_dispatch:
126

13-
jobs:
14-
run:
15-
runs-on: ${{ matrix.operating-system }}
16-
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
operating-system: [ubuntu-latest]
21-
php-versions: ['8.4']
22-
23-
name: WPRocket lint with PHPCS. PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}.
24-
steps:
25-
- name: Checkout
26-
uses: actions/checkout@v4
27-
28-
- name: Setup PHP
29-
uses: shivammathur/setup-php@v2
30-
with:
31-
php-version: ${{ matrix.php-versions }}
32-
coverage: none # XDebug can be enabled here 'coverage: xdebug'
33-
tools: composer:v2
34-
35-
- name: Install dependencies
36-
run: composer install --prefer-dist --no-interaction --no-scripts
37-
38-
- name: Lint with phpcs
39-
run: composer phpcs
7+
# Cancel all previous workflow runs for the same branch that have not yet completed.
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
4011

12+
jobs:
13+
lint:
14+
uses: wp-media/workflows/.github/workflows/phpcs.yml@main
15+
with:
16+
composer-options: --no-scripts

.github/workflows/lint_phpstan.yml

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,16 @@
1-
name: PHP Stan lint
1+
name: PHPStan
22

33
on:
44
pull_request:
5-
branches:
6-
- trunk
7-
- develop
8-
- branch-*
9-
- feature/*
10-
- enhancement/*
11-
- fix/*
12-
- dev/*
5+
workflow_dispatch:
136

14-
jobs:
15-
run:
16-
runs-on: ${{ matrix.operating-system }}
17-
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
operating-system: [ubuntu-latest]
22-
php-versions: ['8.4']
23-
24-
name: WPRocket lint with PHP Stan. PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}.
25-
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v4
28-
29-
- name: Setup PHP
30-
uses: shivammathur/setup-php@v2
31-
with:
32-
php-version: ${{ matrix.php-versions }}
33-
coverage: none # XDebug can be enabled here 'coverage: xdebug'
34-
tools: composer:v2
35-
36-
- name: Install dependencies
37-
run: composer install --prefer-dist --no-interaction --no-scripts
38-
39-
- name: Lint with PHP Stan
40-
run: composer run-stan
7+
# Cancel all previous workflow runs for the same branch that have not yet completed.
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
4111

12+
jobs:
13+
lint:
14+
uses: wp-media/workflows/.github/workflows/phpstan.yml@main
15+
with:
16+
composer-options: --no-scripts

assets/css/wpr-admin.css

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,34 @@ a:focus, button:focus {
104104
font-size: 1em;
105105
}
106106

107+
.wpr-loader {
108+
position: fixed;
109+
top: 50%;
110+
left: 50%;
111+
transform: translate(-50%, -50%);
112+
margin: 0 auto;
113+
width: 60px;
114+
aspect-ratio: 2;
115+
--_g: no-repeat radial-gradient(circle closest-side,#ffffff 90%,#0000);
116+
background: var(--_g) 0% 50%, var(--_g) 50% 50%, var(--_g) 100% 50%;
117+
background-size: 33.3333333333% 50%;
118+
animation: l3 1s infinite linear;
119+
}
120+
121+
@keyframes l3 {
122+
20% {
123+
background-position: 0% 0%, 50% 50%, 100% 50%;
124+
}
125+
40% {
126+
background-position: 0% 100%, 50% 0%, 100% 50%;
127+
}
128+
60% {
129+
background-position: 0% 50%, 50% 100%, 100% 0%;
130+
}
131+
80% {
132+
background-position: 0% 50%, 50% 50%, 100% 100%;
133+
}
134+
}
107135
/*-----------------------------------------------*\
108136
109137
Icons in a font-icon with icomoon (https://icomoon.io/app)
@@ -715,7 +743,7 @@ a:focus, button:focus {
715743
color: #121116;
716744
padding: 8px 0;
717745
padding-left: 4px;
718-
border-bottom: 1px solid #c2cad4;
746+
border-bottom: 1px solid rgb(194.1698113208, 202.0188679245, 211.8301886792);
719747
}
720748
.wpr-Popin .wp-rocket-data-table td:not(.column-primary) {
721749
font-family: "Monaco";
@@ -2573,6 +2601,7 @@ div.wpr-tutorial-item {
25732601
max-height: 100vh;
25742602
overflow-y: auto;
25752603
box-sizing: border-box;
2604+
z-index: 1;
25762605
}
25772606
.wpr-rocketcdn-modal iframe {
25782607
max-width: 100%;
@@ -2870,7 +2899,7 @@ div.wpr-tutorial-item {
28702899
font-family: Monaco;
28712900
color: #121116;
28722901
background: #fff;
2873-
border: 2px solid #c2cad4;
2902+
border: 2px solid rgb(194.1698113208, 202.0188679245, 211.8301886792);
28742903
border-radius: 3px;
28752904
font-size: 0.8125rem;
28762905
line-height: 1.2307692308;
@@ -2902,7 +2931,7 @@ div.wpr-tutorial-item {
29022931
height: 32px;
29032932
color: #121116;
29042933
background: #fff;
2905-
border: 2px solid #c2cad4;
2934+
border: 2px solid rgb(194.1698113208, 202.0188679245, 211.8301886792);
29062935
border-radius: 3px;
29072936
font-family: Monaco;
29082937
font-size: 0.75rem;

assets/css/wpr-admin.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/mixpanel-2-latest.min.js

Lines changed: 0 additions & 152 deletions
This file was deleted.

assets/js/wpr-admin.js

Lines changed: 56 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/wpr-admin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/wpr-admin.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/wpr-beacon.js

Lines changed: 76 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,65 @@
2424
static isPageScrolled() {
2525
return window.pageYOffset > 0 || document.documentElement.scrollTop > 0;
2626
}
27+
/**
28+
* Checks if an element is visible in the viewport.
29+
*
30+
* This method checks if the provided element is visible in the viewport by
31+
* considering its display, visibility, opacity, width, and height properties.
32+
* It also excludes elements with transparent text properties.
33+
* It returns true if the element is visible, and false otherwise.
34+
*
35+
* @param {Element} element - The element to check for visibility.
36+
* @returns {boolean} True if the element is visible, false otherwise.
37+
*/
38+
static isElementVisible(element) {
39+
const style = window.getComputedStyle(element);
40+
const rect = element.getBoundingClientRect();
41+
if (!style) {
42+
return false;
43+
}
44+
if (this.hasTransparentText(element)) {
45+
return false;
46+
}
47+
return !(style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || rect.width === 0 || rect.height === 0);
48+
}
49+
/**
50+
* Checks if an element has transparent text properties.
51+
*
52+
* This method checks for specific CSS properties that make text invisible,
53+
* such as `color: transparent`, `color: rgba(..., 0)`, `color: hsla(..., 0)`,
54+
* `color: #...00` (8-digit hex with alpha = 0), and `filter: opacity(0)`.
55+
*
56+
* @param {Element} element - The element to check.
57+
* @returns {boolean} True if the element has transparent text properties, false otherwise.
58+
*/
59+
static hasTransparentText(element) {
60+
const style = window.getComputedStyle(element);
61+
if (!style) {
62+
return false;
63+
}
64+
const color = style.color || "";
65+
const filter = style.filter || "";
66+
if (color === "transparent") {
67+
return true;
68+
}
69+
const rgbaMatch = color.match(/rgba\(\d+,\s*\d+,\s*\d+,\s*0\)/);
70+
if (rgbaMatch) {
71+
return true;
72+
}
73+
const hslaMatch = color.match(/hsla\(\d+,\s*\d+%,\s*\d+%,\s*0\)/);
74+
if (hslaMatch) {
75+
return true;
76+
}
77+
const hexMatch = color.match(/#[0-9a-fA-F]{6}00/);
78+
if (hexMatch) {
79+
return true;
80+
}
81+
if (filter.includes("opacity(0)")) {
82+
return true;
83+
}
84+
return false;
85+
}
2786
};
2887
var Utils_default = BeaconUtils;
2988

@@ -72,7 +131,7 @@
72131
rect
73132
};
74133
}).filter((item) => item !== null).filter((item) => {
75-
return item.rect.width > 0 && item.rect.height > 0 && Utils_default.isIntersecting(item.rect);
134+
return item.rect.width > 0 && item.rect.height > 0 && Utils_default.isIntersecting(item.rect) && Utils_default.isElementVisible(item.element);
76135
}).map((item) => ({
77136
item,
78137
area: this._getElementArea(item.rect),
@@ -483,55 +542,14 @@
483542
/**
484543
* Checks if an element is visible in the viewport.
485544
*
486-
* This method checks if the provided element is visible in the viewport by
487-
* considering its display, visibility, opacity, width, and height properties.
488-
* It also excludes elements with transparent text properties.
489-
* It returns true if the element is visible, and false otherwise.
545+
* This method delegates to BeaconUtils.isElementVisible() for consistent
546+
* visibility checking across all beacons.
490547
*
491548
* @param {Element} element - The element to check for visibility.
492549
* @returns {boolean} True if the element is visible, false otherwise.
493550
*/
494551
isElementVisible(element) {
495-
const style = window.getComputedStyle(element);
496-
const rect = element.getBoundingClientRect();
497-
if (this.hasTransparentText(element)) {
498-
return false;
499-
}
500-
return !(style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || rect.width === 0 || rect.height === 0);
501-
}
502-
/**
503-
* Checks if an element has transparent text properties.
504-
*
505-
* This method checks for specific CSS properties that make text invisible,
506-
* such as `color: transparent`, `color: rgba(..., 0)`, `color: hsla(..., 0)`,
507-
* `color: #...00` (8-digit hex with alpha = 0), and `filter: opacity(0)`.
508-
*
509-
* @param {Element} element - The element to check.
510-
* @returns {boolean} True if the element has transparent text properties, false otherwise.
511-
*/
512-
hasTransparentText(element) {
513-
const style = window.getComputedStyle(element);
514-
const color = style.color || "";
515-
const filter = style.filter || "";
516-
if (color === "transparent") {
517-
return true;
518-
}
519-
const rgbaMatch = color.match(/rgba\(\d+,\s*\d+,\s*\d+,\s*0\)/);
520-
if (rgbaMatch) {
521-
return true;
522-
}
523-
const hslaMatch = color.match(/hsla\(\d+,\s*\d+%,\s*\d+%,\s*0\)/);
524-
if (hslaMatch) {
525-
return true;
526-
}
527-
const hexMatch = color.match(/#[0-9a-fA-F]{6}00/);
528-
if (hexMatch) {
529-
return true;
530-
}
531-
if (filter.includes("opacity(0)")) {
532-
return true;
533-
}
534-
return false;
552+
return Utils_default.isElementVisible(element);
535553
}
536554
/**
537555
* Cleans a URL by removing query parameters and fragments.
@@ -631,19 +649,21 @@
631649
});
632650
return fontPairs;
633651
}
634-
const externalFontsProviders = [
635-
"fonts.googleapis.com",
636-
"fonts.gstatic.com",
637-
"use.typekit.net",
638-
"fonts.adobe.com",
639-
"cdn.fonts.net"
640-
// Add more known external font domains as needed
641-
];
642652
const links = [
643653
...document.querySelectorAll('link[rel="stylesheet"]')
644-
].filter(
645-
(link) => externalFontsProviders.some((domain) => link.href.includes(domain))
646-
);
654+
].filter((link) => {
655+
try {
656+
const linkUrl = new URL(link.href);
657+
const currentUrl = new URL(window.location.href);
658+
if (linkUrl.origin === currentUrl.origin) {
659+
return false;
660+
}
661+
const exclusions = this.config.external_font_exclusions || [];
662+
return !exclusions.some((exclusion) => link.href.includes(exclusion));
663+
} catch (e) {
664+
return false;
665+
}
666+
});
647667
if (links.length === 0) {
648668
this.logger.logMessage("No external CSS links found to process.");
649669
return {

0 commit comments

Comments
 (0)