PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 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 All 255 releases
give / src / MultiFormGoals / resources / js / blocks / progress-bar / data / utils.js

utils.js in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/MultiFormGoals/resources/js/blocks/progress-bar/data/utils.js

70 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const {useSelect} = wp.data;
2 import {__} from '@wordpress/i18n';
3
4 /**
5 * Get array of form options for a select control
6 *
7 * @since 3.1.0 Use title.raw instead of title.rendered
8 * @since 2.9.0
9 * @return {array} Array of options for a select control
10 */
11 export const useFormOptions = () => {
12 const formOptions = useSelect((select) => {
13 const records = select('core').getEntityRecords('postType', 'give_forms');
14 if (records) {
15 return records.map((record) => {
16 return {
17 label: record.title.raw ? record.title.raw : __('(no title)'),
18 value: record.id,
19 };
20 });
21 }
22 return [];
23 }, []);
24 return formOptions;
25 };
26
27 /**
28 * Get array of form tag options for a select control
29 *
30 * @since 2.9.0
31 * @return {array} Array of options for a select control
32 */
33 export const useTagOptions = () => {
34 const tagOptions = useSelect((select) => {
35 const records = select('core').getEntityRecords('taxonomy', 'give_forms_tag', {per_page: 100});
36 if (records) {
37 return records.map((record) => {
38 return {
39 label: record.name ? record.name : __('(no title)'),
40 value: record.id,
41 };
42 });
43 }
44 return [];
45 }, []);
46 return tagOptions;
47 };
48
49 /**
50 * Get array of form category options for a select control
51 *
52 * @since 2.9.0
53 * @return {array} Array of options for a select control
54 */
55 export const useCategoryOptions = () => {
56 const categoryOptions = useSelect((select) => {
57 const records = select('core').getEntityRecords('taxonomy', 'give_forms_category', {per_page: 100});
58 if (records) {
59 return records.map((record) => {
60 return {
61 label: record.name ? record.name : __('(no title)'),
62 value: record.id,
63 };
64 });
65 }
66 return [];
67 }, []);
68 return categoryOptions;
69 };
70