Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Merge branch 'fix/buttons-block-appender' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
admturner committed May 6, 2024
2 parents b48f7c3 + 91025e2 commit 90c8383
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion inc/asset-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function (): void {
);

if ( $current_screen instanceof \WP_Screen && $current_screen->is_block_editor() ) {
wp_enqueue_style(
wp_enqueue_style(
'hrswds-global-editor-style',
get_template_directory_uri() . '/build/index.css',
array(),
Expand Down
22 changes: 21 additions & 1 deletion src/block-library/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { registerBlockStyle, registerBlockType } from '@wordpress/blocks';
import { addFilter } from '@wordpress/hooks';
import { dispatch } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -21,11 +22,22 @@ import * as table from './table';

/**
* Blocks to register
*
* @type {Object[]}
*/
const blocks = [ logoLockup, svgSelector ];

/**
* Blocks to show
*
* @type {string[]}
*/
const showBlocks = [ 'core/button', 'core/buttons' ];

/**
* Blocks to register styles for
*
* @type {Object[]}
*/
const blockStyles = [
button,
Expand All @@ -41,6 +53,8 @@ const blockStyles = [

/**
* Blocks to filter
*
* @type {Object[]}
*/
const blockFilters = [ spacer ];

Expand Down Expand Up @@ -92,7 +106,6 @@ const addBlockFilter = ( block ) => {

/**
* Function to register blocks.
*
*/
export const registerBlocks = () => {
blocks.forEach( registerBlock );
Expand All @@ -111,3 +124,10 @@ export const registerStyles = () => {
export const addBlockFilters = () => {
blockFilters.forEach( addBlockFilter );
};

/**
* Update the provided block types to be visible.
*/
export const showEditorBlocks = () => {
dispatch( 'core/edit-post' ).showBlockTypes( showBlocks );
};
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {
registerBlocks,
registerStyles,
addBlockFilters,
showEditorBlocks,
} from './block-library';
import './style.css';
import './editor.css';

registerBlocks();
registerStyles();
addBlockFilters();
showEditorBlocks();

0 comments on commit 90c8383

Please sign in to comment.