| 1 |
<?php |
| 2 |
/** |
| 3 |
* Create Plan Group modal. Free is Recurring-only; the other two types are |
| 4 |
* locked unless Subscription Pro is active. |
| 5 |
* |
| 6 |
* @package SpringDevs\Subscription\Admin |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
$pro_active = function_exists( 'subscrpt_pro_activated' ) && subscrpt_pro_activated(); |
| 14 |
|
| 15 |
$types = array( |
| 16 |
'recurring' => array( |
| 17 |
'label' => __( 'Recurring Payment', 'subscription' ), |
| 18 |
'badge' => __( 'Digital products', 'subscription' ), |
| 19 |
'icon' => 'dashicons-update', |
| 20 |
'desc' => __( 'Automatically charge recurring payments (best for virtual & downloadable products).', 'subscription' ), |
| 21 |
'free' => true, |
| 22 |
), |
| 23 |
'subscribe_save' => array( |
| 24 |
'label' => __( 'Recurring Delivery', 'subscription' ), |
| 25 |
'badge' => __( 'Physical products', 'subscription' ), |
| 26 |
'icon' => 'dashicons-cart', |
| 27 |
'desc' => __( 'Charge and deliver physical products on a schedule.', 'subscription' ), |
| 28 |
'free' => false, |
| 29 |
), |
| 30 |
'installments' => array( |
| 31 |
'label' => __( 'Split Payment', 'subscription' ), |
| 32 |
'badge' => __( 'Installments', 'subscription' ), |
| 33 |
'icon' => 'dashicons-money-alt', |
| 34 |
'desc' => __( 'Split a price into a fixed number of payments.', 'subscription' ), |
| 35 |
'free' => false, |
| 36 |
), |
| 37 |
); |
| 38 |
?> |
| 39 |
<div class="wpsubs-modal" id="subscrpt-create-plan" hidden> |
| 40 |
<div class="wpsubs-modal__backdrop" data-wpsubs-modal-close></div> |
| 41 |
<div class="wpsubs-modal__dialog"> |
| 42 |
<div class="wpsubs-modal__head" style="align-items:flex-start;"> |
| 43 |
<div> |
| 44 |
<h2 class="wpsubs-modal__title" style="font-size:16px;line-height:1.3;"><?php esc_html_e( 'Create Plan', 'subscription' ); ?></h2> |
| 45 |
<p style="margin:5px 0 0;color:var(--wpsubs-text-muted);font-size:13px;line-height:1.5;font-weight:400;"> |
| 46 |
<?php esc_html_e( 'A plan bundles the billing terms you attach to products. Name it, pick a type, then add billing terms.', 'subscription' ); ?> |
| 47 |
</p> |
| 48 |
</div> |
| 49 |
<button type="button" class="wpsubs-modal__close" data-wpsubs-modal-close aria-label="<?php esc_attr_e( 'Close', 'subscription' ); ?>">×</button> |
| 50 |
</div> |
| 51 |
<div class="wpsubs-modal__body"> |
| 52 |
|
| 53 |
<label for="subscrpt-create-name" style="display:block;font-weight:600;margin:0 0 6px;"><?php esc_html_e( 'Name', 'subscription' ); ?></label> |
| 54 |
<input type="text" id="subscrpt-create-name" class="wpsubs-input" placeholder="<?php esc_attr_e( 'e.g. Premium Membership', 'subscription' ); ?>" autocomplete="off" /> |
| 55 |
|
| 56 |
<p style="font-weight:600;margin:16px 0 8px;"><?php esc_html_e( 'Plan Type', 'subscription' ); ?></p> |
| 57 |
|
| 58 |
<div data-subscrpt-type-list style="display:flex;flex-direction:column;gap:10px;"> |
| 59 |
<?php |
| 60 |
foreach ( $types as $key => $type_def ) : |
| 61 |
$locked = ! $type_def['free'] && ! $pro_active; |
| 62 |
$selected = 'recurring' === $key; |
| 63 |
|
| 64 |
$style = 'display:flex;gap:12px;align-items:flex-start;box-sizing:border-box;width:100%;padding:12px 14px;border:1px solid var(--wpsubs-border);border-radius:var(--wpsubs-radius);'; |
| 65 |
$style .= $selected ? 'border-color:var(--wpsubs-brand);background:var(--wpsubs-brand-light);' : ''; |
| 66 |
$style .= $locked ? 'opacity:0.6;cursor:not-allowed;' : 'cursor:pointer;'; |
| 67 |
?> |
| 68 |
<div |
| 69 |
class="subscrpt-type-card<?php echo $selected ? ' is-selected' : ''; ?>" |
| 70 |
data-subscrpt-type="<?php echo esc_attr( $key ); ?>" |
| 71 |
data-subscrpt-type-label="<?php echo esc_attr( $type_def['label'] ); ?>" |
| 72 |
<?php echo $locked ? 'data-locked="1"' : 'role="button" tabindex="0"'; ?> |
| 73 |
style="<?php echo esc_attr( $style ); ?>" |
| 74 |
> |
| 75 |
<span class="dashicons <?php echo esc_attr( $type_def['icon'] ); ?>" style="flex:0 0 auto;color:<?php echo $selected ? 'var(--wpsubs-brand)' : 'var(--wpsubs-text-subtle)'; ?>;"></span> |
| 76 |
<span style="flex:1 1 auto;min-width:0;"> |
| 77 |
<span style="display:block;font-weight:600;color:var(--wpsubs-text);"> |
| 78 |
<?php echo esc_html( $type_def['label'] ); ?> |
| 79 |
<?php if ( ! empty( $type_def['badge'] ) ) : ?> |
| 80 |
<span class="wpsubs-badge wpsubs-badge--muted" style="margin-left:2px;"><?php echo esc_html( $type_def['badge'] ); ?></span> |
| 81 |
<?php endif; ?> |
| 82 |
<?php if ( $locked ) : ?> |
| 83 |
<span class="wpsubs-badge wpsubs-badge--pro"><?php esc_html_e( 'Pro', 'subscription' ); ?></span> |
| 84 |
<?php endif; ?> |
| 85 |
</span> |
| 86 |
<span style="display:block;color:var(--wpsubs-text-muted);font-size:13px;word-break:break-word;"><?php echo esc_html( $type_def['desc'] ); ?></span> |
| 87 |
</span> |
| 88 |
</div> |
| 89 |
<?php endforeach; ?> |
| 90 |
</div> |
| 91 |
|
| 92 |
<?php if ( ! $pro_active ) : ?> |
| 93 |
<p style="color:var(--wpsubs-text-muted);font-size:12px;margin:12px 0 0;"> |
| 94 |
<?php esc_html_e( 'Recurring Delivery and Split Payment plans are available in Subscription Pro.', 'subscription' ); ?> |
| 95 |
</p> |
| 96 |
<?php endif; ?> |
| 97 |
</div> |
| 98 |
<div class="wpsubs-modal__footer"> |
| 99 |
<button type="button" class="wpsubs-btn wpsubs-btn--outline" data-wpsubs-modal-close><?php esc_html_e( 'Cancel', 'subscription' ); ?></button> |
| 100 |
<button type="button" class="wpsubs-btn wpsubs-btn--primary" data-subscrpt-create-plan><?php esc_html_e( 'Create Plan', 'subscription' ); ?></button> |
| 101 |
</div> |
| 102 |
</div> |
| 103 |
</div> |
| 104 |
|