v1.3.0
This commit is contained in:
parent
30451228f7
commit
e3bfd7b6f2
12 changed files with 108 additions and 29 deletions
|
|
@ -25,6 +25,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @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
|
||||
* @var bool $manager_has_api_key
|
||||
* @var string $manager_store_url
|
||||
*/
|
||||
|
||||
$client_configured = Robotstxt_Manager_Core_Client::from_options()->is_configured();
|
||||
|
|
@ -77,6 +79,22 @@ $compat_warnings = 0;
|
|||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ( empty( $manager_has_api_key ) && '' !== ( $manager_store_url ?? '' ) ) : ?>
|
||||
<div class="notice notice-info">
|
||||
<p>
|
||||
<?php
|
||||
echo wp_kses_post(
|
||||
sprintf(
|
||||
/* translators: %s: store registration URL. */
|
||||
__( 'Create your free account at the <a href="%s" target="_blank" rel="noopener noreferrer">ROBOTSTXT store</a> to get your personal API key. The key links your subscriptions to this site and unlocks premium plugins and updates.', 'robotstxt-manager' ),
|
||||
esc_url( $manager_store_url . '/wp-login.php?action=register' )
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?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; ?>
|
||||
|
|
@ -149,6 +167,14 @@ $compat_warnings = 0;
|
|||
$website_url = '' !== $page_url ? $page_url : $homepage;
|
||||
$has_detail = ( '' !== $website_url || '' !== $desc );
|
||||
|
||||
// Subscription state: premium plugins are only usable
|
||||
// (install/update) with an active or in-grace subscription.
|
||||
$is_premium = ( $cost > 0.0 || 'premium' === $kind );
|
||||
$sub_row = $manager_subscriptions[ $slug ] ?? null;
|
||||
$raw_status = is_array( $sub_row ) ? ( $sub_row['status'] ?? '' ) : '';
|
||||
$sub_status = is_string( $raw_status ) ? $raw_status : '';
|
||||
$subscribed = in_array( $sub_status, array( 'active', 'payment_failed' ), true );
|
||||
|
||||
$raw_reqs = $entry['requires_plugins'] ?? '';
|
||||
$req_slugs = array();
|
||||
if ( is_string( $raw_reqs ) && '' !== trim( $raw_reqs ) ) {
|
||||
|
|
@ -220,7 +246,7 @@ $compat_warnings = 0;
|
|||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( $cost > 0.0 || 'premium' === $kind ) {
|
||||
if ( $is_premium ) {
|
||||
echo esc_html(
|
||||
sprintf(
|
||||
/* translators: %s: formatted price number. */
|
||||
|
|
@ -230,13 +256,10 @@ $compat_warnings = 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 ) {
|
||||
|
|
@ -261,11 +284,8 @@ $compat_warnings = 0;
|
|||
}
|
||||
|
||||
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_attr( $sub_status )
|
||||
. '">' . esc_html( $sub_text ) . '</span>';
|
||||
}
|
||||
} else {
|
||||
|
|
@ -274,18 +294,16 @@ $compat_warnings = 0;
|
|||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ( ! $l_installed ) : ?>
|
||||
<?php if ( ! $wp_ok || ! $php_ok ) : ?>
|
||||
<span class="description"><?php esc_html_e( 'Incompatible', 'robotstxt-manager' ); ?></span>
|
||||
<?php if ( ! $wp_ok || ! $php_ok ) : ?>
|
||||
<span class="description"><?php esc_html_e( 'Incompatible', 'robotstxt-manager' ); ?></span>
|
||||
<?php elseif ( $is_premium && ! $subscribed ) : ?>
|
||||
<?php if ( '' !== $page_url ) : ?>
|
||||
<a class="button button-primary" href="<?php echo esc_url( $page_url ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Buy', 'robotstxt-manager' ); ?></a>
|
||||
<?php else : ?>
|
||||
<?php if ( $cost > 0.0 && '' !== $page_url ) : ?>
|
||||
<a class="button button-secondary" href="<?php echo esc_url( $page_url ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Buy', 'robotstxt-manager' ); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$install_class = ( $cost > 0.0 && '' !== $page_url ) ? 'button-secondary' : 'button-primary';
|
||||
?>
|
||||
<a class="button <?php echo esc_attr( $install_class ); ?>" href="<?php echo esc_url( Robotstxt_Manager_Admin::action_url( 'install', $slug ) ); ?>"><?php esc_html_e( 'Install', 'robotstxt-manager' ); ?></a>
|
||||
—
|
||||
<?php endif; ?>
|
||||
<?php elseif ( ! $l_installed ) : ?>
|
||||
<a class="button button-primary" href="<?php echo esc_url( Robotstxt_Manager_Admin::action_url( 'install', $slug ) ); ?>"><?php esc_html_e( 'Install', 'robotstxt-manager' ); ?></a>
|
||||
<?php elseif ( ! $l_active ) : ?>
|
||||
<a class="button button-primary" href="<?php echo esc_url( Robotstxt_Manager_Admin::action_url( 'activate', $slug ) ); ?>"><?php esc_html_e( 'Activate', 'robotstxt-manager' ); ?></a>
|
||||
<?php elseif ( $update_available ) : ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue