PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.16.3
GiveWP – Donation Plugin and Fundraising Platform v4.16.3
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / blocks / donor-wall / edit / inspector.js
give / blocks / donor-wall / edit Last commit date
block.js 4 years ago inspector.js 2 years ago style.scss 2 years ago
inspector.js
285 lines
1 /**
2 * WordPress dependencies
3 */
4 import { __ } from '@wordpress/i18n'
5
6 import {InspectorControls, ColorPalette,} from '@wordpress/block-editor';
7 import {PanelBody, Panel, SelectControl, ToggleControl, TextControl, FormTokenField } from '@wordpress/components';
8
9 /**
10 * Internal dependencies
11 */
12 import giveDonorWallOptions from '../data/options';
13
14 import ColumnSelector from '../../components/column-selector';
15 import ToggleOptions from '../../components/toggle';
16
17 import './style.scss'
18 import Toggle from "../../components/toggle";
19
20 /**
21 * Render Inspector Controls
22 */
23
24 const Inspector = ( { attributes, setAttributes } ) => {
25
26 const { donorsPerPage,
27 ids,
28 formID,
29 categories,
30 tags, orderBy,
31 order,
32 columns,
33 avatarSize,
34 showAvatar,
35 showName,
36 showCompanyName,
37 onlyComments,
38 showForm,
39 showTotal,
40 showComments,
41 showAnonymous,
42 commentLength, readMoreText,
43 loadMoreText,
44 toggleOptions,
45 filterOptions,
46 color,
47 showTimestamp,
48 showTributes } = attributes;
49
50 const saveSetting = ( name, value ) => {
51 setAttributes( {
52 [ name ]: value,
53 } );
54 };
55
56 const getAsArray = value => {
57 if (Array.isArray(value)) {
58 return value;
59 }
60
61 // Backward compatibility
62 if (formIDs.indexOf(',')) {
63 return value.split(',');
64 }
65
66 return [value];
67 };
68
69 const filterValue = () => {
70 if(filterOptions === 'categories'){
71 return <> <FormTokenField
72 className="give-donor-wall-inspector"
73 onChange ={(value) => saveSetting('categories', value)}
74 value={getAsArray(categories)}/>
75 <p className="components-form-token-field__help">
76 {__('Type the name of your category to add it to the list. Only forms within the categories you choose will be displayed in this grid.', 'give')}
77 </p>
78 </>
79
80 } else if (filterOptions === 'tags'){
81 return <> <FormTokenField
82 className="give-donor-wall-inspector"
83 name="tags"
84 value={getAsArray(tags)}
85 onChange ={(value) => saveSetting('tags', value)}/>
86 <p className="components-form-token-field__help">
87 {__('Type the name of your tag to add it to the list. Only forms with these tags you choose will be displayed in this grid.', 'give')}
88 </p>
89 </>
90
91 } else if (filterOptions === 'ids'){
92 return <> <FormTokenField
93 className="give-donor-wall-inspector"
94 name="ids"
95 value={getAsArray(ids)}
96 onChange ={(value) => saveSetting('ids', value)}/>
97 <p className="components-form-token-field__help">
98 {__('By default, all donors will display. Use this setting to restrict the donor wall to only display certain donors. Use a comma-separated list of donor IDs.', 'give')}
99 </p>
100 </>
101
102 } else if (filterOptions === 'formID' ){
103 return <> <FormTokenField
104 className="give-donor-wall-inspector"
105 help={__('By Default, donations to all forms will display. Use this setting to restrict the donor to display only donations to certains forms. Use a comma-separated list of form IDs.', 'give')}
106 name="formID"
107 value={getAsArray(formID)}
108 onChange ={(value) => saveSetting('formID', value)}/>
109 <p className="components-form-token-field__help">
110 {__('Type the ID of your form to add it to the list. Only forms with these IDs you choose will be displayed in this grid.', 'give')}
111 </p>
112 </>
113 }
114 };
115 return (
116 <InspectorControls key="inspector">
117 <Panel>
118 <PanelBody title= {__('Layout', 'give')} initialOpen={ true }>
119 <ColumnSelector
120 selected={columns}
121 onClick={(value) => saveSetting('columns', value)}
122 help={__('Controls how many columns of the Form Grid appear. All sizes will adjust responsively to the space available. The maximum number allowed per row is 4', 'give')}
123 />
124 <SelectControl
125 className="give-donor-wall-inspector"
126 name="columns"
127 label={ __( 'Columns', 'give' ) }
128 value={ columns }
129 options={ giveDonorWallOptions.columns }
130 onChange={ ( value ) => saveSetting( 'columns', value ) } />
131 </PanelBody>
132 </Panel>
133 <Panel>
134 <PanelBody title= {__('Display Elements', 'give')} initialOpen={ false }>
135 <ToggleOptions
136 options={giveDonorWallOptions.toggleOptions}
137 onClick={( value ) => saveSetting( 'toggleOptions', value ) }
138 selected={toggleOptions}/>
139 {toggleOptions === 'donorInfo' ?
140 <>
141 <ToggleControl
142 className="give-donor-wall-inspector"
143 name="showName"
144 label={ __( 'Show Name', 'give' ) }
145 checked={ !! showName }
146 onChange={ ( value ) => saveSetting( 'showName', value ) } />
147 <ToggleControl
148 className="give-donor-wall-inspector"
149 name="showName"
150 label={ __( 'Show Company Name', 'give' ) }
151 checked={ !! showCompanyName }
152 onChange={ ( value ) => saveSetting( 'showCompanyName', value ) } />
153 <ToggleControl
154 className="give-donor-wall-inspector"
155 name="showAnonymous"
156 label={ __( 'Show Anonymous', 'give' ) }
157 checked={ !! showAnonymous }
158 onChange={ ( value ) => saveSetting( 'showAnonymous', value ) } />
159 <ToggleControl
160 className="give-donor-wall-inspector"
161 name="showAvatar"
162 label={ __( 'Show Avatar', 'give' ) }
163 checked={ !! showAvatar }
164 onChange={ ( value ) => saveSetting( 'showAvatar', value ) } />
165 <TextControl
166 className="give-donor-wall-inspector"
167 name="avatarSize"
168 label={ __( 'Avatar Size', 'give' ) }
169 help={__('Avatar size. Default height is 75. Accepts valid heights in px.', 'give')}
170 value={ avatarSize }
171 onChange={ ( value ) => saveSetting( 'avatarSize', value ) } />
172 </> :
173 <>
174 <ToggleControl
175 className="give-donor-wall-inspector"
176 name="showForm"
177 label={ __( 'Show Donation Form', 'give' ) }
178 checked={ !! showForm }
179 onChange={ ( value ) => saveSetting( 'showForm', value ) } />
180 <ToggleControl
181 className="give-donor-wall-inspector"
182 name="showTotal"
183 label={ __( 'Show Total', 'give' ) }
184 checked={ !! showTotal }
185 onChange={ ( value ) => saveSetting( 'showTotal', value ) } />
186 <ToggleControl
187 className="give-donor-wall-inspector"
188 name="showTimestamp"
189 label={ __( 'Show Time', 'give' ) }
190 checked={ !! showTimestamp }
191 onChange={ ( value ) => saveSetting( 'showTimestamp', value ) } />
192 { !!window.Give_Tribute && <ToggleControl
193 className="give-donor-wall-inspector"
194 name="showTributes"
195 label={ __( 'Show Tributes', 'give' ) }
196 checked={ !! showTributes }
197 onChange={ ( value ) => saveSetting( 'showTributes', value ) } />}
198 <ToggleControl
199 className="give-donor-wall-inspector"
200 name="showComments"
201 label={ __( 'Show Comments', 'give' ) }
202 checked={ !! showComments }
203 onChange={ ( value ) => saveSetting( 'showComments', value ) } />
204 <ToggleControl
205 className="give-donor-wall-inspector"
206 name="onlyComments"
207 label={ __( 'Only Comments', 'give' ) }
208 checked={ !! onlyComments }
209 onChange={ ( value ) => saveSetting( 'onlyComments', value ) } />
210 <TextControl
211 className="give-donor-wall-inspector"
212 name="commentLength"
213 label={ __( 'Comment Length', 'give' ) }
214 help={__('Limits the amount of characters to be displayed on donations with comments.', 'give')}
215 value={ commentLength }
216 onChange={ ( value ) => saveSetting( 'commentLength', value ) } />
217 <TextControl
218 className="give-donor-wall-inspector"
219 name="readMoreText"
220 label={ __( 'Read More Text', 'give' ) }
221 value={ readMoreText }
222 onChange={ ( value ) => saveSetting( 'readMoreText', value ) } />
223 </>
224 }
225 </PanelBody>
226 </Panel>
227 <Panel>
228 <PanelBody className="give-wall--wall-settings" title= {__('Wall Settings', 'give')} initialOpen={ false }>
229 <SelectControl
230 className="give-donor-wall-inspector"
231 label={ __( 'Sort By', 'give' ) }
232 name="orderBy"
233 value={ orderBy }
234 options={ giveDonorWallOptions.orderBy }
235 onChange={ ( value ) => saveSetting( 'orderBy', value ) } />
236 <SelectControl
237 className="give-donor-wall-inspector"
238 label={ __( 'Order', 'give' ) }
239 name="order"
240 value={ order }
241 options={ giveDonorWallOptions.order }
242 onChange={ ( value ) => saveSetting( 'order', value ) } />
243 <SelectControl
244 className="give-donor-wall-inspector"
245 label={ __( 'Filter', 'give' ) }
246 name="filter"
247 value={ filterOptions }
248 options={ giveDonorWallOptions.filter }
249 onChange={ ( value ) => saveSetting( 'filterOptions', value ) } />
250
251 {filterValue(filterOptions)}
252 </PanelBody>
253 </Panel>
254 <Panel>
255 <PanelBody title= {__('Wall Interaction', 'give')} initialOpen={ true }>
256 <TextControl
257 className="give-donor-wall-inspector"
258 name="donorsPerPage"
259 label={ __( 'Donors Per Page', 'give' ) }
260 value={ donorsPerPage }
261 onChange={ ( value ) => saveSetting( 'donorsPerPage', value ) }
262 help={ __('How many donors should show up on the initial page load?', 'give' ) }
263 />
264 <TextControl
265 className="give-donor-wall-inspector"
266 name="loadMoreText"
267 label={ __( 'Load More Text', 'give' ) }
268 value={ loadMoreText }
269 onChange={ ( value ) => saveSetting( 'loadMoreText', value ) } />
270 </PanelBody>
271 </Panel>
272 <Panel>
273 <PanelBody title= {__('Color', 'give')} initialOpen={ false }>
274 <ColorPalette
275 value={color}
276 onChange={( value ) => setAttributes( { color: value } )}
277 />
278 </PanelBody>
279 </Panel>
280 </InspectorControls>
281 );
282 };
283
284 export default Inspector;
285