This commit is contained in:
Javier Casares 2026-08-17 16:03:39 +00:00
commit 0e617fa428
12 changed files with 286 additions and 259 deletions

View file

@ -7,6 +7,10 @@
* (website link + description), an intro paragraph, and Support /
* Payments sections below the table.
*
* Also available:
* $manager_subscriptions array<string, array{status:string, expires_at:string}>
* Account subscriptions keyed by slug (may be empty).
*
* @package Robotstxt_Manager
*/
@ -19,6 +23,8 @@ if ( ! defined( 'ABSPATH' ) ) {
*
* @var list<array<string,mixed>> $catalog
* @var array<string, array{installed:bool, active:bool, version:string}> $local
* @var array<string, array<string,mixed>> $manager_subscriptions
* @var list<array{type:string, message:string}> $manager_notices
*/
$client_configured = Robotstxt_Manager_Core_Client::from_options()->is_configured();
@ -65,6 +71,12 @@ $compat_warnings = 0;
<div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Catalog refreshed.', 'robotstxt-manager' ); ?></p></div>
<?php endif; ?>
<?php foreach ( ( $manager_notices ?? array() ) as $manager_notice ) : ?>
<div class="notice notice-<?php echo esc_attr( is_string( $manager_notice['type'] ?? '' ) ? $manager_notice['type'] : 'warning' ); ?>">
<p><?php echo esc_html( is_string( $manager_notice['message'] ?? '' ) ? $manager_notice['message'] : '' ); ?></p>
</div>
<?php endforeach; ?>
<?php if ( '' !== $notice_message && in_array( $notice_result, array( 'success', 'error' ), true ) ) : ?>
<div class="notice notice-<?php echo esc_attr( $notice_result ); ?> is-dismissible"><p><?php echo esc_html( $notice_message ); ?></p></div>
<?php endif; ?>
@ -209,6 +221,46 @@ $compat_warnings = 0;
number_format_i18n( $cost, 0 )
)
);
// Subscription pill for premium plugins.
$sub_row = $manager_subscriptions[ $slug ] ?? null;
$sub_text = '';
if ( is_array( $sub_row ) ) {
$raw_sub_status = $sub_row['status'] ?? '';
$raw_sub_expiry = $sub_row['expires_at'] ?? '';
$sub_status = is_string( $raw_sub_status ) ? $raw_sub_status : '';
$sub_expiry = is_string( $raw_sub_expiry ) ? $raw_sub_expiry : '';
if ( 'active' === $sub_status && '' !== $sub_expiry ) {
$days_left = (int) floor( ( (int) strtotime( $sub_expiry ) - time() ) / DAY_IN_SECONDS );
if ( $days_left >= 0 && $days_left <= 14 ) {
$sub_text = sprintf(
/* translators: %d: days remaining. */
__( 'Subscribed — %d days left', 'robotstxt-manager' ),
$days_left
);
} else {
$sub_text = __( 'Subscribed', 'robotstxt-manager' );
}
} elseif ( 'payment_failed' === $sub_status ) {
$sub_text = __( 'Payment failed', 'robotstxt-manager' );
} elseif ( 'cancelled' === $sub_status ) {
$sub_text = __( 'Cancelled', 'robotstxt-manager' );
} elseif ( 'expired' === $sub_status ) {
$sub_text = __( 'Expired', 'robotstxt-manager' );
}
}
if ( '' !== $sub_text ) {
$raw_pill_status = is_array( $sub_row ) ? ( $sub_row['status'] ?? '' ) : '';
$pill_status = is_string( $raw_pill_status ) ? $raw_pill_status : '';
echo '<br /><span class="robotstxt-manager-subscription robotstxt-manager-subscription--'
. esc_attr( $pill_status )
. '">' . esc_html( $sub_text ) . '</span>';
}
} else {
echo esc_html__( 'Free', 'robotstxt-manager' );
}