88 lines
6.9 KiB
PHP
88 lines
6.9 KiB
PHP
<?php
|
|
/** @var array $ctx */
|
|
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']);
|
|
$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'] : [];
|
|
|
|
if (!function_exists('aksrt_submit_pay_line')) {
|
|
function aksrt_submit_pay_line(string $label, string $name, string $value, string $step): void {
|
|
?>
|
|
<div class="relative mt6"><div class="flex ab"><div class="muted-color mb6 flex0"><?php echo esc_html($label); ?></div><input type="number" min="0" step="<?php echo esc_attr($step); ?>" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr($value); ?>" class="line-form-input em2x key-color text-right"><i class="line-form-line"></i></div></div>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<div class="zib-widget dependency-box mb10-sm newpost-pay-box" data-pay-box>
|
|
<div class="title-theme mb10"><?php esc_html_e('付费内容', 'aksrt'); ?></div>
|
|
<div class="flex ac jsb padding-h10 border-bottom">
|
|
<div class="flex ac"><?php esc_html_e('内容付费', 'aksrt'); ?></div>
|
|
<label class="form-switch-label"><input class="hide" type="checkbox" name="pay_enabled" value="1" <?php checked($enabled); ?> data-pay-toggle><span class="form-switch flex0"></span></label>
|
|
</div>
|
|
|
|
<div data-pay-fields <?php echo $enabled ? '' : 'hidden'; ?>>
|
|
<?php if ($points_on) : ?>
|
|
<div class="flex ac jsb padding-h10">
|
|
<div class="flex ac"><?php esc_html_e('支付类型', 'aksrt'); ?></div>
|
|
<div class="but-average radius em09">
|
|
<button type="button" class="but p2-10 pointer<?php echo $modo !== 'points' ? ' active' : ''; ?>" data-pay-modo="0"><?php esc_html_e('现金支付', 'aksrt'); ?></button>
|
|
<button type="button" class="but p2-10 pointer<?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 class="mt10 newpost-pay-price" data-pay-cash <?php echo $modo === 'points' ? 'hidden' : ''; ?>>
|
|
<?php aksrt_submit_pay_line(__('设置价格', 'aksrt'), 'aksrt_pay[price]', (string) ($pay['price'] ?? ''), '0.01'); ?>
|
|
<?php if ($manual && $vip1_on) aksrt_submit_pay_line(sprintf(__('%s价格', 'aksrt'), $vip1_name), 'aksrt_pay[vip1_price]', (string) ($pay['vip1_price'] ?? ''), '0.01'); ?>
|
|
<?php if ($manual && $vip2_on) aksrt_submit_pay_line(sprintf(__('%s价格', 'aksrt'), $vip2_name), 'aksrt_pay[vip2_price]', (string) ($pay['vip2_price'] ?? ''), '0.01'); ?>
|
|
<?php if ($manual && ($vip1_on || $vip2_on)) : ?><div class="px12 mt6 muted-color"><?php esc_html_e('会员价不能高于普通价,为0则为会员免费', 'aksrt'); ?></div><?php endif; ?>
|
|
</div>
|
|
|
|
<div class="mt10 newpost-pay-price" data-pay-points <?php echo $modo !== 'points' ? 'hidden' : ''; ?>>
|
|
<?php aksrt_submit_pay_line(__('设置积分', 'aksrt'), 'aksrt_pay[points_price]', (string) ($pay['points_price'] ?? ''), '1'); ?>
|
|
<?php if ($manual && $vip1_on) aksrt_submit_pay_line(sprintf(__('%s积分', 'aksrt'), $vip1_name), 'aksrt_pay[vip1_points]', (string) ($pay['vip1_points'] ?? ''), '1'); ?>
|
|
<?php if ($manual && $vip2_on) aksrt_submit_pay_line(sprintf(__('%s积分', 'aksrt'), $vip2_name), 'aksrt_pay[vip2_points]', (string) ($pay['vip2_points'] ?? ''), '1'); ?>
|
|
<?php if ($manual && ($vip1_on || $vip2_on)) : ?><div class="px12 mt6 muted-color"><?php esc_html_e('会员价不能高于普通价,为0则为会员免费', 'aksrt'); ?></div><?php endif; ?>
|
|
</div>
|
|
|
|
<?php if (!empty($ctx['can_pay_download'])) : ?>
|
|
<div class="mt10 pay-dawnload-edit" data-pay-downloads>
|
|
<div class="flex ac jsb padding-h10">
|
|
<b><?php esc_html_e('付费下载', 'aksrt'); ?></b>
|
|
<div>
|
|
<button type="button" class="pay-dawnload-add but hollow p2-10 px12 c-blue" data-pay-download-add><i class="fa fas fa-plus mr3"></i><?php esc_html_e('添加资源', 'aksrt'); ?></button>
|
|
<?php if (!empty($ctx['can_upload_file'])) : ?><button type="button" class="but hollow p2-10 px12" data-pay-download-upload><i class="fa fas fa-upload mr3"></i><?php esc_html_e('上传附件', 'aksrt'); ?></button><?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="mt10 px12 lists-box" data-pay-download-list>
|
|
<?php foreach ($downloads as $index => $row) : ?>
|
|
<div class="flex ac jsb lists-item" data-pay-download-item>
|
|
<input class="form-control flex1" type="url" data-pay-download-url name="aksrt_pay[downloads][<?php echo (int) $index; ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>">
|
|
<input class="form-control" type="text" data-pay-download-label name="aksrt_pay[downloads][<?php echo (int) $index; ?>][label]" value="<?php echo esc_attr((string) ($row['label'] ?? '')); ?>" placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>">
|
|
<input class="form-control" type="text" name="aksrt_pay[downloads][<?php echo (int) $index; ?>][extract_code]" value="<?php echo esc_attr((string) ($row['extract_code'] ?? '')); ?>" placeholder="<?php esc_attr_e('提取码/备注', 'aksrt'); ?>">
|
|
<button type="button" class="but cir c-red" data-pay-download-remove><i class="fa fas fa-trash"></i></button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<template data-pay-download-tpl><div class="flex ac jsb lists-item" data-pay-download-item><input class="form-control flex1" type="url" data-name="url" data-pay-download-url placeholder="<?php esc_attr_e('资源链接', 'aksrt'); ?>"><input class="form-control" type="text" data-name="label" data-pay-download-label placeholder="<?php esc_attr_e('名称', 'aksrt'); ?>"><input class="form-control" type="text" data-name="extract_code" placeholder="<?php esc_attr_e('提取码/备注', 'aksrt'); ?>"><button type="button" class="but cir c-red" data-pay-download-remove><i class="fa fas fa-trash"></i></button></div></template>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="em09 mt10 muted-2-color"><?php esc_html_e('请确保已经在文中添加了付费可见的隐藏内容或已添加付费下载内容', 'aksrt'); ?></div>
|
|
</div>
|
|
<div class="em09 mt10 muted-2-color" data-pay-off-hint <?php echo $enabled ? 'hidden' : ''; ?>><?php esc_html_e('如果您在文章中添加了付费可见的隐藏内容或需要设置付费下载资源,请在此设置付费功能', 'aksrt'); ?></div>
|
|
</div>
|