benecaster_get_next_renewal_date()
Returns the next billing renewal date from the last license validation response.
Access: Free (can be called from any context)
Since: feature/license-panel-info
Signature
benecaster_get_next_renewal_date(): ?string
Return Value
An ISO 8601 date string (e.g. '2026-07-17') from the last /validate response, or null when no renewal date is available.
Returns null in these cases:
- The site is on the Launch (free) plan — no billing cycle
- The site is an unlicensed (WordPress.org) install
- The plugin has not yet completed a validation run
- The validation response did not include a
next_renewal_datefield
This function reads from the locally cached benecaster_license_next_renewal_date option — it does not make an HTTP call to the license server and is safe to call on every request. The value is refreshed during each daily validation run and cleared on plugin deactivation or an invalid validation response.
Usage
// Display the renewal date in a custom admin widget
add_action( 'wp_dashboard_setup', function(): void {
wp_add_dashboard_widget(
'my_addon_license_widget',
'Benecaster License',
function(): void {
$renewal = benecaster_get_next_renewal_date();
if ( $renewal ) {
printf( '<p>Renews: <strong>%s</strong></p>', esc_html( $renewal ) );
} else {
echo '<p>No renewal date available (Launch plan or unlicensed).</p>';
}
}
);
} );
// Alert an external system when renewal is within 7 days
add_action( 'benecaster_license_validated', function(): void {
$renewal = benecaster_get_next_renewal_date();
if ( ! $renewal ) {
return;
}
$days_until = ( strtotime( $renewal ) - time() ) / DAY_IN_SECONDS;
if ( $days_until <= 7 ) {
// Send alert to external monitoring
wp_remote_post( 'https://example.com/alerts', [
'body' => json_encode( [
'site' => home_url(),
'renewal' => $renewal,
'days' => round( $days_until ),
] ),
] );
}
} );
Notes
- The date reflects the last cached validation response. If the license server date has changed since the last daily validation, this function will not reflect the update until the next run.
- Format is always ISO 8601 (
YYYY-MM-DD). Parse withstrtotime()orDateTimeImmutable::createFromFormat('Y-m-d', ...)for date arithmetic.
Related
benecaster_is_premium()— returns whether any paid plan is activebenecaster_get_license_plan()— returns the current plan slugbenecaster_get_plan_label()— returns the human-readable label for a plan slug