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

Allow filtering for global styles #25499

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 20 additions & 3 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function gutenberg_experimental_global_styles_get_support_keys() {
* @return array Presets structure
*/
function gutenberg_experimental_global_styles_get_presets_structure() {
return array(
$structure = array(
'color' => array(
'path' => array( 'color', 'palette' ),
'key' => 'color',
Expand All @@ -446,6 +446,13 @@ function gutenberg_experimental_global_styles_get_presets_structure() {
'key' => 'size',
),
);

/**
* Filter the global styles presets structure.
*
* @param array $structure The structure array.
*/
return apply_filters( 'global_styles_get_presets_structure', $structure );
}

/**
Expand Down Expand Up @@ -552,7 +559,12 @@ function gutenberg_experimental_global_styles_get_block_data() {
}
}

return $block_data;
/**
* Filter the global styles array for blocks.
*
* @param array $block_data The block-data array.
*/
return apply_filters( 'global_styles_get_block_data', $block_data );
}

/**
Expand Down Expand Up @@ -644,7 +656,12 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree ) {
$stylesheet .= 'a{color:var(--wp--style--color--link, #00e);}';
}

return $stylesheet;
/**
* Filter the generated styles.
*
* @param string $stylesheet The generated CSS.
*/
return apply_filters( 'global_styles_get_stylesheet', $stylesheet );
}

/**
Expand Down