PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.3
Secure Custom Fields v6.9.3
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / build / js / pro / acf-field-bindings.js
secure-custom-fields / assets / build / js / pro Last commit date
acf-datastore.asset.php 3 months ago acf-datastore.js 3 months ago acf-datastore.js.map 3 months ago acf-datastore.min.asset.php 3 months ago acf-datastore.min.js 3 months ago acf-field-bindings.asset.php 3 months ago acf-field-bindings.js 3 months ago acf-field-bindings.js.map 3 months ago acf-field-bindings.min.asset.php 3 months ago acf-field-bindings.min.js 3 months ago acf-pro-blocks.asset.php 1 month ago acf-pro-blocks.js 1 month ago acf-pro-blocks.js.map 1 month ago acf-pro-blocks.min.asset.php 1 month ago acf-pro-blocks.min.js 1 month ago acf-pro-field-group.asset.php 11 months ago acf-pro-field-group.js 11 months ago acf-pro-field-group.js.map 9 months ago acf-pro-field-group.min.asset.php 9 months ago acf-pro-field-group.min.js 9 months ago acf-pro-input.asset.php 1 month ago acf-pro-input.js 1 month ago acf-pro-input.js.map 1 month ago acf-pro-input.min.asset.php 1 month ago acf-pro-input.min.js 1 month ago acf-pro-ui-options-page.asset.php 9 months ago acf-pro-ui-options-page.js 9 months ago acf-pro-ui-options-page.js.map 9 months ago acf-pro-ui-options-page.min.asset.php 9 months ago acf-pro-ui-options-page.min.js 9 months ago index.php 1 year ago
acf-field-bindings.js
123 lines
1 /******/ (() => { // webpackBootstrap
2 /*!*************************************************!*\
3 !*** ./assets/src/js/pro/acf-field-bindings.js ***!
4 \*************************************************/
5 (() => {
6 'use strict';
7
8 const STORE_NAME = 'acf/fields';
9 const fieldSupportsBindings = field => {
10 return false !== field.supportsBindings && false !== field.allowInBindings;
11 };
12 const isScalarValue = value => {
13 const valueType = typeof value;
14 return 'string' === valueType || 'number' === valueType || 'boolean' === valueType;
15 };
16 const valueToBindingString = value => {
17 if (null === value || undefined === value) {
18 return null;
19 }
20 if (isScalarValue(value)) {
21 return String(value);
22 }
23 if (Array.isArray(value) && value.every(isScalarValue)) {
24 return value.join(', ');
25 }
26 return null;
27 };
28 if (!window.wp?.blocks?.registerBlockBindingsSource) {
29 // eslint-disable-next-line no-console
30 console.warn('SCF: wp.blocks.registerBlockBindingsSource is unavailable; SCF block bindings will not be registered. Requires WordPress 6.7+.');
31 return;
32 }
33 wp.blocks.registerBlockBindingsSource({
34 name: 'acf/field',
35 usesContext: ['postType', 'postId'],
36 getValues({
37 select,
38 bindings
39 }) {
40 const store = select(STORE_NAME);
41 if (!store.isInitialized()) {
42 return {};
43 }
44 const values = {};
45 for (const attributeName of Object.keys(bindings)) {
46 const fieldKey = bindings[attributeName].args?.key;
47 if (!fieldKey) {
48 continue;
49 }
50 const value = valueToBindingString(store.getFieldValue(fieldKey));
51 if (null !== value) {
52 values[attributeName] = value;
53 }
54 }
55 return values;
56 },
57 setValues({
58 select,
59 dispatch,
60 bindings
61 }) {
62 const store = select(STORE_NAME);
63 if (!store.isInitialized()) {
64 return;
65 }
66 for (const attributeName of Object.keys(bindings)) {
67 const binding = bindings[attributeName];
68 const fieldKey = binding.args?.key;
69 if (!fieldKey || undefined === binding.newValue || !isScalarValue(binding.newValue)) {
70 continue;
71 }
72 const field = store.getField(fieldKey);
73 if (field && fieldSupportsBindings(field)) {
74 dispatch(STORE_NAME).setFieldValue(fieldKey, binding.newValue);
75 }
76 }
77 },
78 canUserEditValue({
79 select,
80 args
81 }) {
82 if (!args?.key) {
83 return false;
84 }
85 const store = select(STORE_NAME);
86 if (!store.isInitialized()) {
87 return false;
88 }
89 const field = store.getField(args.key);
90 if (!field || !fieldSupportsBindings(field)) {
91 return false;
92 }
93 const value = store.getFieldValue(args.key);
94 return !(null !== value && undefined !== value && !isScalarValue(value));
95 },
96 getFieldsList({
97 select
98 }) {
99 const store = select(STORE_NAME);
100 if (!store.isInitialized()) {
101 return [];
102 }
103 const fields = store.getFields();
104 const list = [];
105 for (const fieldKey of Object.keys(fields)) {
106 const field = fields[fieldKey];
107 if (fieldSupportsBindings(field)) {
108 list.push({
109 label: field.label,
110 args: {
111 key: field.key
112 },
113 type: 'string'
114 });
115 }
116 }
117 return list;
118 }
119 });
120 })();
121 /******/ })()
122 ;
123 //# sourceMappingURL=acf-field-bindings.js.map