Ejemplo n.º 1
0
/**
 * @param int $licensekey_id
 */
function foolic_perform_renewal($licensekey_id)
{
    $license_key = foolic_licensekey::get_by_id($licensekey_id);
    if ($license_key->ID == 0) {
        return false;
    }
    if ($license_key->does_expire() && !$license_key->is_deactivated()) {
        $date_format = get_option('date_format');
        $expiry_date = $license_key->expires;
        //get the expiry date
        $expiry = strtotime($license_key->expires);
        //if already expired, then use today's date
        if ($expiry < time()) {
            $expiry = time();
        }
        //ensure we have our connections registered
        foolic_post_relationships::register_connections();
        //load license
        $license = $license_key->get_license();
        if ($license->ID > 0) {
            if ($license->expires_in_days > 0) {
                $expiry_date = date($date_format, strtotime('+' . $license->expires_in_days . ' days', $expiry));
            } else {
                $expiry_date = 'never';
            }
        }
        //save new expiry date
        $license_key->expires = $expiry_date;
        $license_key->update();
        //save renewal post
        $renewal_post_args = apply_filters('foolic_renewal_post_args_override', array('post_type' => FOOLIC_CPT_RENEWAL, 'post_status' => 'publish', 'post_author' => $license->author, 'post_title' => $license->name . ' - ' . $license_key->license_key));
        //insert the renewal post
        $renewal_id = wp_insert_post($renewal_post_args, true);
        //save renewal post meta
        $existing_renewals = foolic_get_renewals($license_key->ID);
        $existing_renewals[] = array('renewal_date' => date($date_format), 'renewal_id' => $renewal_id);
        foolic_update_renewals($license_key->ID, $existing_renewals);
        do_action('foolic_perform_renewal', $license_key->ID);
        return $renewal_id;
    }
    return false;
}
Ejemplo n.º 2
0
                echo '<span style="text-decoration: line-through">' . $domain->url . '</span> (' . __('detached', 'foolicensing') . ')';
                echo ' <a class="foolic-action foolic-action-attach" data-domain-id="' . $domain->ID . '" data-licensekey-id="' . $key->ID . '" data-action="foolic_attach_domain_to_licensekey" href="#attach">' . __('Attach', 'foolicensing') . '</a>';
            }
        }
    }
}
// Retrieve all license keys for the current user
$license_keys = foolic_get_licensekeys_by_user();
if ($license_keys) {
    ?>
	<div id="foolic_license_listing">
		<?php 
    foreach ($license_keys as $key) {
        $domains = foolic_license_listing_get_sorted_domains($key);
        $attached_domains = $key->get_attached_domains();
        $renewals = foolic_get_renewals($key->ID);
        $upgrades = foolic_get_upgrades($key->ID);
        $license = $key->get_license();
        ?>
			<div class="foolic_license_listing_item">
				<h2><?php 
        echo $license->name;
        ?>
</h2>
				<table>
					<tr>
						<th><?php 
        _e('Date Issued', 'foolicensing');
        ?>
</th>
						<td><?php