move block properties to PHP as attribute default values are not known to backend otherwise
This commit is contained in:
parent
54807da6fe
commit
3cbe31434d
|
@ -2,8 +2,8 @@
|
|||
import { loadEventList } from '../../events-loader.js'
|
||||
|
||||
const { InspectorControls, useBlockProps } = wp.blockEditor
|
||||
const { useEffect } = wp.element
|
||||
const { PanelBody } = wp.components
|
||||
const { useEffect } = wp.element
|
||||
const { __ } = wp.i18n
|
||||
|
||||
const NAME = '<wordpress-name>'
|
||||
|
|
|
@ -1,30 +1,7 @@
|
|||
import edit from './edit.js'
|
||||
|
||||
const { registerBlockType } = wp.blocks
|
||||
const { __ } = wp.i18n
|
||||
|
||||
const NAME = '<wordpress-name>'
|
||||
|
||||
registerBlockType(NAME + '/events-list', {
|
||||
apiVersion: 2,
|
||||
title: __('Events List', '<wordpress-name>'),
|
||||
description: __(
|
||||
'A list of the upcoming events of the connected Mobilizon instance.',
|
||||
'<wordpress-name>'
|
||||
),
|
||||
icon: 'list-view',
|
||||
category: 'widgets',
|
||||
attributes: {
|
||||
eventsCount: {
|
||||
type: 'number',
|
||||
default: 3,
|
||||
},
|
||||
groupName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
supports: {
|
||||
html: false,
|
||||
},
|
||||
edit,
|
||||
})
|
||||
registerBlockType(NAME + '/events-list', { edit })
|
||||
|
|
|
@ -19,6 +19,22 @@ class EventsListBlock {
|
|||
]);
|
||||
register_block_type(NAME . '/events-list', [
|
||||
'api_version' => 2,
|
||||
'title' => __('Events List', 'connector-mobilizon'),
|
||||
'description' => __('A list of the upcoming events of the connected Mobilizon instance.', 'connector-mobilizon'),
|
||||
'category' => 'widgets',
|
||||
'icon' => 'list-view',
|
||||
'supports' => [
|
||||
'html' => false
|
||||
],
|
||||
'attributes' => [
|
||||
'eventsCount' => [
|
||||
'type' => 'number',
|
||||
'default' => 3,
|
||||
],
|
||||
'groupName' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
],
|
||||
'editor_script' => $scriptName,
|
||||
'render_callback' => 'MobilizonConnector\EventsListBlock::render',
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue