Skip to content

Instantly share code, notes, and snippets.

@wpgaurav
Created August 30, 2022 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpgaurav/80725644a07bd49143691e5b4597986f to your computer and use it in GitHub Desktop.
Save wpgaurav/80725644a07bd49143691e5b4597986f to your computer and use it in GitHub Desktop.
Enhance WordPress Blocks with custom styles.
<?php add_action('init', function() {
register_block_style('core/pullquote', [
'name' => 'smaller',
'label' => __('Small', 'md'),
'inline_style' => '.wp-block-pullquote.is-style-smaller blockquote{font-size:18px!important}'
]);
register_block_style('core/quote', [
'name' => 'minimal',
'label' => __('Minimal', 'md'),
'inline_style' => '.wp-block-quote.is-style-minimal{font-size: 18px; padding: 2em; border-left:8px solid #c0392b; box-shadow: 1px 2px 9px 0px rgb(153 153 153 / 33%); line-height:1.9em}'
]);
register_block_style('core/paragraph', [
'name' => 'note',
'label' => __('Note', 'md'),
'inline_style' => '.is-style-note{background: #fff6c8; border: 2px solid #333; border-radius: 10px; padding:1em}'
]);
register_block_style('core/paragraph', [
'name' => 'notice',
'label' => __('Notice', 'md'),
'inline_style' => '.is-style-notice{background-color: #fff8f0; border: 1px solid #ddd!important; border-radius: 4px; padding: 15px;}'
]);
register_block_style('core/paragraph', [
'name' => 'minimal',
'label' => __('Minimal', 'md'),
'inline_style' => ', .is-style-minimal, p.is-style-minimal{font-size: 18px; padding: 2em; border-left:8px solid #c0392b; box-shadow: 1px 2px 9px 0px rgb(153 153 153 / 33%);}'
]);
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment