Created
August 5, 2020 19:08
-
-
Save alexmustin/b412d660fba92f25a55677fd23acd207 to your computer and use it in GitHub Desktop.
WP - Add block style variations
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
jQuery(document).ready(function($) { | |
// Add 'Semibold' style to Paragraph blocks | |
wp.blocks.registerBlockStyle("core/paragraph", { | |
name: "semibold", | |
label: "Semibold" | |
}); | |
// Add 'Black' style to Paragraph blocks | |
wp.blocks.registerBlockStyle("core/paragraph", { | |
name: "weightblack", | |
label: "Black" | |
}); | |
}); |
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
p.is-style-semibold { | |
font-weight: 600 !important; | |
} | |
p.is-style-weightblack { | |
font-weight: 800 !important; | |
} |
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
<?php | |
// Enqueue the variations JS. | |
add_action( 'enqueue_block_editor_assets', 'block_editor_variations_js' ); | |
function block_editor_variations_js() { | |
wp_enqueue_script( 'blockstylevariations-js', get_stylesheet_directory_uri() . '/js/block-style-variations.js', array( 'jquery' ), '1.0', true ); | |
} | |
// Enqueue custom Block Styles. | |
add_action( 'enqueue_block_assets', 'custom_block_styles_css' ); | |
function custom_block_styles_css() { | |
wp_enqueue_style( 'custom-block-styles', get_stylesheet_directory_uri() . '/css/custom-block-styles.css' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment