164 lines
8.8 KiB
PHP
164 lines
8.8 KiB
PHP
<?php
|
|
/**
|
|
* Pay content sidebar card.
|
|
*
|
|
* @var array $ctx
|
|
* @package AKSRT
|
|
*/
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (empty($ctx['can_pay'])) {
|
|
return;
|
|
}
|
|
|
|
$settings = $ctx['settings'];
|
|
$pay = is_array($ctx['pay_meta'] ?? null) ? $ctx['pay_meta'] : [];
|
|
$enabled = !empty($pay['pay_type']) && ($pay['pay_type'] !== 'no');
|
|
$modo = (($pay['pay_modo'] ?? '0') === 'points') ? 'points' : '0';
|
|
$points_on = !empty($ctx['points_enabled']);
|
|
$vip_manual = !empty($settings['pay_vip_price_s']);
|
|
$vip1_on = !empty($ctx['vip']['vip1_enabled']);
|
|
$vip2_on = !empty($ctx['vip']['vip2_enabled']);
|
|
$vip1_name = (string) ($ctx['vip']['vip1_name'] ?? 'VIP1');
|
|
$vip2_name = (string) ($ctx['vip']['vip2_name'] ?? 'VIP2');
|
|
$downloads = is_array($pay['downloads'] ?? null) ? $pay['downloads'] : [];
|
|
?>
|
|
<div class="aksrt-submit-panel aksrt-submit-pay dependency-box" data-pay-box>
|
|
<div class="aksrt-submit-panel__title"><?php esc_html_e('付费内容', 'aksrt'); ?></div>
|
|
<div class="aksrt-submit-panel__body">
|
|
<div class="aksrt-submit-pay__row">
|
|
<span><?php esc_html_e('内容付费', 'aksrt'); ?></span>
|
|
<label class="aksrt-switch">
|
|
<input type="checkbox" name="pay_enabled" value="1" <?php checked($enabled); ?> data-pay-toggle>
|
|
<span class="aksrt-switch__ui"></span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="aksrt-submit-pay__body" data-pay-fields <?php echo $enabled ? '' : 'hidden'; ?>>
|
|
<?php if ($points_on) : ?>
|
|
<div class="aksrt-submit-pay__row">
|
|
<span><?php esc_html_e('支付类型', 'aksrt'); ?></span>
|
|
<div class="aksrt-submit-segmented">
|
|
<button type="button" class="but <?php echo $modo !== 'points' ? 'active' : ''; ?>" data-pay-modo="0"><?php esc_html_e('现金', 'aksrt'); ?></button>
|
|
<button type="button" class="but <?php echo $modo === 'points' ? 'active' : ''; ?>" data-pay-modo="points"><?php esc_html_e('积分', 'aksrt'); ?></button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<input type="hidden" name="aksrt_pay[pay_modo]" value="<?php echo esc_attr($modo); ?>" data-pay-modo-input>
|
|
<input type="hidden" name="aksrt_pay[pay_type]" value="<?php echo esc_attr((string) ($pay['pay_type'] ?? 'reading')); ?>" data-pay-type-input>
|
|
|
|
<div data-pay-cash <?php echo $modo === 'points' ? 'hidden' : ''; ?>>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php esc_html_e('设置价格', 'aksrt'); ?></span>
|
|
<input type="number" step="0.01" min="0" name="aksrt_pay[price]" class="aksrt-form-input" value="<?php echo esc_attr((string) ($pay['price'] ?? '')); ?>">
|
|
</label>
|
|
<?php if ($vip_manual && $vip1_on) : ?>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php echo esc_html(sprintf(__('%s 价格', 'aksrt'), $vip1_name)); ?></span>
|
|
<input type="number" step="0.01" min="0" name="aksrt_pay[vip1_price]" class="aksrt-form-input" value="<?php echo esc_attr((string) ($pay['vip1_price'] ?? '')); ?>">
|
|
</label>
|
|
<?php endif; ?>
|
|
<?php if ($vip_manual && $vip2_on) : ?>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php echo esc_html(sprintf(__('%s 价格', 'aksrt'), $vip2_name)); ?></span>
|
|
<input type="number" step="0.01" min="0" name="aksrt_pay[vip2_price]" class="aksrt-form-input" value="<?php echo esc_attr((string) ($pay['vip2_price'] ?? '')); ?>">
|
|
</label>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div data-pay-points <?php echo $modo !== 'points' ? 'hidden' : ''; ?>>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php esc_html_e('设置积分', 'aksrt'); ?></span>
|
|
<input type="number" step="1" min="0" name="aksrt_pay[points_price]" class="aksrt-form-input" value="<?php echo esc_attr((string) ($pay['points_price'] ?? '')); ?>">
|
|
</label>
|
|
<?php if ($vip_manual && $vip1_on) : ?>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php echo esc_html(sprintf(__('%s 积分', 'aksrt'), $vip1_name)); ?></span>
|
|
<input type="number" step="1" min="0" name="aksrt_pay[vip1_points]" class="aksrt-form-input" value="<?php echo esc_attr((string) ($pay['vip1_points'] ?? '')); ?>">
|
|
</label>
|
|
<?php endif; ?>
|
|
<?php if ($vip_manual && $vip2_on) : ?>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php echo esc_html(sprintf(__('%s 积分', 'aksrt'), $vip2_name)); ?></span>
|
|
<input type="number" step="1" min="0" name="aksrt_pay[vip2_points]" class="aksrt-form-input" value="<?php echo esc_attr((string) ($pay['vip2_points'] ?? '')); ?>">
|
|
</label>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="aksrt-submit-pay__row">
|
|
<span><?php esc_html_e('购买限制', 'aksrt'); ?></span>
|
|
<select name="aksrt_pay[pay_limit]" class="form-control">
|
|
<?php $pl = (int) ($pay['pay_limit'] ?? 0); ?>
|
|
<option value="0" <?php selected($pl, 0); ?>><?php esc_html_e('所有人可购', 'aksrt'); ?></option>
|
|
<option value="1" <?php selected($pl, 1); ?>><?php esc_html_e('仅 VIP1 及以上', 'aksrt'); ?></option>
|
|
<option value="2" <?php selected($pl, 2); ?>><?php esc_html_e('仅 VIP2', 'aksrt'); ?></option>
|
|
</select>
|
|
</div>
|
|
<div class="aksrt-submit-pay__row">
|
|
<span><?php esc_html_e('登录后可购', 'aksrt'); ?></span>
|
|
<label class="aksrt-switch">
|
|
<input type="checkbox" name="aksrt_pay[require_login]" value="1" <?php checked(!empty($pay['require_login'])); ?>>
|
|
<span class="aksrt-switch__ui"></span>
|
|
</label>
|
|
</div>
|
|
<div class="aksrt-submit-pay__row">
|
|
<span><?php esc_html_e('允许优惠码', 'aksrt'); ?></span>
|
|
<label class="aksrt-switch">
|
|
<input type="checkbox" name="aksrt_pay[coupon_s]" value="1" <?php checked(!empty($pay['coupon_s'])); ?>>
|
|
<span class="aksrt-switch__ui"></span>
|
|
</label>
|
|
</div>
|
|
<label class="aksrt-submit-field">
|
|
<span><?php esc_html_e('优惠说明', 'aksrt'); ?></span>
|
|
<input type="text" class="aksrt-form-input" name="aksrt_pay[coupon_desc]" value="<?php echo esc_attr((string) ($pay['coupon_desc'] ?? '')); ?>" placeholder="<?php esc_attr_e('收银台展示的优惠提示', 'aksrt'); ?>">
|
|
</label>
|
|
|
|
<?php if (!empty($ctx['can_pay_download'])) : ?>
|
|
<div class="aksrt-submit-pay-downloads" data-pay-downloads>
|
|
<div class="aksrt-submit-pay__row">
|
|
<strong><?php esc_html_e('付费下载', 'aksrt'); ?></strong>
|
|
<span>
|
|
<button type="button" class="but hollow c-blue" data-pay-download-add>
|
|
<i class="fa fas fa-plus"></i> <?php esc_html_e('添加资源', 'aksrt'); ?>
|
|
</button>
|
|
<?php if (!empty($ctx['can_upload_file'])) : ?>
|
|
<button type="button" class="but hollow" data-pay-download-upload>
|
|
<i class="fa fas fa-upload"></i> <?php esc_html_e('上传附件', 'aksrt'); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
</span>
|
|
</div>
|
|
<div class="aksrt-submit-pay-downloads__list" data-pay-download-list>
|
|
<?php foreach ($downloads as $i => $row) :
|
|
$url = (string) ($row['url'] ?? '');
|
|
$label = (string) ($row['label'] ?? '');
|
|
$code = (string) ($row['extract_code'] ?? '');
|
|
?>
|
|
<div class="aksrt-submit-pay-downloads__item" data-pay-download-item>
|
|
<input type="url" class="aksrt-form-input" data-pay-download-url name="aksrt_pay[downloads][<?php echo (int) $i; ?>][url]" value="<?php echo esc_attr($url); ?>" placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
|
|
<input type="text" class="aksrt-form-input" data-pay-download-label name="aksrt_pay[downloads][<?php echo (int) $i; ?>][label]" value="<?php echo esc_attr($label); ?>" placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
|
|
<input type="text" class="aksrt-form-input" name="aksrt_pay[downloads][<?php echo (int) $i; ?>][extract_code]" value="<?php echo esc_attr($code); ?>" placeholder="<?php esc_attr_e('提取码/备注', 'aksrt'); ?>">
|
|
<button type="button" class="but c-red cir" data-pay-download-remove title="<?php esc_attr_e('删除', 'aksrt'); ?>"><i class="fa fas fa-trash-alt"></i></button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<template data-pay-download-tpl>
|
|
<div class="aksrt-submit-pay-downloads__item" data-pay-download-item>
|
|
<input type="url" class="aksrt-form-input" data-name="url" data-pay-download-url placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
|
|
<input type="text" class="aksrt-form-input" data-name="label" data-pay-download-label placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
|
|
<input type="text" class="aksrt-form-input" data-name="extract_code" placeholder="<?php esc_attr_e('提取码/备注', 'aksrt'); ?>">
|
|
<button type="button" class="but c-red cir" data-pay-download-remove title="<?php esc_attr_e('删除', 'aksrt'); ?>"><i class="fa fas fa-trash-alt"></i></button>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<p class="aksrt-submit-hint"><?php esc_html_e('请确保已经在文中添加了付费可见的隐藏内容', 'aksrt'); ?></p>
|
|
</div>
|
|
|
|
<p class="aksrt-submit-hint" data-pay-off-hint <?php echo $enabled ? 'hidden' : ''; ?>>
|
|
<?php esc_html_e('如果您在文章中添加了付费可见的隐藏内容,请在此设置付费功能', 'aksrt'); ?>
|
|
</p>
|
|
</div>
|
|
</div>
|