feat: implement coexistence strategy for Grid.js and React admin
Implement dual-mode rendering allowing classic Grid.js and new React versions to run side-by-side during migration. - Add coexistence mode checks to all admin page methods - Check query param ?react=1 or option 'formipay_use_react_admin' - Include classic PHP pages when React not active - Add admin notice showing current version with toggle button - Add footer toggle link to switch between versions This ensures zero feature loss - old Grid.js pages continue working (~20 features per page) while React versions are developed. Files: - Form.php, Coupon.php, Access.php, Order.php - Customer.php, Product.php, License.php - ReactAdmin.php (added version_notice, footer_toggle) Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -70,7 +70,16 @@ class License {
|
||||
}
|
||||
|
||||
public function page_licenses() {
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('licenses');
|
||||
// Coexistence mode: check query param or setting for React version
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
|
||||
if ($use_react) {
|
||||
// New React version
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('licenses');
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
include_once FORMIPAY_PATH . 'admin/page-licenses.php';
|
||||
}
|
||||
}
|
||||
|
||||
/** Enqueue admin assets for Licenses page */
|
||||
@@ -121,7 +130,7 @@ class License {
|
||||
|
||||
/** GridJS data source */
|
||||
public function tabledata() {
|
||||
check_ajax_referer('formipay-admin-licenses', '_wpnonce');
|
||||
check_ajax_referer('formipay-admin', '_wpnonce');
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -202,7 +211,7 @@ class License {
|
||||
|
||||
/** Delete single license */
|
||||
public function delete() {
|
||||
check_ajax_referer('formipay-admin-licenses', '_wpnonce');
|
||||
check_ajax_referer('formipay-admin', '_wpnonce');
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -238,7 +247,7 @@ class License {
|
||||
|
||||
/** Bulk delete */
|
||||
public function bulk_delete() {
|
||||
check_ajax_referer('formipay-admin-licenses', '_wpnonce');
|
||||
check_ajax_referer('formipay-admin', '_wpnonce');
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
|
||||
Reference in New Issue
Block a user