<?php

function ghl_gf_send_plugin_data($plugin_slug, $endpoint, $user_email = null)
{
    $api_url = 'http://pluginconnect.ibsofts.com/api';
    $site_url = site_url();

    $data = [
        'plugin_slug' => $plugin_slug,
        'site_url' => $site_url,
    ];

    if ($user_email) {
        $data['user_email'] = $user_email;
    }

    $response = wp_remote_post($api_url . '/' . $endpoint, [
        'body' => $data,
    ]);

    if (is_wp_error($response)) {
        error_log('Plugin Sync error: ' . $response->get_error_message());
    }
}
