ifnex/03_WordPress/wp-content/plugins/ifnex-bridge/ifnex-bridge.php
Kazem Alghasi b605b689fd feat(wp-plugin): expand IFNEX Bridge with wallet and transaction support
Extend the WordPress bridge plugin to provide seamless integration with
the backend wallet system. This update introduces user-specific
functionality via shortcodes and AJAX.

- feat(bridge): implement `IFNEX_User_Bridge` for Sanctum token management
- feat(bridge): add `[ifnex_wallet_balance]` shortcode for balance display
- feat(bridge): add `[ifnex_transactions]` shortcode for transaction history
- feat(bridge): implement AJAX handlers for real-time balance and transaction updates
- feat(bridge): add plugin-specific CSS assets and enqueueing logic
- docs: update project status with new bridge capabilities
- chore: add plugin testing utility and asset directory structure
2026-08-08 03:49:46 +03:30

67 lines
2.9 KiB
PHP

<?php
/**
* Plugin Name: IFNEX Logistics Bridge
* Description: اتصال فرانت‌اند سایت ایف‌نکس به API لاراول
* Version: 1.0
* Author: VernaSoft group (Kazem Alghasi)
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// لود کردن فایل‌های پلاگین
require_once plugin_dir_path( __FILE__ ) . 'includes/api-client.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/user-bridge.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/shortcodes.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/tracking-form.php';
// لود کردن استایل‌های پلاگین
add_action('wp_enqueue_scripts', 'ifnex_enqueue_scripts');
function ifnex_enqueue_scripts() {
global $post;
if (is_a($post, 'WP_Post') &&
(has_shortcode($post->post_content, 'ifnex_tracking_form') ||
has_shortcode($post->post_content, 'ifnex_wallet_balance') ||
has_shortcode($post->post_content, 'ifnex_transactions') ||
has_shortcode($post->post_content, 'ifnex_tracking_status'))) {
wp_enqueue_style('ifnex-bridge-css', plugin_dir_url(__FILE__) . 'assets/css/ifnex-bridge.css', array(), '1.0.0');
}
}
// اضافه کردن لینک به منوی پیشخوان وردپرس
add_action( 'admin_menu', 'ifnex_plugin_setup_menu' );
function ifnex_plugin_setup_menu() {
add_menu_page( 'تنظیمات IFNEX', 'IFNEX', 'manage_options', 'ifnex-settings', 'ifnex_settings_page_html', 'dashicons-location-alt', 30 );
}
function ifnex_settings_page_html() {
if (isset($_POST['ifnex_api_url']) && check_admin_referer('ifnex_settings_save')) {
update_option('ifnex_api_url', sanitize_url($_POST['ifnex_api_url']));
update_option('ifnex_api_key', sanitize_text_field($_POST['ifnex_api_key']));
echo '<div class="notice notice-success"><p>تنظیمات ذخیره شد.</p></div>';
}
$api_url = get_option('ifnex_api_url', 'http://localhost:8000/api/v1');
$api_key = get_option('ifnex_api_key', '');
?>
<div class="wrap">
<h1>تنظیمات IFNEX Logistics Bridge</h1>
<form method="post">
<?php wp_nonce_field('ifnex_settings_save'); ?>
<table class="form-table">
<tr>
<th scope="row"><label for="ifnex_api_url">API URL</label></th>
<td><input type="text" id="ifnex_api_url" name="ifnex_api_url" value="<?php echo esc_attr($api_url); ?>" class="regular-text" placeholder="http://localhost:8000/api/v1"></td>
</tr>
<tr>
<th scope="row"><label for="ifnex_api_key">API Key</label></th>
<td><input type="text" id="ifnex_api_key" name="ifnex_api_key" value="<?php echo esc_attr($api_key); ?>" class="regular-text"></td>
</tr>
</table>
<?php submit_button('ذخیره تنظیمات'); ?>
</form>
</div>
<?php
}