示例#1
0
$fs = freemius($slug);
$timestamp = time();
$context_params = array('plugin_id' => $fs->get_id(), 'plugin_public_key' => $fs->get_public_key(), 'plugin_version' => $fs->get_plugin_version());
// Get site context secure params.
if ($fs->is_registered()) {
    $site = $fs->get_site();
    $plugin_id = fs_request_get('plugin_id', $fs->get_id());
    if ($plugin_id != $fs->get_id()) {
        if ($fs->is_addon_activated($plugin_id)) {
            $fs_addon = Freemius::get_instance_by_id($plugin_id);
            $site = $fs_addon->get_site();
        }
    }
    $context_params = array_merge($context_params, FS_Security::instance()->get_context_params($site, $timestamp, 'checkout'));
} else {
    $current_user = Freemius::_get_current_wp_user();
    // Add site and user info to the request, this information
    // is NOT being stored unless the user complete the purchase
    // and agrees to the TOS.
    $context_params = array_merge($context_params, array('user_firstname' => $current_user->user_firstname, 'user_lastname' => $current_user->user_lastname, 'user_email' => $current_user->user_email));
    $fs_user = Freemius::_get_user_by_email($current_user->user_email);
    if (is_object($fs_user)) {
        $context_params = array_merge($context_params, FS_Security::instance()->get_context_params($fs_user, $timestamp, 'checkout'));
    }
}
if ($fs->is_payments_sandbox()) {
    // Append plugin secure token for sandbox mode authentication.
    $context_params['sandbox'] = FS_Security::instance()->get_secure_token($fs->get_plugin(), $timestamp, 'checkout');
    /**
     * @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
     */