-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skeleton for filtering theme.json for classic themes at all layers
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
lib/compat/wordpress-6.1/hook-theme-json-for-classic-themes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
function theme_json_current_theme_has_support( ){ | ||
return WP_Theme_JSON_Gutenberg::has_theme_support(); | ||
} | ||
|
||
function theme_json_default_filter_for_classic_themes( $theme_json_data ) { | ||
if ( theme_json_current_theme_has_support() ) { | ||
$new_data = array( | ||
'version' => 2, | ||
'settings' => array( /* we should maintain the presets by core */ ), | ||
'styles' => array( /* clear this? add only the base-layout-styles? */ ), | ||
); | ||
$theme_json_data->update_with( $new_data ); | ||
} | ||
return $theme_json_data; | ||
} | ||
add_filter( 'theme_json_default', 'theme_json_default_filter_for_classic_themes'); | ||
|
||
function theme_json_blocks_filter_for_classic_themes( $theme_json_data ) { | ||
if ( theme_json_current_theme_has_support() ) { | ||
$new_data = array( | ||
'version' => 2, | ||
'settings' => array(), | ||
'styles' => array( /* add button styles for classic here */ ), | ||
); | ||
$theme_json_data->update_with( $new_data ); | ||
} | ||
return $theme_json_data; | ||
} | ||
add_filter( 'theme_json_blocks', 'theme_json_blocks_filter_for_classic_themes' ); | ||
|
||
function theme_json_reset_for_classic_themes( $theme_json_data ) { | ||
if ( theme_json_current_theme_has_support() ) { | ||
$new_data = array( | ||
'version' => 2, | ||
'settings' => array(), | ||
'styles' => array(), | ||
); | ||
$theme_json_data->update_with( $new_data ); | ||
} | ||
|
||
return $theme_json_data; | ||
} | ||
add_filter( 'theme_json_theme', 'theme_json_reset_for_classic_themes' ); | ||
add_filter( 'theme_json_user', 'theme_json_reset_for_classic_themes' ); |