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>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/**
|
|
* Formipay Admin - React Application Entry Point
|
|
*/
|
|
|
|
import { render } from '@wordpress/element';
|
|
import App from './components/App';
|
|
|
|
// Mount the React app to all available mount points
|
|
const mountApps = () => {
|
|
const mountPoints = document.querySelectorAll('[data-formipay-mount]');
|
|
|
|
console.log('[Formipay] Mount points found:', mountPoints.length);
|
|
console.log('[Formipay] formipayAdmin data:', window.formipayAdmin);
|
|
|
|
mountPoints.forEach((mountPoint) => {
|
|
const page = mountPoint.dataset.formipayMount;
|
|
const initialData = window.formipayAdmin?.[page] || {};
|
|
|
|
console.log('[Formipay] Mounting page:', page, 'with data:', initialData);
|
|
|
|
try {
|
|
render(
|
|
<App page={page} initialData={initialData} />,
|
|
mountPoint
|
|
);
|
|
console.log('[Formipay] Successfully mounted:', page);
|
|
} catch (error) {
|
|
console.error('[Formipay] Failed to mount:', page, error);
|
|
}
|
|
});
|
|
};
|
|
|
|
// Initialize when DOM is ready
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', mountApps);
|
|
} else {
|
|
mountApps();
|
|
}
|