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:
@@ -94,10 +94,21 @@ class Coupon {
|
||||
}
|
||||
|
||||
public function formipay_coupon() {
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('coupons');
|
||||
// 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('coupons');
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
include_once FORMIPAY_PATH . 'admin/page-coupons.php';
|
||||
}
|
||||
}
|
||||
|
||||
public function enqueue_admin() {
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
global $current_screen;
|
||||
|
||||
@@ -568,7 +579,7 @@ class Coupon {
|
||||
|
||||
public function formipay_tabledata_coupons() {
|
||||
|
||||
check_ajax_referer( 'formipay-admin-coupon-page', '_wpnonce' );
|
||||
check_ajax_referer( 'formipay-admin', '_wpnonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -676,7 +687,7 @@ class Coupon {
|
||||
|
||||
public function formipay_coupon_get_products() {
|
||||
|
||||
check_ajax_referer( 'formipay-admin-coupon-page', '_wpnonce' );
|
||||
check_ajax_referer( 'formipay-admin', '_wpnonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -710,7 +721,7 @@ class Coupon {
|
||||
|
||||
public function formipay_create_coupon_post() {
|
||||
|
||||
check_ajax_referer( 'formipay-admin-coupon-page', '_wpnonce' );
|
||||
check_ajax_referer( 'formipay-admin', '_wpnonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -745,7 +756,7 @@ class Coupon {
|
||||
|
||||
public function formipay_delete_coupon() {
|
||||
|
||||
check_ajax_referer( 'formipay-admin-coupon-page', '_wpnonce' );
|
||||
check_ajax_referer( 'formipay-admin', '_wpnonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -773,7 +784,7 @@ class Coupon {
|
||||
|
||||
public function formipay_bulk_delete_coupon() {
|
||||
|
||||
check_ajax_referer( 'formipay-admin-coupon-page', '_wpnonce' );
|
||||
check_ajax_referer( 'formipay-admin', '_wpnonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => 'Unauthorized' ] );
|
||||
@@ -820,7 +831,7 @@ class Coupon {
|
||||
|
||||
public function formipay_duplicate_coupon() {
|
||||
|
||||
check_ajax_referer( 'formipay-admin-coupon-page', '_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