PluginProbe
Friends / 2.8.1
Friends v2.8.1
4.3.2 4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 All 88 releases
friends / blocks / friend-posts / src / index.js

index.js in Friends 2.8.1, at blocks/friend-posts/src/index.js

75 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { registerBlockType } from '@wordpress/blocks';
3 import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
4 import { CheckboxControl, PanelBody, RangeControl, SelectControl, TextControl } from '@wordpress/components';
5 import ServerSideRender from '@wordpress/server-side-render';
6
7 registerBlockType( 'friends/friend-posts', {
8 apiVersion: 2,
9 edit: function( { attributes, setAttributes } ) {
10 const blockProps = useBlockProps();
11 return (
12 <>
13 <InspectorControls>
14 <PanelBody>
15 <CheckboxControl
16 label={ __( 'Display Author name', 'friends' ) }
17 checked={ attributes.author_name }
18 onChange={ author_name => setAttributes( { author_name } ) }
19 />
20 <CheckboxControl
21 label={ __( 'Display Author avatar', 'friends' ) }
22 checked={ attributes.author_avatar }
23 onChange={ author_avatar => setAttributes( { author_avatar } ) }
24 />
25 <CheckboxControl
26 label={ __( 'Show Author inline', 'friends' ) }
27 checked={ attributes.author_inline }
28 onChange={ author_inline => setAttributes( { author_inline } ) }
29 />
30 <CheckboxControl
31 label={ __( 'Show Date', 'friends' ) }
32 checked={ attributes.show_date }
33 onChange={ show_date => setAttributes( { show_date } ) }
34 />
35 <RangeControl
36 label={ __( 'Number of posts', 'friends' ) }
37 value={ attributes.count }
38 onChange={ count => setAttributes( { count } ) }
39 min={ 1 }
40 max={ 100 }
41 />
42 <TextControl
43 label={ __( 'Exclude these users', 'friends' ) }
44 placeholder={ __( 'space and/or comma separated', 'friends' ) }
45 value={ attributes.exclude_users }
46 onChange={ exclude_users => setAttributes( { exclude_users } ) }
47 />
48 <TextControl
49 label={ __( 'Only these users', 'friends' ) }
50 placeholder={ __( 'space and/or comma separated', 'friends' ) }
51 value={ attributes.only_users }
52 onChange={ only_users => setAttributes( { only_users } ) }
53 />
54 <CheckboxControl
55 label={ __( 'Link to local page', 'friends' ) }
56 checked={ attributes.internal_link }
57 onChange={ internal_link => setAttributes( { internal_link } ) }
58 />
59 </PanelBody>
60 </InspectorControls>
61 <div {...blockProps}>
62 <ServerSideRender
63 block="friends/friend-posts"
64 attributes={ attributes }
65 />
66 </div>
67 </>
68 );
69 },
70
71 save() {
72 return null;
73 },
74 } );
75