refactor: remove coexistence mode, use React only
Remove all dual-mode rendering logic since React is now the single admin interface. Focus on implementing full table features in React. Changes: - Remove ?react= query param checks from all page methods - Remove admin notice and footer toggle from ReactAdmin - Simplify asset loading - ReactAdmin handles all assets - Clean up Init.php enqueue method Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -84,28 +84,13 @@ class Access {
|
||||
}
|
||||
|
||||
public function formipay_access_items() {
|
||||
// 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('access');
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
include_once FORMIPAY_PATH . 'admin/page-access-items.php';
|
||||
}
|
||||
// React admin
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('access');
|
||||
}
|
||||
|
||||
public function enqueue_admin() {
|
||||
global $current_screen;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
|
||||
$screen = get_current_screen();
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ class ReactAdmin {
|
||||
|
||||
add_action( 'admin_enqueue_scripts', [$this, 'enqueue_assets'] );
|
||||
add_filter( 'formipay/admin/data', [$this, 'localize_data'] );
|
||||
add_action( 'admin_notices', [$this, 'version_notice'] );
|
||||
add_filter( 'admin_footer_text', [$this, 'footer_toggle'] );
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +24,6 @@ class ReactAdmin {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check coexistence mode - only load React when ?react=1 or option is set
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ( ! $use_react ) {
|
||||
return; // Classic mode - don't load React assets
|
||||
}
|
||||
|
||||
// Enqueue React build assets
|
||||
$build_dir = FORMIPAY_PATH . 'build';
|
||||
$build_url = FORMIPAY_URL . 'build';
|
||||
@@ -164,58 +156,4 @@ class ReactAdmin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show admin notice about current admin version
|
||||
*/
|
||||
public function version_notice() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
// Only show on Formipay admin pages
|
||||
if ( strpos( $screen->id, 'formipay' ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
$version = $use_react ? 'React (Beta)' : 'Classic';
|
||||
|
||||
printf(
|
||||
'<div class="notice notice-info inline">
|
||||
<p>
|
||||
<strong>Formipay Admin:</strong> Using %s version.
|
||||
<a href="%s" class="button button-small" style="margin-left: 10px;">Switch to %s</a>
|
||||
</p>
|
||||
</div>',
|
||||
esc_html( $version ),
|
||||
esc_url( add_query_arg( 'react', $use_react ? '0' : '1' ) ),
|
||||
esc_html( $use_react ? 'Classic' : 'React (Beta)' )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add toggle link to admin footer
|
||||
*/
|
||||
public function footer_toggle( $text ) {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
// Only add toggle on Formipay admin pages
|
||||
if ( strpos( $screen->id, 'formipay' ) === false ) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
$toggle_url = add_query_arg( 'react', $use_react ? '0' : '1' );
|
||||
$toggle_text = $use_react ? 'Switch to Classic' : 'Try React (Beta)';
|
||||
|
||||
return sprintf(
|
||||
'%s | <a href="%s">%s</a>',
|
||||
$text,
|
||||
esc_url( $toggle_url ),
|
||||
esc_html( $toggle_text )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,26 +94,13 @@ class Coupon {
|
||||
}
|
||||
|
||||
public function formipay_coupon() {
|
||||
// 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';
|
||||
}
|
||||
// React admin
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('coupons');
|
||||
}
|
||||
|
||||
public function enqueue_admin() {
|
||||
global $current_screen;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
if($current_screen->id == 'formipay_page_formipay-coupons') {
|
||||
|
||||
|
||||
@@ -182,16 +182,8 @@ class Customer {
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
global $current_screen;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($current_screen->id == 'formipay_page_formipay-customers') {
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
$customer_id = intval(filter_input(INPUT_GET, 'customer_id', FILTER_SANITIZE_STRING));
|
||||
if(empty($customer_id)){
|
||||
@@ -225,16 +217,8 @@ class Customer {
|
||||
}
|
||||
|
||||
public function customers_page() {
|
||||
// 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('customers');
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
include_once FORMIPAY_PATH . 'admin/page-customers.php';
|
||||
}
|
||||
// React admin
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('customers');
|
||||
}
|
||||
|
||||
public function formipay_tabledata_customers() {
|
||||
|
||||
@@ -93,16 +93,8 @@ class Form {
|
||||
}
|
||||
|
||||
public function formipay_form() {
|
||||
// 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('forms');
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
include_once FORMIPAY_PATH . 'admin/page-forms.php';
|
||||
}
|
||||
// React admin
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('forms');
|
||||
}
|
||||
|
||||
public function metaboxes($post) {
|
||||
@@ -1257,13 +1249,8 @@ class Form {
|
||||
}
|
||||
|
||||
public function enqueue_admin() {
|
||||
global $current_screen, $post;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
// Check that we are on the 'Checker' post editor screen
|
||||
if ( $current_screen->post_type === 'formipay-form' && $current_screen->base === 'post' ) {
|
||||
|
||||
@@ -80,18 +80,6 @@ class Init {
|
||||
public function enqueue() {
|
||||
global $current_screen;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic shared assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
$is_formipay_screen = strpos($current_screen->id, 'formipay') !== false;
|
||||
|
||||
// Don't load classic Grid.js/shared assets when React is active on admin pages
|
||||
if ($use_react && $is_formipay_screen && $current_screen->base !== 'post') {
|
||||
// Still load SweetAlert2 for React mode (needed for modals)
|
||||
wp_enqueue_style( 'sweetalert2', FORMIPAY_URL . 'vendor/SweetAlert2/sweetalert2.min.css', [], '11.14.4', 'all');
|
||||
wp_enqueue_script( 'sweetalert2', FORMIPAY_URL . 'vendor/SweetAlert2/sweetalert2.min.js', ['jquery'], '11.14.4', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$formipayCPTs = [
|
||||
'formipay-form' => __( 'Edit Form', 'formipay' ),
|
||||
'formipay-product' => __( 'Edit Product', 'formipay' ),
|
||||
|
||||
@@ -70,29 +70,14 @@ class License {
|
||||
}
|
||||
|
||||
public function page_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';
|
||||
}
|
||||
// React admin
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('licenses');
|
||||
}
|
||||
|
||||
/** Enqueue admin assets for Licenses page */
|
||||
public function enqueue() {
|
||||
global $current_screen; if (!$current_screen) return;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($current_screen->id === 'formipay_page_formipay-licenses') {
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
wp_enqueue_style('page-licenses', FORMIPAY_URL . 'admin/assets/css/admin-licenses.css', [], FORMIPAY_VERSION, 'all');
|
||||
wp_enqueue_script('page-licenses', FORMIPAY_URL . 'admin/assets/js/admin-licenses.js', ['jquery', 'gridjs'], FORMIPAY_VERSION, true);
|
||||
wp_localize_script('page-licenses', 'formipay_licenses_page', [
|
||||
|
||||
@@ -644,39 +644,17 @@ class Order {
|
||||
$order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0;
|
||||
$page = $order_id ? 'order-detail' : 'orders';
|
||||
|
||||
// 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
|
||||
printf(
|
||||
'<div id="formipay-admin-root" data-formipay-mount="%s"></div>',
|
||||
esc_attr($page)
|
||||
);
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
if ($order_id) {
|
||||
include_once FORMIPAY_PATH . 'admin/page-order-details.php';
|
||||
} else {
|
||||
include_once FORMIPAY_PATH . 'admin/page-orders.php';
|
||||
}
|
||||
}
|
||||
// React admin
|
||||
printf(
|
||||
'<div id="formipay-admin-root" data-formipay-mount="%s"></div>',
|
||||
esc_attr($page)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
global $current_screen;
|
||||
if (!$current_screen) return;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Classic Grid.js assets would be loaded here
|
||||
// (Original enqueue code was commented out, may need restoration)
|
||||
}
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
public function formipay_get_all_forms() {
|
||||
|
||||
|
||||
@@ -106,13 +106,8 @@ class Product {
|
||||
}
|
||||
|
||||
public function enqueue_admin() {
|
||||
global $current_screen;
|
||||
|
||||
// Check coexistence mode - if React is active, don't load classic assets
|
||||
$use_react = isset($_GET['react']) || get_option('formipay_use_react_admin', false);
|
||||
if ($use_react) {
|
||||
return;
|
||||
}
|
||||
// Assets now handled by ReactAdmin class
|
||||
return;
|
||||
|
||||
if($current_screen->id == 'formipay_page_formipay-products') {
|
||||
|
||||
@@ -233,16 +228,8 @@ class Product {
|
||||
}
|
||||
|
||||
public function formipay_products() {
|
||||
// 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('products');
|
||||
} else {
|
||||
// Classic Grid.js version
|
||||
include_once FORMIPAY_PATH . 'admin/page-products.php';
|
||||
}
|
||||
// React admin
|
||||
\Formipay\Admin\ReactAdmin::render_mount_point('products');
|
||||
}
|
||||
|
||||
public function cpt_post_fields_box($boxes) {
|
||||
|
||||
Reference in New Issue
Block a user