PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.20.0
GiveWP – Donation Plugin and Fundraising Platform v2.20.0
4.16.4 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 / donation-form-grid / edit / inspector.js
give / blocks / donation-form-grid / edit Last commit date
block.js 4 years ago inspector.js 4 years ago
inspector.js
286 lines
1 /**
2 * WordPress dependencies
3 */
4 import {__} from '@wordpress/i18n'
5 import { select } from '@wordpress/data';
6 import {InspectorControls, store } from '@wordpress/block-editor';
7 import {
8 ColorPalette,
9 FormTokenField,
10 PanelBody,
11 SelectControl,
12 TextControl,
13 ToggleControl
14 } from '@wordpress/components';
15
16 import ColumnSelector from '../../components/column-selector';
17
18 /**
19 * Internal dependencies
20 */
21 import giveFormOptions from '../data/options';
22
23 /**
24 * Render Inspector Controls
25 */
26
27 const Inspector = ({attributes, setAttributes}) => {
28 const {
29 formsPerPage,
30 paged,
31 imageSize,
32 imageHeight,
33 formIDs,
34 excludeForms,
35 excludedFormIDs,
36 orderBy,
37 order,
38 categories,
39 tags,
40 columns,
41 showTitle,
42 showExcerpt,
43 excerptLength,
44 showGoal,
45 showProgressBar,
46 showFeaturedImage,
47 showDonateButton,
48 donateButtonBackgroundColor,
49 donateButtonTextColor,
50 displayType
51 } = attributes;
52
53 const saveSetting = (name, value) => {
54 setAttributes({
55 [name]: value,
56 });
57 };
58
59 const getAsArray = value => {
60 if (Array.isArray(value)) {
61 return value;
62 }
63
64 // Backward compatibility
65 if (formIDs.indexOf(',')) {
66 return value.split(',');
67 }
68
69 return [value];
70 };
71
72 const getImageSizes = () => select(store).getSettings().imageSizes.map(({slug, name}) => {
73 return {
74 value: slug,
75 label: name
76 };
77 });
78
79 return (
80 <InspectorControls key="inspector">
81 <PanelBody title={__('Display Appearance', 'give')}>
82 <ColumnSelector
83 label={__('Columns', 'give')}
84 selected={columns}
85 onClick={(value) => saveSetting('columns', value)}
86 help={__('Controls how many columns of the Form Grid appear. "Best Fit" will adjust responsively to the space available.', 'give')}
87 />
88
89 <ToggleControl
90 name="showTitle"
91 label={__('Show Title', 'give')}
92 checked={!!showTitle}
93 onChange={(value) => saveSetting('showTitle', value)}/>
94
95 <ToggleControl
96 name="showExcerpt"
97 label={__('Show Excerpt', 'give')}
98 checked={!!showExcerpt}
99 onChange={(value) => saveSetting('showExcerpt', value)}
100 />
101
102 <TextControl
103 name="excerptLength"
104 label={__('Excerpt Length', 'give')}
105 value={excerptLength || ''}
106 className={!showExcerpt && 'hidden'}
107 onChange={(value) => saveSetting('excerptLength', Number.parseInt(value) || 0)}
108 />
109
110 <ToggleControl
111 name="showGoal"
112 label={__('Show Goal', 'give')}
113 checked={!!showGoal}
114 onChange={(value) => saveSetting('showGoal', value)}
115 />
116
117 {showGoal && (
118 <ToggleControl
119 name="showProgressBar"
120 label={__('Show Progress Bar', 'give')}
121 checked={!!showProgressBar}
122 onChange={(value) => saveSetting('showProgressBar', value)}
123 />
124 )}
125
126 <ToggleControl
127 align="right"
128 name="showFeaturedImage"
129 label={__('Show Featured Image', 'give')}
130 checked={!!showFeaturedImage}
131 onChange={(value) => saveSetting('showFeaturedImage', value)}
132 />
133
134 {showFeaturedImage && (
135 <>
136 <SelectControl
137 name="imageSize"
138 label={__('Image Size', 'give')}
139 value={imageSize}
140 options={getImageSizes()}
141 onChange={(value) => saveSetting('imageSize', value)}
142 help={__('Featured image size. Default "medium." Accepts WordPress image sizes, which by default are "thumbnail," "medium," "large," or "full." ', 'give')}
143 />
144
145 <TextControl
146 name="imageHeight"
147 label={__('Image Height', 'give')}
148 value={imageHeight}
149 onChange={(value) => saveSetting('imageHeight', value)}
150 help={__('Featured image height. Default "auto". Accepts valid heights in px, em, or rem.', 'give')}
151 />
152 </>
153 )}
154
155 <ToggleControl
156 name="showDonateButton"
157 label={__('Show Donate Button', 'give')}
158 checked={!!showDonateButton}
159 onChange={(value) => saveSetting('showDonateButton', value)}
160 />
161 {showDonateButton && (
162 <>
163 <p>
164 {__('Donate Button Background Color', 'give')}
165 </p>
166 <ColorPalette
167 clearable={false}
168 onChange={(value) => saveSetting('donateButtonBackgroundColor', value)}
169 value={donateButtonBackgroundColor}
170 />
171 <p>
172 {__('Donate Button Text Color', 'give')}
173 </p>
174 <ColorPalette
175 clearable={false}
176 onChange={(value) => saveSetting('donateButtonTextColor', value)}
177 value={donateButtonTextColor}
178 />
179 </>
180 )}
181 </PanelBody>
182
183 <PanelBody title={__('Filters and Categories', 'give')}>
184
185 <SelectControl
186 label={__('Order By', 'give')}
187 name="orderBy"
188 value={orderBy}
189 options={giveFormOptions.orderBy}
190 onChange={(value) => saveSetting('orderBy', value)}
191 help={__('The order forms are displayed in.', 'give')}
192 />
193
194 <SelectControl
195 label={__('Order', 'give')}
196 name="order"
197 value={order}
198 options={giveFormOptions.order}
199 onChange={(value) => saveSetting('order', value)}
200 help={__('Whether the order ascends or descends.', 'give')}
201 />
202
203 <FormTokenField
204 name="categories"
205 label={__('Categories', 'give')}
206 value={getAsArray(categories)}
207 onChange={(value) => saveSetting('categories', value)}
208 />
209
210 <p className="components-form-token-field__help">
211 {__('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')}
212 </p>
213
214 <FormTokenField
215 name="tags"
216 label={__('Tags', 'give')}
217 value={getAsArray(tags)}
218 onChange={(value) => saveSetting('tags', value)}
219 />
220
221 <p className="components-form-token-field__help">
222 {__('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')}
223 </p>
224
225 <FormTokenField
226 name="formIDs"
227 label={__('Form IDs', 'give')}
228 value={getAsArray(formIDs)}
229 onChange={(value) => saveSetting('formIDs', value)}
230 />
231
232 <p className="components-form-token-field__help">
233 {__('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')}
234 </p>
235
236 <ToggleControl
237 name="excludeForms"
238 label={__('Exclude specific forms?', 'give')}
239 checked={!!excludeForms}
240 onChange={(value) => saveSetting('excludeForms', value)}
241 />
242
243 {excludeForms && (
244 <>
245 <FormTokenField
246 name="excludedFormIDs"
247 label={__('Excluded Form IDs', 'give')}
248 value={getAsArray(excludedFormIDs)}
249 onChange={(value) => saveSetting('excludedFormIDs', value)}
250 />
251 <p className="components-form-token-field__help">
252 {__('Type the ID of your form to exclude it from the list. Forms with these IDs you choose will not be displayed in this grid.', 'give')}
253 </p>
254 </>
255 )}
256 </PanelBody>
257
258 <PanelBody title={__('Grid Behavior', 'give')}>
259 <SelectControl
260 label={__('Display Type', 'give')}
261 name="displayType"
262 value={displayType}
263 options={giveFormOptions.displayType}
264 onChange={(value) => saveSetting('displayType', value)}
265 help={__('What should happen when a visitor clicks on a form within the grid? "Redirect" sends them to the individual form. "Modal" opens the form in a lightbox/popup on the same page.', 'give')}
266 />
267 <TextControl
268 name="formsPerPage"
269 label={__('Forms Per Page', 'give')}
270 value={formsPerPage}
271 onChange={(value) => saveSetting('formsPerPage', value)}
272 help={__('How many forms should display on the first page load? To restrict display to only one page, disable pagination below.', 'give')}
273 />
274 <ToggleControl
275 name="paged"
276 label={__('Show Pagination', 'give')}
277 checked={!!paged}
278 onChange={(value) => saveSetting('paged', value)}
279 />
280 </PanelBody>
281 </InspectorControls>
282 );
283 };
284
285 export default Inspector;
286