Skip to content

Commit faa2a2b

Browse files
oandregalMamaduka
authored andcommitted
Allow child classes to override the WP_Theme_JSON_Resolver_Gutenberg and VALID_TOP_LEVEL_KEYS (#38625)
1 parent 51a9cb7 commit faa2a2b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/compat/wordpress-5.9/class-wp-theme-json-gutenberg.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class WP_Theme_JSON_Gutenberg {
2121
*
2222
* @var array
2323
*/
24-
private $theme_json = null;
24+
protected $theme_json = null;
2525

2626
/**
2727
* Holds block metadata extracted from block.json
@@ -426,7 +426,7 @@ private static function sanitize( $input, $valid_block_names, $valid_element_nam
426426
return $output;
427427
}
428428

429-
$output = array_intersect_key( $input, array_flip( self::VALID_TOP_LEVEL_KEYS ) );
429+
$output = array_intersect_key( $input, array_flip( static::VALID_TOP_LEVEL_KEYS ) );
430430

431431
// Some styles are only meant to be available at the top-level (e.g.: blockGap),
432432
// hence, the schema for blocks & elements should not have them.

lib/compat/wordpress-5.9/class-wp-theme-json-resolver-gutenberg.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,43 @@ class WP_Theme_JSON_Resolver_Gutenberg {
2222
*
2323
* @var WP_Theme_JSON_Gutenberg
2424
*/
25-
private static $core = null;
25+
protected static $core = null;
2626

2727
/**
2828
* Container for data coming from the theme.
2929
*
3030
* @var WP_Theme_JSON_Gutenberg
3131
*/
32-
private static $theme = null;
32+
protected static $theme = null;
3333

3434
/**
3535
* Whether or not the theme supports theme.json.
3636
*
3737
* @var bool
3838
*/
39-
private static $theme_has_support = null;
39+
protected static $theme_has_support = null;
4040

4141
/**
4242
* Container for data coming from the user.
4343
*
4444
* @var WP_Theme_JSON_Gutenberg
4545
*/
46-
private static $user = null;
46+
protected static $user = null;
4747

4848
/**
4949
* Stores the ID of the custom post type
5050
* that holds the user data.
5151
*
5252
* @var integer
5353
*/
54-
private static $user_custom_post_type_id = null;
54+
protected static $user_custom_post_type_id = null;
5555

5656
/**
5757
* Container to keep loaded i18n schema for `theme.json`.
5858
*
5959
* @var array
6060
*/
61-
private static $i18n_schema = null;
61+
protected static $i18n_schema = null;
6262

6363
/**
6464
* Processes a file that adheres to the theme.json
@@ -68,7 +68,7 @@ class WP_Theme_JSON_Resolver_Gutenberg {
6868
* @param string $file_path Path to file. Empty if no file.
6969
* @return array Contents that adhere to the theme.json schema.
7070
*/
71-
private static function read_json_file( $file_path ) {
71+
protected static function read_json_file( $file_path ) {
7272
$config = array();
7373
if ( $file_path ) {
7474
$decoded_file = wp_json_file_decode( $file_path, array( 'associative' => true ) );
@@ -100,7 +100,7 @@ public static function get_fields_to_translate() {
100100
* Default 'default'.
101101
* @return array Returns the modified $theme_json_structure.
102102
*/
103-
private static function translate( $theme_json, $domain = 'default' ) {
103+
protected static function translate( $theme_json, $domain = 'default' ) {
104104
if ( null === self::$i18n_schema ) {
105105
$i18n_schema = wp_json_file_decode( __DIR__ . '/theme-i18n.json' );
106106
self::$i18n_schema = null === $i18n_schema ? array() : $i18n_schema;
@@ -388,7 +388,7 @@ public static function theme_has_support() {
388388
* @param bool $template Optional. Use template theme directory. Default false.
389389
* @return string The whole file path or empty if the file doesn't exist.
390390
*/
391-
private static function get_file_path_from_theme( $file_name, $template = false ) {
391+
protected static function get_file_path_from_theme( $file_name, $template = false ) {
392392
$path = $template ? get_template_directory() : get_stylesheet_directory();
393393
$candidate = $path . '/' . $file_name;
394394

0 commit comments

Comments
 (0)