| 1 |
import { allowedSettings } from '@agent/workflows/settings/edit-wp-setting'; |
| 2 |
import apiFetch from '@wordpress/api-fetch'; |
| 3 |
import { __ } from '@wordpress/i18n'; |
| 4 |
|
| 5 |
export default async ({ settingName }) => { |
| 6 |
if (!allowedSettings.includes(settingName)) { |
| 7 |
throw new Error('Setting not allowed'); |
| 8 |
} |
| 9 |
const response = await apiFetch({ |
| 10 |
path: '/wp/v2/settings?context=edit', |
| 11 |
}); |
| 12 |
|
| 13 |
return { |
| 14 |
oldSettingValue: |
| 15 |
response[settingName] || |
| 16 |
// translators: No value found message for when a WP setting has no value. |
| 17 |
__('No value found', 'extendify-local'), |
| 18 |
}; |
| 19 |
}; |
| 20 |
|