PluginProbe
wpForo Forum / 3.1.4
wpForo Forum v3.1.4
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / blocks / forums / index.js

index.js in wpForo Forum 3.1.4, at blocks/forums/index.js

72 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function (blocks, editor, components, i18n, element) {
2 var el = element.createElement;
3 var Fragment = element.Fragment;
4 var __ = i18n.__;
5 var InspectorControls = editor.InspectorControls;
6 var useBlockProps = editor.useBlockProps;
7 var PanelBody = components.PanelBody;
8 var TextControl = components.TextControl;
9 var ToggleControl = components.ToggleControl;
10 var SelectControl = components.SelectControl;
11
12 blocks.registerBlockType('wpforo/forums', {
13 title: __('wpForo Forums', 'wpforo'),
14 icon: 'admin-comments',
15 category: 'widgets',
16 edit: function (props) {
17 var attributes = props.attributes;
18 var setAttributes = props.setAttributes;
19 var blockProps = useBlockProps();
20
21 var boards = window.wpforo_block_data ? window.wpforo_block_data.boards : [];
22 var boardOptions = boards.map(function (board) {
23 return { value: board.boardid, label: board.title };
24 });
25
26 return el(Fragment, null,
27 el(InspectorControls, { key: 'inspector' },
28 el(PanelBody, { title: __('Settings', 'wpforo') },
29 el(TextControl, {
30 label: __('Title', 'wpforo'),
31 value: attributes.title,
32 onChange: function (value) {
33 setAttributes({ title: value });
34 },
35 }),
36 el(SelectControl, {
37 label: __('Board', 'wpforo'),
38 value: attributes.boardid,
39 options: boardOptions,
40 onChange: function (value) {
41 setAttributes({ boardid: parseInt(value) });
42 },
43 }),
44 el(ToggleControl, {
45 label: __('Display as dropdown', 'wpforo'),
46 checked: attributes.dropdown,
47 onChange: function (value) {
48 setAttributes({ dropdown: value });
49 },
50 }),
51 ),
52 ),
53 el('div', blockProps,
54 el('div', { className: 'wpf-block-placeholder' },
55 el('span', { className: 'dashicons dashicons-admin-comments' }),
56 __('wpForo Forums', 'wpforo'),
57 ),
58 ),
59 );
60 },
61 save: function () {
62 return null;
63 },
64 });
65 })(
66 window.wp.blocks,
67 window.wp.blockEditor,
68 window.wp.components,
69 window.wp.i18n,
70 window.wp.element,
71 );
72