Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #7241: 3.19 Preload Fonts Beacon Processing Part #7316

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 440 additions & 4 deletions assets/js/wpr-beacon.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/wpr-beacon.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions assets/js/wpr-beacon.min.js.map

Large diffs are not rendered by default.

111 changes: 110 additions & 1 deletion inc/Engine/Media/PreloadFonts/Frontend/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,116 @@ public function add_custom_data( array $data ): array {
*/
$system_fonts = wpm_apply_filters_typed( 'array', 'rocket_preload_fonts_system_fonts', $system_fonts );

$data['system_fonts'] = $system_fonts;
// To Delete Mock Data during implementation of https://github.com/wp-media/wp-rocket/issues/7306.
$font_data = [
'https://fonts.gstatic.com/s/poppins/v22/pxiAyp8kv8JHgFVrJJLmE0tMMPKhSkFEkm8.woff2' => [
[
'family' => 'Poppins',
'weight' => '100',
'style' => 'italic',
'unicodeRange' => 'U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiAyp8kv8JHgFVrJJLmE0tCMPKhSkFE.woff2' => [
[
'family' => 'Poppins',
'weight' => '100',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiDyp8kv8JHgFVrJJLmv1pVGdeOYktMqlap.woff2' => [
[
'family' => 'Poppins',
'weight' => '200',
'style' => 'italic',
'unicodeRange' => 'U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiDyp8kv8JHgFVrJJLmv1pVF9eOYktMqg.woff2' => [
[
'family' => 'Poppins',
'weight' => '200',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiDyp8kv8JHgFVrJJLm21lVGdeOYktMqlap.woff2' => [
[
'family' => 'Poppins',
'weight' => '300',
'style' => 'italic',
'unicodeRange' => 'U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiDyp8kv8JHgFVrJJLm21lVF9eOYktMqg.woff2' => [
[
'family' => 'Poppins',
'weight' => '300',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiEyp8kv8JHgFVrJJLmg1hHGpeKQEk.woff2' => [
[
'family' => 'Poppins',
'weight' => '400',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiFyp8kv8JHgFVrJJLucHtUFMNEKQ.woff2' => [
[
'family' => 'Poppins',
'weight' => '500',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiGyp8kv8JHgFVrJJLsbX9NE9eO.woff2' => [
[
'family' => 'Poppins',
'weight' => '600',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiGyp8kv8JHgFVrJJLsbXpNE9eO.woff2' => [
[
'family' => 'Poppins',
'weight' => '900',
'style' => 'italic',
'unicodeRange' => 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC…',
],
],
'https://fonts.gstatic.com/s/poppins/v22/pxiGyp8kv8JHgFVrLPTufntAOvWDSHFF.woff2' => [
[
'family' => 'Poppins',
'weight' => '100',
'style' => 'normal',
'unicodeRange' => 'U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7…',
],
],
'https://fonts.cdnfonts.com/s/31427/Paper Sign.woff' => [
[
'family' => 'Paper Sign',
'weight' => '400',
'style' => 'normal',
'unicodeRange' => 'U+0000-10FFFF',
],
],
];

/**
* Filters the list of mock font urls.
*
* @param array $font_data Array of font data.
*/
$font_data = wpm_apply_filters_typed( 'array', 'rocket_preload_fonts_font_data', $font_data );

$data['system_fonts'] = $system_fonts;
$data['font_data'] = $font_data;
$data['status']['preload_fonts'] = $this->context->is_allowed();

return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"watchify": "^4.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"wp-rocket-scripts": "^1.0.8",
"wp-rocket-scripts": "github:wp-media/rocket-scripts#feature/40-3.19-preload-fonts-beacon-processing-part",
"yargs": "^17.3.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
</head>
<body>
</html>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800,"system_fonts":["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Georgia","Palatino","Garamond","Bookman","Tahoma","Trebuchet MS","Arial Black","Impact","Comic Sans MS"]}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true,"preload_fonts":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800,"system_fonts":["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Georgia","Palatino","Garamond","Bookman","Tahoma","Trebuchet MS","Arial Black","Impact","Comic Sans MS"],"font_data":{"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiAyp8kv8JHgFVrJJLmE0tMMPKhSkFEkm8.woff2":[{"family":"Poppins","weight":"100","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiAyp8kv8JHgFVrJJLmE0tCMPKhSkFE.woff2":[{"family":"Poppins","weight":"100","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLmv1pVGdeOYktMqlap.woff2":[{"family":"Poppins","weight":"200","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLmv1pVF9eOYktMqg.woff2":[{"family":"Poppins","weight":"200","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLm21lVGdeOYktMqlap.woff2":[{"family":"Poppins","weight":"300","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLm21lVF9eOYktMqg.woff2":[{"family":"Poppins","weight":"300","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiEyp8kv8JHgFVrJJLmg1hHGpeKQEk.woff2":[{"family":"Poppins","weight":"400","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiFyp8kv8JHgFVrJJLucHtUFMNEKQ.woff2":[{"family":"Poppins","weight":"500","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrJJLsbX9NE9eO.woff2":[{"family":"Poppins","weight":"600","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrJJLsbXpNE9eO.woff2":[{"family":"Poppins","weight":"900","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrLPTufntAOvWDSHFF.woff2":[{"family":"Poppins","weight":"100","style":"normal","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.cdnfonts.com\/s\/31427\/Paper Sign.woff":[{"family":"Paper Sign","weight":"400","style":"normal","unicodeRange":"U+0000-10FFFF"}]}}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script>

Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ <h1>Iframe Header</h1>
</body>
</html>
" width="600" height="400" style="border:none;"></iframe>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800,"system_fonts":["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Georgia","Palatino","Garamond","Bookman","Tahoma","Trebuchet MS","Arial Black","Impact","Comic Sans MS"]}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script></body>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true,"preload_fonts":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800,"system_fonts":["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Georgia","Palatino","Garamond","Bookman","Tahoma","Trebuchet MS","Arial Black","Impact","Comic Sans MS"],"font_data":{"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiAyp8kv8JHgFVrJJLmE0tMMPKhSkFEkm8.woff2":[{"family":"Poppins","weight":"100","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiAyp8kv8JHgFVrJJLmE0tCMPKhSkFE.woff2":[{"family":"Poppins","weight":"100","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLmv1pVGdeOYktMqlap.woff2":[{"family":"Poppins","weight":"200","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLmv1pVF9eOYktMqg.woff2":[{"family":"Poppins","weight":"200","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLm21lVGdeOYktMqlap.woff2":[{"family":"Poppins","weight":"300","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLm21lVF9eOYktMqg.woff2":[{"family":"Poppins","weight":"300","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiEyp8kv8JHgFVrJJLmg1hHGpeKQEk.woff2":[{"family":"Poppins","weight":"400","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiFyp8kv8JHgFVrJJLucHtUFMNEKQ.woff2":[{"family":"Poppins","weight":"500","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrJJLsbX9NE9eO.woff2":[{"family":"Poppins","weight":"600","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrJJLsbXpNE9eO.woff2":[{"family":"Poppins","weight":"900","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrLPTufntAOvWDSHFF.woff2":[{"family":"Poppins","weight":"100","style":"normal","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.cdnfonts.com\/s\/31427\/Paper Sign.woff":[{"family":"Paper Sign","weight":"400","style":"normal","unicodeRange":"U+0000-10FFFF"}]}}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script></body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<title>Test</title>
</head>
<body>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800,"system_fonts":["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Georgia","Palatino","Garamond","Bookman","Tahoma","Trebuchet MS","Arial Black","Impact","Comic Sans MS"]}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script></body>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true,"preload_fonts":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800,"system_fonts":["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Georgia","Palatino","Garamond","Bookman","Tahoma","Trebuchet MS","Arial Black","Impact","Comic Sans MS"],"font_data":{"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiAyp8kv8JHgFVrJJLmE0tMMPKhSkFEkm8.woff2":[{"family":"Poppins","weight":"100","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiAyp8kv8JHgFVrJJLmE0tCMPKhSkFE.woff2":[{"family":"Poppins","weight":"100","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLmv1pVGdeOYktMqlap.woff2":[{"family":"Poppins","weight":"200","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLmv1pVF9eOYktMqg.woff2":[{"family":"Poppins","weight":"200","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLm21lVGdeOYktMqlap.woff2":[{"family":"Poppins","weight":"300","style":"italic","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiDyp8kv8JHgFVrJJLm21lVF9eOYktMqg.woff2":[{"family":"Poppins","weight":"300","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiEyp8kv8JHgFVrJJLmg1hHGpeKQEk.woff2":[{"family":"Poppins","weight":"400","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiFyp8kv8JHgFVrJJLucHtUFMNEKQ.woff2":[{"family":"Poppins","weight":"500","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrJJLsbX9NE9eO.woff2":[{"family":"Poppins","weight":"600","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrJJLsbXpNE9eO.woff2":[{"family":"Poppins","weight":"900","style":"italic","unicodeRange":"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC\u2026"}],"https:\/\/fonts.gstatic.com\/s\/poppins\/v22\/pxiGyp8kv8JHgFVrLPTufntAOvWDSHFF.woff2":[{"family":"Poppins","weight":"100","style":"normal","unicodeRange":"U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7\u2026"}],"https:\/\/fonts.cdnfonts.com\/s\/31427\/Paper Sign.woff":[{"family":"Paper Sign","weight":"400","style":"normal","unicodeRange":"U+0000-10FFFF"}]}}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script></body>
</html>
Loading
Loading