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>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
import namespaceAndEndpointMiddleware from './namespace-endpoint';
|
|
|
|
/**
|
|
* @param {string} rootURL
|
|
* @return {import('../types').APIFetchMiddleware} Root URL middleware.
|
|
*/
|
|
const createRootURLMiddleware = rootURL => (options, next) => {
|
|
return namespaceAndEndpointMiddleware(options, optionsWithPath => {
|
|
let url = optionsWithPath.url;
|
|
let path = optionsWithPath.path;
|
|
let apiRoot;
|
|
if (typeof path === 'string') {
|
|
apiRoot = rootURL;
|
|
if (-1 !== rootURL.indexOf('?')) {
|
|
path = path.replace('?', '&');
|
|
}
|
|
path = path.replace(/^\//, '');
|
|
|
|
// API root may already include query parameter prefix if site is
|
|
// configured to use plain permalinks.
|
|
if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) {
|
|
path = path.replace('?', '&');
|
|
}
|
|
url = apiRoot + path;
|
|
}
|
|
return next({
|
|
...optionsWithPath,
|
|
url
|
|
});
|
|
});
|
|
};
|
|
export default createRootURLMiddleware;
|
|
//# sourceMappingURL=root-url.js.map
|