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-datastore.min.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 2 months ago acf-pro-input.js 2 months ago acf-pro-input.js.map 2 months ago acf-pro-input.min.asset.php 2 months ago acf-pro-input.min.js 2 months 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-datastore.min.js
1 lines
1 (()=>{"use strict";const e="acf/fields",t=["repeater","group","flexible_content","clone"],n=new Set(["post_object","page_link","relationship","taxonomy","user"]),i=new RegExp(`\\[acf_(${["added","changed","deleted","reordered","inserted"].join("|")})]$`),s={context:{postId:0,postType:""},fields:{},values:{},savedValues:{},nameToKey:{},fieldGroups:[],initialized:!1,syncing:!1},a=e=>null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e)),r=e=>t.includes(e),o=e=>{const t={};for(const n of Object.keys(e)){const i=e[n];i.name&&(t[i.name]=n)}return t},l=(e,t)=>{if(t)return e.fields[t]?t:e.nameToKey[t]},c=(e,t,n)=>{if(0===t.length)return n;const i=t[0],s=e??{},a=Array.isArray(s)?[...s]:{...s};return a[i]=c(a[i],t.slice(1),n),a},f=(e=s,t)=>{switch(t.type){case"INITIALIZE_STORE":{const n=t.fields??{},i=t.values??{};return{...e,context:t.context??e.context,fields:n,values:i,savedValues:a(i),nameToKey:o(n),fieldGroups:t.fieldGroups??[],initialized:!0}}case"REGISTER_FIELD_GROUP":{const n={...e.fields,...t.fields??{}},i=t.values??{},s={...e.values},r={...e.savedValues};for(const e of Object.keys(i))e in s||(s[e]=i[e]),e in r||(r[e]=a(i[e]));const l=new Set(e.fieldGroups.map(e=>e.key)),c=(t.fieldGroups??[]).filter(e=>!l.has(e.key)),f=0===e.context.postId&&t.context?t.context:e.context;return{...e,context:f,fields:n,values:s,savedValues:r,nameToKey:o(n),fieldGroups:[...e.fieldGroups,...c],initialized:!0}}case"SET_FIELD_VALUE":{const n=l(e,t.fieldKey);return n?{...e,values:{...e.values,[n]:t.value}}:e}case"SET_VALUES":{const n={};for(const i of Object.keys(t.values)){const s=l(e,i);s&&(n[s]=t.values[i])}return{...e,values:{...e.values,...n}}}case"SET_SUB_FIELD_VALUE":{const n=l(e,t.parentKey);if(!n)return e;const i=e.values[n]??{},s=c(i,t.path,t.value);return{...e,values:{...e.values,[n]:s}}}case"ADD_REPEATER_ROW":{const n=l(e,t.fieldKey);if(!n)return e;const i=[...Array.isArray(e.values[n])?e.values[n]:[]],s=Math.max(0,Math.min(t.index??i.length,i.length));return i.splice(s,0,t.rowData??{}),{...e,values:{...e.values,[n]:i}}}case"REMOVE_REPEATER_ROW":{const n=l(e,t.fieldKey);if(!n)return e;const i=e.values[n];if(!Array.isArray(i))return e;if(t.rowIndex<0||t.rowIndex>=i.length)return e;const s=[...i];return s.splice(t.rowIndex,1),{...e,values:{...e.values,[n]:s}}}case"MOVE_REPEATER_ROW":{const n=l(e,t.fieldKey);if(!n)return e;const i=e.values[n];if(!Array.isArray(i))return e;if(t.fromIndex<0||t.fromIndex>=i.length||t.toIndex<0||t.toIndex>=i.length)return e;const s=[...i],[a]=s.splice(t.fromIndex,1);return s.splice(t.toIndex,0,a),{...e,values:{...e.values,[n]:s}}}case"MARK_AS_SAVED":return{...e,savedValues:a(e.values)};case"SET_SYNCING":return{...e,syncing:t.isSyncing};default:return e}},d={getFieldValue:(e,t)=>{const n=l(e,t);return n?e.values[n]:void 0},getFieldValueByKey:(e,t)=>e.values[t],getFieldValueByName:(e,t)=>{const n=e.nameToKey[t];return n?e.values[n]:void 0},getAllValues:e=>e.values,getAllValuesByName:e=>{const t={};for(const n of Object.keys(e.nameToKey)){const i=e.nameToKey[n];i in e.values&&(t[n]=e.values[i])}return t},getChangedValues:e=>{const t={};for(const n of Object.keys(e.values))JSON.stringify(e.values[n])!==JSON.stringify(e.savedValues[n])&&(t[n]=e.values[n]);return t},getField:(e,t)=>{const n=l(e,t);return n?e.fields[n]:void 0},getFields:e=>e.fields,getFieldsByGroup:(e,t)=>{const n={};for(const i of Object.keys(e.fields))e.fields[i].fieldGroupKey===t&&(n[i]=e.fields[i]);return n},getFieldKeyByName:(e,t)=>e.nameToKey[t],getSubFieldValue:(e,t,...n)=>{const i=l(e,t);return i?((e,t)=>{let n=e;for(const e of t){if(null==n)return;n=n[e]}return n})(e.values[i],n):void 0},isInitialized:e=>e.initialized,isSyncing:e=>e.syncing,hasChanges:e=>JSON.stringify(e.values)!==JSON.stringify(e.savedValues),isDirty:(e,t)=>{const n=l(e,t);return!(!n||JSON.stringify(e.values[n])===JSON.stringify(e.savedValues[n]))},getContext:e=>e.context,getFieldGroups:e=>e.fieldGroups},u={initializeStore:e=>({type:"INITIALIZE_STORE",context:e.context,fields:e.fields,values:e.values,fieldGroups:e.fieldGroups}),registerFieldGroup:e=>({type:"REGISTER_FIELD_GROUP",context:e.context,fields:e.fields,values:e.values,fieldGroups:e.fieldGroups}),setFieldValue:(e,t)=>({type:"SET_FIELD_VALUE",fieldKey:e,value:t}),setValues:e=>({type:"SET_VALUES",values:e}),setSubFieldValue:(e,...t)=>{const n=t.pop();return{type:"SET_SUB_FIELD_VALUE",parentKey:e,path:t,value:n}},addRepeaterRow:(e,t,n)=>({type:"ADD_REPEATER_ROW",fieldKey:e,rowData:t,index:n}),removeRepeaterRow:(e,t)=>({type:"REMOVE_REPEATER_ROW",fieldKey:e,rowIndex:t}),moveRepeaterRow:(e,t,n)=>({type:"MOVE_REPEATER_ROW",fieldKey:e,fromIndex:t,toIndex:n}),markAsSaved:()=>({type:"MARK_AS_SAVED"}),setSyncing:e=>({type:"SET_SYNCING",isSyncing:e})};window.wp?.data?.createReduxStore&&wp.data.register(wp.data.createReduxStore(e,{reducer:f,selectors:d,actions:u}));const p=(e,t)=>{const i=e.get("type");if(!n.has(i))return[];const s=(e=>null==e||""===e||!1===e?[]:Array.isArray(e)?e.filter(e=>null!=e&&""!==e):[e])(t);if(!s.length)return[];if("relationship"===i){const t=new Set;return e.$el.find(".choices-list .acf-rel-item").each(function(){t.add(String(jQuery(this).data("id")))}),s.filter(e=>!t.has(String(e)))}const a=e.$el.find("select").first();if(!a.length)return[];const r=new Set;return a.find("option").each(function(){r.add(String(jQuery(this).val()))}),s.filter(e=>!r.has(String(e)))},y=(e,t)=>{if(!t.length)return;if("relationship"===e.get("type")){const n=e.$el.find(".choices-list").first();if(!n.length)return;for(const e of t){const t=String(e.id);if(n.find(".acf-rel-item").toArray().some(e=>String(jQuery(e).data("id"))===t))continue;const i=jQuery('<li><span tabindex="0" class="acf-rel-item acf-rel-item-add"></span></li>');i.find(".acf-rel-item").attr("data-id",t).text(e.text),n.append(i)}return}const n=e.$el.find("select").first();if(n.length)for(const e of t){const t=String(e.id);n.find("option").toArray().some(e=>String(e.value)===t)||n.append(jQuery("<option></option>").attr("value",t).text(e.text))}},g=async(e,t)=>{const n=e.get("type"),i=e.get("key"),s=e.get("nonce");if(!(n&&i&&s&&window.ajaxurl))return null;const a=new FormData;a.append("action",`acf/fields/${n}/query`),a.append("field_key",i),a.append("nonce",s),a.append("include",String(t));try{const e=await fetch(ajaxurl,{method:"POST",credentials:"same-origin",body:a});return e.ok?((e,t)=>{const n=e?.results;if(!Array.isArray(n))return null;const i=String(t);for(const e of n)if(e&&"object"==typeof e)if(Array.isArray(e.children)){for(const t of e.children)if(t&&"object"==typeof t&&String(t.id)===i&&"string"==typeof t.text)return{id:t.id,text:t.text}}else if(String(e.id)===i&&"string"==typeof e.text)return{id:e.id,text:e.text};return null})(await e.json(),t):null}catch(e){return null}},h=e=>{const t=e.get("type");return"group"===t||"clone"===t?v(e):"repeater"===t?S(e):"flexible_content"===t?w(e):void 0},v=e=>{const t={},n=acf.getFields({parent:e.$el});for(const e of n){const n=e.get("key"),i=e.get("type");t[n]=r(i)?h(e):e.val()}return t},S=e=>{const t=[];return e.$el.find("> .acf-input > .acf-repeater > table > tbody > tr.acf-row:not(.acf-clone)").each(function(){const e=jQuery(this),n={},i=acf.getFields({parent:e});for(const e of i){const t=e.get("key"),i=e.get("type");n[t]=r(i)?h(e):e.val()}t.push(n)}),t},w=e=>{const t=[];return e.$el.find("> .acf-input > .acf-flexible-content > .values > .layout:not(.acf-clone)").each(function(){const e=jQuery(this),n={acf_fc_layout:e.data("layout")},i=acf.getFields({parent:e});for(const e of i){const t=e.get("key"),i=e.get("type");n[t]=r(i)?h(e):e.val()}t.push(n)}),t},A=e=>{acf.doAction("remove",e),e.remove()},E=(e,t)=>{const n=e.get("type");r(n)?"group"===n||"clone"===n?_(e,t):"repeater"===n?F(e,t):"flexible_content"===n&&b(e,t):e.val(t)},_=(e,t)=>{t&&"object"==typeof t&&!Array.isArray(t)&&x(e.$el,t)},F=(e,t)=>{if(e.get("pagination"))return;const n=Array.isArray(t)?t:[],i=()=>e.$el.find("> .acf-input > .acf-repeater > table > tbody > tr.acf-row:not(.acf-clone)"),s=i().length;for(let e=s-1;e>=n.length;e--)A(i().eq(e));for(let t=s;t<n.length;t++)e.add();i().each(function(e){const t=n[e];t&&"object"==typeof t&&x(jQuery(this),t)})},b=(e,t)=>{const n=Array.isArray(t)?t:[],i=e.$layouts();if(i.length!==n.length||!i.toArray().every((e,t)=>jQuery(e).data("layout")===n[t]?.acf_fc_layout)){i.each(function(){A(jQuery(this))});for(const t of n){const n=t?.acf_fc_layout;"string"==typeof n&&n&&e.add({layout:n})}}e.$layouts().each(function(e){const t=n[e];t&&"object"==typeof t&&x(jQuery(this),t)})},x=(e,t)=>{for(const n of acf.getFields({parent:e})){const e=n.get("key");e in t&&E(n,t[e])}};if(window.wp?.data?.select&&window.wp?.data?.dispatch){let t=!1,i=null;const s=e=>{const t=e.parents();return t.length?t[t.length-1].get("key"):e.get("key")},a=(e,t)=>{const n=acf.findField(e);if(!n.length)return;const i=acf.getField(n);i&&E(i,t)},o=async(e,t)=>{const i={},s=[];for(const a of e){const e=acf.findField(a);if(!e.length)continue;const r=acf.getField(e);if(!r||!n.has(r.get("type")))continue;const o=p(r,t[a]);if(o.length){i[a]=[];for(const e of o)s.push(g(r,e).then(e=>{e&&i[a].push(e)}))}}return await Promise.all(s),i},l=()=>{if(t)return;const s=wp.data.select(e);if(!s.isInitialized())return;const r=s.getAllValues();if(r===i)return;const c=i??{},f=Object.keys(r).filter(e=>r[e]!==c[e]);if(i=r,!f.length)return;let d=!1;for(const e of f){const t=acf.findField(e);if(!t.length)continue;const i=acf.getField(t);if(i&&n.has(i.get("type"))&&p(i,r[e]).length){d=!0;break}}if(d)return t=!0,void o(f,r).then(n=>{try{for(const[e,t]of Object.entries(n)){const n=acf.findField(e);if(!n.length)continue;const i=acf.getField(n);i&&y(i,t)}for(const e of f)a(e,r[e])}finally{t=!1,i=r,wp.data.select(e).getAllValues()!==r&&queueMicrotask(l)}}).catch(()=>{t=!1});t=!0;try{for(const e of f)a(e,r[e])}finally{t=!1}};new acf.Model({id:"datastoreSync",wait:"prepare",initialize(){acf.isGutenbergPostEditor()&&(this.initializeStore(),this.subscribeToStore(),this.listenToDOM(),this.setupConvenienceAPI())},initializeStore(){const t=acf.get("storeData");t&&(wp.data.dispatch(e).initializeStore(t),this.reconcileWithDOM(),i=wp.data.select(e).getAllValues())},reconcileWithDOM(){const t=acf.getFields();if(!t?.length)return;const n=wp.data.select(e),i={};for(const e of t){const t=e.get("key");if(!t||!n.getField(t))continue;const s=n.getFieldValue(t);if(void 0===s)continue;const a=e.get("type"),o=r(a)?h(e):e.val();JSON.stringify(o)!==JSON.stringify(s)&&(i[t]=o)}Object.keys(i).length&&wp.data.dispatch(e).setValues(i)},subscribeToStore(){this.storeUnsubscribe=wp.data.subscribe(l)},listenToDOM(){acf.addAction("change_field",this.onFieldChange,10,this),acf.addAction("append_field",this.onFieldStructureChange,10,this),acf.addAction("remove_field",this.onFieldStructureChange,10,this),acf.addAction("sortstop_field",this.onFieldStructureChange,10,this),acf.addAction("refresh_post_screen",this.onRefreshPostScreen,10,this)},onFieldChange(n){if(t)return;if(!wp.data.select(e).isInitialized())return;const a=n.get("key");if(a){t=!0;try{const t=n.parent();if(t&&r(t.get("type"))){const t=s(n);if(t){const n=acf.findField(t);if(n.length){const i=acf.getField(n);i&&wp.data.dispatch(e).setFieldValue(t,h(i))}}}else r(n.get("type"))?wp.data.dispatch(e).setFieldValue(a,h(n)):wp.data.dispatch(e).setFieldValue(a,n.val())}finally{t=!1,i=wp.data.select(e).getAllValues()}}},onFieldStructureChange(n){if(t)return;if(!wp.data.select(e).isInitialized())return;const a=s(n);if(!a)return;const o=acf.findField(a);if(!o.length)return;const l=acf.getField(o);if(l&&r(l.get("type"))){t=!0;try{wp.data.dispatch(e).setFieldValue(a,h(l))}finally{t=!1,i=wp.data.select(e).getAllValues()}}},onRefreshPostScreen(n){if(n?.storeData){t=!0;try{wp.data.dispatch(e).registerFieldGroup(n.storeData),this.reconcileWithDOM()}finally{t=!1,i=wp.data.select(e).getAllValues()}}},setupConvenienceAPI(){acf.store={get(t){if(wp.data.select(e).isInitialized())return wp.data.select(e).getFieldValue(t)},set(t,n){wp.data.select(e).isInitialized()&&wp.data.dispatch(e).setFieldValue(t,n)},subscribe(t,n){let i=wp.data.select(e).getFieldValue(t);return wp.data.subscribe(()=>{const s=wp.data.select(e).getFieldValue(t);if(s!==i){const e=i;i=s,n(s,e)}})}}}})}const V=e=>{const t=acf.findField(e);if(!t.length)return{};const n=t.find("> .acf-input > .acf-repeater > table > tbody > tr.acf-row:not(.acf-clone)"),s={};return n.each(function(){const e=jQuery(this),t=e.data("id");if(!t)return;const n={};for(const t of acf.getFields({parent:e})){const e=t.get("key"),i=t.get("type");n[e]=r(i)?h(t):t.val()}e.find("input.acf-row-status").each(function(){const e=(jQuery(this).attr("name")??"").match(i);e&&(n[`acf_${e[1]}`]=jQuery(this).val())}),s[t]=n}),s};let m=null,I=null,O=!1;acf.gutenbergEditPost=function(){if(!acf.isGutenbergPostEditor())return;const t=wp.data.select(e);if(!t||!t.isInitialized())return;const n={...t.getAllValues()};for(const e of Object.keys(n)){const i=t.getField(e);"repeater"===i?.type&&i.pagination&&(n[e]=V(e))}const i=JSON.stringify(n);m=i,I=i,wp.data.dispatch("core/editor").editPost({meta:{_acf:i}})},window.wp?.data?.subscribe&&wp.data.subscribe(()=>{if(O)return;const t=wp.data.select(e);if(!t?.isInitialized())return;const n=wp.data.select("core/editor");if(!n?.getEditedPostAttribute)return;const i=n.getEditedPostAttribute("meta"),s=i&&"string"==typeof i._acf?i._acf:null;if(!s||s===I)return;if(s===m)return void(I=s);let a;try{a=JSON.parse(s)}catch(e){return void(I=s)}if(a&&"object"==typeof a&&!Array.isArray(a)){I=s,O=!0;try{wp.data.dispatch(e).setValues(a)}finally{O=!1}}else I=s})})();