Skip to content

Commit f9275df

Browse files
Merge branch 'trunk' into 64619-deprecated-wp-updates-l10n
2 parents f00cd1b + 81885a9 commit f9275df

23 files changed

Lines changed: 808 additions & 150 deletions

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@lodder/grunt-postcss": "^3.1.1",
3131
"@playwright/test": "1.56.1",
3232
"@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
33+
"@types/codemirror": "5.60.17",
3334
"@wordpress/e2e-test-utils-playwright": "1.33.2",
3435
"@wordpress/prettier-config": "4.33.1",
3536
"@wordpress/scripts": "30.26.2",
@@ -79,6 +80,7 @@
7980
"core-js-url-browser": "3.6.4",
8081
"csslint": "1.0.5",
8182
"element-closest": "3.0.2",
83+
"espree": "9.6.1",
8284
"esprima": "4.0.1",
8385
"formdata-polyfill": "4.0.10",
8486
"hoverintent": "2.2.1",
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* CodeMirror JavaScript linter.
3+
*
4+
* @since 7.0.0
5+
*/
6+
7+
import CodeMirror from 'codemirror';
8+
9+
/**
10+
* CodeMirror Lint Error.
11+
*
12+
* @see https://codemirror.net/5/doc/manual.html#addon_lint
13+
*
14+
* @typedef {Object} CodeMirrorLintError
15+
* @property {string} message - Error message.
16+
* @property {'error'} severity - Severity.
17+
* @property {CodeMirror.Position} from - From position.
18+
* @property {CodeMirror.Position} to - To position.
19+
*/
20+
21+
/**
22+
* JSHint options supported by Espree.
23+
*
24+
* @see https://jshint.com/docs/options/
25+
* @see https://www.npmjs.com/package/espree#options
26+
*
27+
* @typedef {Object} SupportedJSHintOptions
28+
* @property {number} [esversion] - "This option is used to specify the ECMAScript version to which the code must adhere."
29+
* @property {boolean} [es5] - "This option enables syntax first defined in the ECMAScript 5.1 specification. This includes allowing reserved keywords as object properties."
30+
* @property {boolean} [es3] - "This option tells JSHint that your code needs to adhere to ECMAScript 3 specification. Use this option if you need your program to be executable in older browsers—such as Internet Explorer 6/7/8/9—and other legacy JavaScript environments."
31+
* @property {boolean} [module] - "This option informs JSHint that the input code describes an ECMAScript 6 module. All module code is interpreted as strict mode code."
32+
* @property {'implied'} [strict] - "This option requires the code to run in ECMAScript 5's strict mode."
33+
*/
34+
35+
/**
36+
* Validates JavaScript.
37+
*
38+
* @since 7.0.0
39+
*
40+
* @param {string} text - Source.
41+
* @param {SupportedJSHintOptions} options - Linting options.
42+
* @returns {Promise<CodeMirrorLintError[]>}
43+
*/
44+
async function validator( text, options ) {
45+
const errors = /** @type {CodeMirrorLintError[]} */ [];
46+
try {
47+
const espree = await import( /* webpackIgnore: true */ 'espree' );
48+
espree.parse( text, {
49+
...getEspreeOptions( options ),
50+
loc: true,
51+
} );
52+
} catch ( error ) {
53+
if (
54+
// This is an `EnhancedSyntaxError` in Espree: <https://github.com/brettz9/espree/blob/3c1120280b24f4a5e4c3125305b072fa0dfca22b/packages/espree/lib/espree.js#L48-L54>.
55+
error instanceof SyntaxError &&
56+
typeof error.lineNumber === 'number' &&
57+
typeof error.column === 'number'
58+
) {
59+
const line = error.lineNumber - 1;
60+
errors.push( {
61+
message: error.message,
62+
severity: 'error',
63+
from: CodeMirror.Pos( line, error.column - 1 ),
64+
to: CodeMirror.Pos( line, error.column ),
65+
} );
66+
} else {
67+
console.warn( '[CodeMirror] Unable to lint JavaScript:', error ); // jshint ignore:line
68+
}
69+
}
70+
71+
return errors;
72+
}
73+
74+
CodeMirror.registerHelper( 'lint', 'javascript', validator );
75+
76+
/**
77+
* Gets the options for Espree from the supported JSHint options.
78+
*
79+
* @since 7.0.0
80+
*
81+
* @param {SupportedJSHintOptions} options - Linting options for JSHint.
82+
* @return {{
83+
* ecmaVersion?: number|'latest',
84+
* ecmaFeatures?: {
85+
* impliedStrict?: true
86+
* }
87+
* }}
88+
*/
89+
function getEspreeOptions( options ) {
90+
const ecmaFeatures = {};
91+
if ( options.strict === 'implied' ) {
92+
ecmaFeatures.impliedStrict = true;
93+
}
94+
95+
return {
96+
ecmaVersion: getEcmaVersion( options ),
97+
sourceType: options.module ? 'module' : 'script',
98+
ecmaFeatures,
99+
};
100+
}
101+
102+
/**
103+
* Gets the ECMAScript version.
104+
*
105+
* @since 7.0.0
106+
*
107+
* @param {SupportedJSHintOptions} options - Options.
108+
* @return {number|'latest'} ECMAScript version.
109+
*/
110+
function getEcmaVersion( options ) {
111+
if ( typeof options.esversion === 'number' ) {
112+
return options.esversion;
113+
}
114+
if ( options.es5 ) {
115+
return 5;
116+
}
117+
if ( options.es3 ) {
118+
return 3;
119+
}
120+
return 'latest';
121+
}

