/*
Theme Name: forgex
Theme URI: http://themexriver.com/wp/forgex
Author: themexriver
Author URI: http://themexriver.com/
Description: Forgex - Industrial & Factory WordPress Theme
Version: 1.0.1
Tested up to: 5.4
Requires PHP: 5.6
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: forgex
Tags: custom-background, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/
// تعطيل سكربت SplitText.js
function disable_splittext_script() {
    wp_deregister_script('gsap-splittext'); 
    wp_dequeue_script('gsap-splittext'); 
}
add_action('wp_enqueue_scripts', 'disable_splittext_script', 100);
// إضافة حقل رفع ملف في Checkout
add_action( 'learn-press/checkout/before-order-review', 'add_receipt_upload_field' );
function add_receipt_upload_field() {
    ?>
    <p>
        <label for="receipt_upload">ارفع إيصال الدفع</label><br>
        <input type="file" name="receipt_upload" id="receipt_upload" />
    </p>
    <?php
}

// حفظ الملف بعد الدفع
add_action( 'learn-press/checkout/order-processing', 'save_receipt_upload', 10, 2 );
function save_receipt_upload( $order_id, $data ) {
    if ( ! empty( $_FILES['receipt_upload']['name'] ) ) {
        require_once( ABSPATH . 'wp-admin/includes/file.php' );
        $uploaded = wp_handle_upload( $_FILES['receipt_upload'], array( 'test_form' => false ) );
        if ( isset( $uploaded['url'] ) ) {
            update_post_meta( $order_id, '_receipt_upload', esc_url( $uploaded['url'] ) );
        }
    }
}

