- Add package.json with @wordpress/scripts and React dependencies - Configure webpack for admin bundle output - Create src/admin directory structure (api, components, pages) - Implement API client with nonce handling (ajaxRequest, apiRequest) - Add API methods for orders, customers, products, forms, coupons, licenses - Create React App component with page routing - Add placeholder page components for all admin sections - Create ReactAdmin PHP class to manage asset enqueuing - Register ReactAdmin singleton in main plugin file - Bump version to 2.0.0 Build: Run 'npm install && npm run build' to generate assets
75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Formipay
|
|
* Description: -
|
|
* Version: 2.0.0
|
|
* Plugin URI: https://formipay.com/
|
|
* Author: Formipay
|
|
* Text Domain: formipay
|
|
* License: GPL-2.0+
|
|
* License URI: http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
|
|
*
|
|
* Requires at least: 6.2
|
|
* Tested up to: 6.8.1
|
|
*
|
|
* Copyright: © 2023 Formipay.
|
|
* License: GNU General Public License v3.0
|
|
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
|
|
|
define( 'FORMIPAY_NAME', 'Formipay' );
|
|
define( 'FORMIPAY_VERSION', '2.0.0' );
|
|
define( 'FORMIPAY_PATH', plugin_dir_path( __FILE__ ) );
|
|
define( 'FORMIPAY_URL', plugin_dir_url( __FILE__ ) );
|
|
define( 'FORMIPAY_MENU_SLUG', 'formipay' );
|
|
define( 'FORMIPAY_OPTION_KEY', 'formipay_settings' );
|
|
|
|
|
|
require_once FORMIPAY_PATH . 'admin/functions.php';
|
|
|
|
spl_autoload_register(function ($class) {
|
|
$prefix = 'Formipay\\';
|
|
$base_dir = __DIR__ . '/includes/';
|
|
|
|
// Check if the class uses the plugin's namespace
|
|
if (strpos($class, $prefix) !== 0) return;
|
|
|
|
// Remove namespace prefix
|
|
$relative_class = substr($class, strlen($prefix));
|
|
|
|
// Convert namespace to file path
|
|
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
|
|
|
if (file_exists($file)) {
|
|
require_once $file;
|
|
}
|
|
});
|
|
|
|
\Formipay\Init::get_instance();
|
|
\Formipay\Admin\ReactAdmin::get_instance();
|
|
|
|
register_activation_hook( __FILE__, 'formipay_activate' );
|
|
function formipay_activate() {
|
|
// Instantiate singletons so rewrite rules get registered via init hooks
|
|
\Formipay\Thankyou::get_instance();
|
|
\Formipay\Integration\Paypal::get_instance();
|
|
\Formipay\Payment\BankTransfer::get_instance();
|
|
flush_rewrite_rules();
|
|
}
|
|
|
|
register_deactivation_hook( __FILE__, 'formipay_deactivate' );
|
|
function formipay_deactivate() {
|
|
flush_rewrite_rules();
|
|
}
|
|
|
|
// function formipay_add_defer_attribute($tag, $handle) {
|
|
// if ( 'product-details' === $handle ) {
|
|
// // Add defer attribute
|
|
// return str_replace( '<script ', '<script defer ', $tag );
|
|
// }
|
|
// return $tag;
|
|
// }
|
|
// add_filter( 'script_loader_tag', 'formipay_add_defer_attribute', 10, 2 );
|