Skip to content

Commit

Permalink
Archives block: use block.json. (#21775)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill authored Apr 22, 2020
1 parent 0e75729 commit 9002eb1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
21 changes: 21 additions & 0 deletions packages/block-library/src/archives/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "core/archives",
"category": "widgets",
"attributes": {
"align": {
"type": "string",
"enum": [ "left", "center", "right", "wide", "full" ]
},
"className": {
"type": "string"
},
"displayAsDropdown": {
"type": "boolean",
"default": false
},
"showPostCounts": {
"type": "boolean",
"default": false
}
}
}
8 changes: 5 additions & 3 deletions packages/block-library/src/archives/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { archive as icon } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import metadata from './block.json';
import edit from './edit';

export const name = 'core/archives';
const { name } = metadata;

export { metadata, name };

export const settings = {
title: __( 'Archives' ),
description: __( 'Display a monthly archive of your posts.' ),
icon,
category: 'widgets',
supports: {
align: true,
html: false,
Expand Down
21 changes: 2 additions & 19 deletions packages/block-library/src/archives/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,9 @@ function render_block_core_archives( $attributes ) {
* Register archives block.
*/
function register_block_core_archives() {
register_block_type(
'core/archives',
register_block_type_from_metadata(
__DIR__ . '/archives',
array(
'attributes' => array(
'align' => array(
'type' => 'string',
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
),
'className' => array(
'type' => 'string',
),
'displayAsDropdown' => array(
'type' => 'boolean',
'default' => false,
),
'showPostCounts' => array(
'type' => 'boolean',
'default' => false,
),
),
'render_callback' => 'render_block_core_archives',
)
);
Expand Down

0 comments on commit 9002eb1

Please sign in to comment.