src/wp-admin/includes/file.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ function wp_get_plugin_file_editable_extensions( $plugin ) {
202202
'inc',
203203
'include',
204204
'js',
205+
'mjs',
205206
'json',
206207
'jsx',
207208
'less',
@@ -261,6 +262,7 @@ function wp_get_theme_file_editable_extensions( $theme ) {
261262
'inc',
262263
'include',
263264
'js',
265+
'mjs',
264266
'json',
265267
'jsx',
266268
'less',

src/wp-content/themes/twentytwentyone/inc/block-patterns.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ function twenty_twenty_one_register_block_pattern_category() {
2727
add_action( 'init', 'twenty_twenty_one_register_block_pattern_category' );
2828
}
2929

30-
/**
31-
* Register Block Patterns.
32-
*/
3330
if ( function_exists( 'register_block_pattern' ) ) {
3431
/**
35-
* Registers Block Pattern.
32+
* Registers Block Patterns.
3633
*
3734
* @since Twenty Twenty-One 1.0
3835
*

src/wp-includes/block-patterns.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ function _register_core_block_patterns_and_categories() {
7979
'query-grid-posts',
8080
'query-large-title-posts',
8181
'query-offset-posts',
82+
'navigation-overlay',
83+
'navigation-overlay-black-bg',
84+
'navigation-overlay-accent-bg',
85+
'navigation-overlay-centered',
86+
'navigation-overlay-centered-with-extras',
8287
);
8388

8489
foreach ( $core_block_patterns as $core_block_pattern ) {
@@ -228,6 +233,13 @@ function _register_core_block_patterns_and_categories() {
228233
'description' => __( 'A variety of header designs displaying your site title and navigation.' ),
229234
)
230235
);
236+
register_block_pattern_category(
237+
'navigation',
238+
array(
239+
'label' => _x( 'Navigation', 'Block pattern category' ),
240+
'description' => __( 'A variety of designs displaying site navigation.' ),
241+
)
242+
);
231243
}
232244

233245
/**
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Navigation: Overlay with orange background.
4+
*
5+
* @package WordPress
6+
*/
7+
8+
return array(
9+
'title' => _x( 'Overlay with orange background', 'Block pattern title' ),
10+
'blockTypes' => array( 'core/template-part/navigation-overlay' ),
11+
'categories' => array( 'navigation' ),
12+
'content' => '<!-- wp:group {"metadata":{"name":"' . esc_attr( __( 'Navigation Overlay' ) ) . '"},"style":{"spacing":{"padding":{"right":"var:preset|spacing|50","left":"var:preset|spacing|50","top":"var:preset|spacing|50","bottom":"var:preset|spacing|50"}},"color":{"background":"#f57600"},"dimensions":{"minHeight":"100vh"},"elements":{"link":{"color":{"text":"var:preset|color|black"}}}},"textColor":"black","layout":{"type":"grid","columnCount":2,"minimumColumnWidth":"600px","rowCount":2,"isManualPlacement":true}} -->
13+
<div class="wp-block-group has-black-color has-text-color has-background has-link-color" style="background-color:#f57600;min-height:100vh;padding-top:var(--wp--preset--spacing--50);padding-right:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)"><!-- wp:group {"style":{"layout":{"columnStart":1,"rowStart":1}},"layout":{"type":"default"}} -->
14+
<div class="wp-block-group"><!-- wp:navigation-overlay-close {"style":{"layout":{"columnStart":1,"rowStart":1}}} /--></div>
15+
<!-- /wp:group -->
16+
17+
<!-- wp:group {"style":{"typography":{"lineHeight":"0.8"},"layout":{"columnStart":1,"rowStart":2}},"layout":{"type":"flex","orientation":"vertical","verticalAlignment":"bottom"}} -->
18+
<div class="wp-block-group" style="line-height:0.8"><!-- wp:site-title {"fontSize":"large"} /-->
19+
20+
<!-- wp:site-tagline {"style":{"typography":{"lineHeight":"1.2"},"elements":{"link":{"color":{"text":"#000000a6"}}},"color":{"text":"#000000a6"}},"fontSize":"large"} /--></div>
21+
<!-- /wp:group -->
22+
23+
<!-- wp:spacer {"height":"10rem","style":{"layout":{"columnStart":2,"rowStart":2}}} -->
24+
<div style="height:10rem" aria-hidden="true" class="wp-block-spacer"></div>
25+
<!-- /wp:spacer -->
26+
27+
<!-- wp:navigation {"overlayMenu":"never","style":{"typography":{"lineHeight":"1"},"layout":{"columnStart":2,"rowStart":1}},"fontSize":"large","layout":{"type":"flex","orientation":"vertical"}} /--></div>
28+
<!-- /wp:group -->',
29+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Navigation: Overlay with black background.
4+
*
5+
* @package WordPress
6+
*/
7+
8+
return array(
9+
'title' => _x( 'Overlay with black background', 'Block pattern title' ),
10+
'blockTypes' => array( 'core/template-part/navigation-overlay' ),
11+
'categories' => array( 'navigation' ),
12+
'content' => '<!-- wp:group {"metadata":{"name":"' . esc_attr( __( 'Navigation Overlay' ) ) . '"},"style":{"spacing":{"padding":{"right":"var:preset|spacing|40","left":"var:preset|spacing|40","top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}},"dimensions":{"minHeight":"100vh"},"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"color":{"background":"#000000"}},"textColor":"white","layout":{"type":"default"}} -->
13+
<div class="wp-block-group has-white-color has-text-color has-background has-link-color" style="background-color:#000000;min-height:100vh;padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)"><!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}}},"layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between","verticalAlignment":"top"}} -->
14+
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:navigation {"style":{"typography":{"lineHeight":"1"}},"fontSize":"xx-large","layout":{"type":"flex","orientation":"vertical"}} /-->
15+
16+
<!-- wp:navigation-overlay-close {"displayMode":"text","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"spacing":{"padding":{"top":"0","bottom":"0","left":"0","right":"0"}}},"textColor":"white"} /--></div>
17+
<!-- /wp:group --></div>
18+
<!-- /wp:group -->',
19+
);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Navigation: Overlay with site info and CTA.
4+
*
5+
* @package WordPress
6+
*/
7+
8+
return array(
9+
'title' => _x( 'Overlay with site info and CTA', 'Block pattern title' ),
10+
'blockTypes' => array( 'core/template-part/navigation-overlay' ),
11+
'categories' => array( 'navigation' ),
12+
'content' => '<!-- wp:group {"metadata":{"name":"' . esc_attr( __( 'Navigation Overlay' ) ) . '"},"style":{"spacing":{"padding":{"right":"var:preset|spacing|40","left":"var:preset|spacing|40","top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}},"dimensions":{"minHeight":"100vh"},"elements":{"link":{"color":{"text":"var:preset|color|black"}}},"backgroundColor":"white","textColor":"black","layout":{"type":"default"}} -->
13+
<div class="wp-block-group has-black-color has-white-background-color has-text-color has-background has-link-color" style="min-height:100vh;padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)"><!-- wp:group {"align":"wide","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"right"}} -->
14+
<div class="wp-block-group alignwide"><!-- wp:navigation-overlay-close /--></div>
15+
<!-- /wp:group -->
16+
17+
<!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
18+
<div class="wp-block-group alignwide"><!-- wp:site-logo {"width":80,"isLink":false,"align":"center","className":"is-style-rounded"} /-->
19+
20+
<!-- wp:site-title {"textAlign":"center","fontSize":"large"} /-->
21+
22+
<!-- wp:site-tagline {"textAlign":"center","fontSize":"medium"} /-->
23+
24+
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50"}}},"layout":{"type":"constrained"}} -->
25+
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--50)"><!-- wp:navigation {"overlayMenu":"never","style":{"typography":{"textTransform":"uppercase"}},"fontSize":"x-large","layout":{"type":"flex","orientation":"vertical","justifyContent":"center"}} /--></div>
26+
<!-- /wp:group -->
27+
28+
<!-- wp:group {"align":"full","style":{"border":{"top":{"color":"#eeeeee","width":"1px"}},"spacing":{"padding":{"top":"var:preset|spacing|60","bottom":"var:preset|spacing|60"}}},"layout":{"type":"constrained"}} -->
29+
<div class="wp-block-group alignfull" style="border-top-color:#eeeeee;border-top-width:1px;padding-top:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60)"><!-- wp:paragraph {"style":{"typography":{"textAlign":"center"}}} -->
30+
<p class="has-text-align-center">' . esc_html( __( 'Find out how we can help your business.' ) ) . ' <a href="#">' . esc_html( __( 'Learn more' ) ) . '</a></p>
31+
<!-- /wp:paragraph -->
32+
33+
<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
34+
<div class="wp-block-buttons"><!-- wp:button {"style":{"typography":{"textTransform":"uppercase"}}} -->
35+
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="text-transform:uppercase">' . esc_html( __( 'Get started today!' ) ) . '</a></div>
36+
<!-- /wp:button -->
37+
38+
<!-- wp:button -->
39+
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button"></a></div>
40+
<!-- /wp:button --></div>
41+
<!-- /wp:buttons --></div>
42+
<!-- /wp:group --></div>
43+
<!-- /wp:group --></div>
44+
<!-- /wp:group -->',
45+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Navigation: Overlay with centered navigation.
4+
*
5+
* @package WordPress
6+
*/
7+
8+
return array(
9+
'title' => _x( 'Overlay with centered navigation', 'Block pattern title' ),
10+
'blockTypes' => array( 'core/template-part/navigation-overlay' ),
11+
'categories' => array( 'navigation' ),
12+
'content' => '<!-- wp:group {"metadata":{"name":"' . esc_attr( __( 'Navigation Overlay' ) ) . '"},"style":{"spacing":{"padding":{"right":"var:preset|spacing|40","left":"var:preset|spacing|40","top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}},"dimensions":{"minHeight":"100vh"},"elements":{"link":{"color":{"text":"var:preset|color|black"}}},"color":{"background":"#eeeeee"}},"textColor":"black","layout":{"type":"default"}} -->
13+
<div class="wp-block-group has-black-color has-text-color has-background has-link-color" style="background-color:#eeeeee;min-height:100vh;padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)"><!-- wp:group {"align":"wide","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"right"}} -->
14+
<div class="wp-block-group alignwide"><!-- wp:navigation-overlay-close /--></div>
15+
<!-- /wp:group -->
16+
17+
<!-- wp:group {"align":"wide","style":{"dimensions":{"minHeight":"90vh"}},"layout":{"type":"flex","orientation":"vertical","justifyContent":"center","verticalAlignment":"center"}} -->
18+
<div class="wp-block-group alignwide" style="min-height:90vh"><!-- wp:navigation {"layout":{"type":"flex","orientation":"vertical","justifyContent":"center"}} /--></div>
19+
<!-- /wp:group --></div>
20+
<!-- /wp:group -->',
21+
);

0 commit comments

Comments
 (0)