Files
formipay/formipay.php
dwindown 66e7b37f92 fix: resolve all Week 2 performance & security issues (F1.10–F1.19)
Security:
- Replace maybe_serialize() in cookies with json_encode() (PHP object injection fix)
- Add PayPal webhook signature verification
- Add current_user_can('manage_options') to all 18 admin-ajax handlers

Performance:
- Remove flush_rewrite_rules() from init hooks (Thankyou + Payment)
- Add activation/deactivation hooks for flush_rewrite_rules
- Cache currency, country, flags JSON reads in static variables
- Add server-side pagination to Customer::formipay_tabledata_customers()
- Optimize Order::formipay_tabledata_orders() with COUNT(*) GROUP BY

Cleanup:
- Delete Paypal.phpbak backup file
- Fix timezone hardcode Asia/Jakarta → wp_timezone_string()
- Create uninstall.php for proper cleanup on uninstall

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 19:52:01 +07:00

74 lines
2.2 KiB
PHP

<?php
/**
* Plugin Name: Formipay
* Description: -
* Version: 1.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', '1.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();
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 );