Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
/**
|
|
* @callback DoingHook
|
|
* Returns whether a hook is currently being executed.
|
|
*
|
|
* @param {string} [hookName] The name of the hook to check for. If
|
|
* omitted, will check for any hook being executed.
|
|
*
|
|
* @return {boolean} Whether the hook is being executed.
|
|
*/
|
|
|
|
/**
|
|
* Returns a function which, when invoked, will return whether a hook is
|
|
* currently being executed.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
*
|
|
* @return {DoingHook} Function that returns whether a hook is currently
|
|
* being executed.
|
|
*/
|
|
function createDoingHook(hooks, storeKey) {
|
|
return function doingHook(hookName) {
|
|
const hooksStore = hooks[storeKey];
|
|
|
|
// If the hookName was not passed, check for any current hook.
|
|
if ('undefined' === typeof hookName) {
|
|
return 'undefined' !== typeof hooksStore.__current[0];
|
|
}
|
|
|
|
// Return the __current hook.
|
|
return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
|
|
};
|
|
}
|
|
export default createDoingHook;
|
|
//# sourceMappingURL=createDoingHook.js.map
|