function custom_column_content($column) { global $post; switch ($column) { case FOOLIC_CPT_LICENSE . '_version': $license = new foolic_license(); $license->load($post); echo $license->update_version; break; case FOOLIC_CPT_LICENSE . '_domains': $license = new foolic_license(); $license->load($post); $limit = $license->domain_limit; if ($limit == '' || $limit == '0') { echo 'Unlimited'; } else { echo $limit; } break; case FOOLIC_CPT_LICENSE . '_expires': $license = new foolic_license(); $license->load($post); $days = $license->expires_in_days; if ($days == '' || $days == '0') { echo 'Never'; } else { echo sprintf(__('%s days', 'foolic'), $days); } break; case FOOLIC_CPT_LICENSE_KEY . '_issued': echo date('d M Y', strtotime($post->post_date)); break; case FOOLIC_CPT_LICENSE_KEY . '_status': $licensekey = new foolic_licensekey(); $licensekey->load($post); $valid = foolic_licensekey_checker::validate_license_key($licensekey); echo '<span title="' . $valid['message'] . '" style="color:' . $valid['color'] . '">' . $valid['status'] . '</span>'; if ($licensekey->has_exceeded_domain_limit()) { echo ' ' . __('Usage:', 'foolic') . ' (' . $licensekey->usage_html() . ')'; } if ($licensekey->has_expired()) { echo ' ' . __('Expires:', 'foolic') . ' ' . $licensekey->expires; } break; } }
function foolic_find_license($slug) { $license = new foolic_license($slug); if ($license->ID == 0) { $license = foolic_license::find_by_override_slug($slug); } return $license; }
/** * @param int $licensekey_id * @param int $upgrade_license_id */ function foolic_perform_upgrade($licensekey_id, $upgrade_license_id) { $license_key = foolic_licensekey::get_by_id($licensekey_id); if ($license_key->ID == 0) { return false; } if (!$license_key->is_deactivated()) { $date_format = get_option('date_format'); $expiry_date = $license_key->expires; $domain_limit = $license_key->domain_limit; //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 new license $license = foolic_license::get_by_id($upgrade_license_id); if ($license->ID > 0) { $domain_limit = $license->domain_limit; 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 and domain limit $license_key->domain_limit = $domain_limit; $license_key->expires = $expiry_date; $license_key->process_domains(); //process domains immediately and update //delete connection $license_key->disconnect_from_existing_license(); //connect to new license $license->link_to_licensekey($license_key->ID); //save upgrade post meta $existing_upgrades = foolic_get_upgrades($license_key->ID); $existing_upgrades[] = array('upgrade_date' => date($date_format), 'upgrade_details' => __('Upgrade to', 'foolicensing') . ' ' . $license->name); foolic_update_upgrades($license_key->ID, $existing_upgrades); return true; } return false; }
public static function find_by_override_slug($slug) { $args = array('numberposts' => 1, 'post_type' => FOOLIC_CPT_LICENSE, 'post_status' => 'publish', 'meta_key' => self::META_UPDATE_SLUG, 'meta_value' => $slug); $licenses = get_posts($args); if ($licenses) { $license = new foolic_license(); $license->load($licenses[0]); return $license; } return false; }