ifnex/03_WordPress/wp-content/plugins/ifnex-bridge/ifnex-bridge.php
Kazem Alghasi 97e641de42 feat(wp): add ifnex-bridge plugin for Laravel API integration
Implement a new WordPress plugin to bridge the frontend with the Laravel
logistics API. This includes:

- API client for secure shipment tracking via Bearer token
- Admin settings page for configuring API URL and Key
- Shortcodes for embedding tracking forms and status displays
- AJAX-based tracking form with real-time results and timeline view
2026-08-04 11:38:36 +03:30

53 lines
2.2 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/shortcodes.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/tracking-form.php';
// اضافه کردن لینک به منوی پیشخوان وردپرس
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
}