[ SYSTEM ]: Linux wordpress 6.1.0-44-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
[ SERVER ]: Apache/2.4.66 (Debian) | PHP: 8.2.30
[ USER ]: www-data | IP: 172.19.30.54
GEFORCE FILE MANAGER
/
var
/
www
/
html
/
wordpress
/
wp-content
/
plugins
/
presto-player
/
src
/
hooks
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 useSave.js
934 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: useSave.js
import { __ } from "@wordpress/i18n"; import { select, useDispatch } from "@wordpress/data"; import { store as coreStore } from "@wordpress/core-data"; export default function useSave() { const { saveEditedEntityRecord } = useDispatch(coreStore); /** * Handle the form submission */ const save = async () => { // build up pending records to save. const dirtyRecords = select( coreStore ).__experimentalGetDirtyEntityRecords(); const pendingSavedRecords = []; dirtyRecords.forEach(({ kind, name, key }) => { pendingSavedRecords.push( saveEditedEntityRecord(kind, name, key, { throwOnError: true, }) ); }); // check values. const values = await Promise.all(pendingSavedRecords); if (values.some((value) => typeof value === "undefined")) { throw { message: "Saving failed." }; } return true; }; return { save, }; }