ifnex/03_WordPress/test-plugin.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

63 lines
2.3 KiB
PHP

<?php
// Test script for IFNEX Bridge plugin
// This creates a test page in WordPress with all shortcodes
require_once('wp-load.php');
// Check if user is logged in as admin
if (!is_user_logged_in() || !current_user_can('manage_options')) {
die('Admin access required');
}
// Create test page content
$page_content = '
<h1>تست پلاگین IFNEX Bridge</h1>
<h2>1. فرم رهگیری مرسوله</h2>
[ifnex_tracking_form title="رهگیری مرسوله IFNEX" placeholder="شماره بارنامه را وارد کنید" button_text="جستجو"]
<h2>2. موجودی کیف پول</h2>
[ifnex_wallet_balance show_details="yes"]
<h2>3. لیست تراکنش‌ها</h2>
[ifnex_transactions per_page="5" show_pagination="yes"]
<h2>4. وضعیت مستقیم مرسوله</h2>
[ifnex_tracking_status awb="980100010"]
';
// Check if test page already exists
$test_page = get_page_by_title('تست IFNEX Bridge', OBJECT, 'page');
if (!$test_page) {
// Create test page
$page_id = wp_insert_post(array(
'post_title' => 'تست IFNEX Bridge',
'post_content' => $page_content,
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
));
if ($page_id) {
echo "✅ صفحه تست ایجاد شد: " . get_permalink($page_id) . "\n";
} else {
echo "❌ خطا در ایجاد صفحه تست\n";
}
} else {
// Update existing test page
$test_page->post_content = $page_content;
wp_update_post($test_page);
echo "✅ صفحه تست به‌روز شد: " . get_permalink($test_page->ID) . "\n";
}
echo "\n📋 اطلاعات اتصال:\n";
echo "API URL: " . get_option('ifnex_api_url', 'http://localhost:8000/api/v1') . "\n";
echo "API Key: " . (get_option('ifnex_api_key', '') ? 'تنظیم شده' : 'تنظیم نشده') . "\n";
echo "\n🔧 مراحل بعدی:\n";
echo "1. مطمئن شوید لاراول در حال اجرا است: cd 04_Laravel && php artisan serve\n";
echo "2. وارد صفحه تست شوید: http://localhost/ifnexwp/?page_id=" . ($test_page ? $test_page->ID : $page_id) . "\n";
echo "3. ابتدا وارد وردپرس شوید (admin / admin)\n";
echo "4. صفحه تست را باز کنید و عملکرد شورت‌کدها را بررسی کنید\n";