272 lines
20 KiB
PHP
272 lines
20 KiB
PHP
<?php
|
|
/**
|
|
* Article paid-content fields shared by the block and classic editors.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
namespace AKSRT\Core;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
class ResourceMetaBox {
|
|
|
|
private static $instance = null;
|
|
|
|
private function __construct() {}
|
|
|
|
public static function get_instance(): self {
|
|
if (null === self::$instance) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
public function init(): void {
|
|
add_action('add_meta_boxes', [$this, 'register_meta_box']);
|
|
add_action('save_post_post', [$this, 'save'], 10, 2);
|
|
add_action('admin_enqueue_scripts', [$this, 'enqueue_assets']);
|
|
}
|
|
|
|
public function register_meta_box(): void {
|
|
add_meta_box('aksrt_pay_meta', __('付费功能', 'aksrt'), [$this, 'render'], 'post', 'normal', 'high');
|
|
}
|
|
|
|
public function enqueue_assets(string $hook): void {
|
|
if (!in_array($hook, ['post.php', 'post-new.php'], true)) {
|
|
return;
|
|
}
|
|
$screen = function_exists('get_current_screen') ? get_current_screen() : null;
|
|
if (!$screen || $screen->post_type !== 'post') {
|
|
return;
|
|
}
|
|
|
|
wp_enqueue_media();
|
|
$css = AKSRT_DIR . '/assets/css/admin/pay-meta-box.css';
|
|
$js = AKSRT_DIR . '/assets/js/admin-pay-meta-box.js';
|
|
if (is_file($css)) {
|
|
wp_enqueue_style('aksrt-pay-meta-box', AKSRT_URI . '/assets/css/admin/pay-meta-box.css', [], (string) filemtime($css));
|
|
}
|
|
if (is_file($js)) {
|
|
wp_enqueue_script('aksrt-pay-meta-box', AKSRT_URI . '/assets/js/admin-pay-meta-box.js', [], (string) filemtime($js), true);
|
|
}
|
|
}
|
|
|
|
public function render(\WP_Post $post): void {
|
|
wp_nonce_field('aksrt_pay_meta_save', 'aksrt_pay_meta_nonce');
|
|
$meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post) : DomainModel::default_pay_meta();
|
|
$gallery_ids = [];
|
|
foreach ((array) ($meta['gallery'] ?? []) as $url) {
|
|
$id = attachment_url_to_postid((string) $url);
|
|
if ($id > 0) {
|
|
$gallery_ids[] = $id;
|
|
}
|
|
}
|
|
?>
|
|
<div class="aksrt-pay-meta" data-aksrt-pay-meta>
|
|
<?php $this->radio('pay_type', __('付费模式', 'aksrt'), (string) ($meta['pay_type'] ?? 'no'), aksrt_get_pay_types()); ?>
|
|
<div data-pay-enabled>
|
|
<?php
|
|
$this->radio('pay_limit', __('购买权限', 'aksrt'), (string) ($meta['pay_limit'] ?? 0), [
|
|
'0' => __('所有人可购买', 'aksrt'),
|
|
'1' => __('VIP1 及以上会员可购买', 'aksrt'),
|
|
'2' => __('仅 VIP2 可购买', 'aksrt'),
|
|
], __('设置会员专享资源时,请同时配置对应的会员价格。', 'aksrt'));
|
|
$this->radio('pay_modo', __('支付类型', 'aksrt'), (string) ($meta['pay_modo'] ?? '0'), [
|
|
'0' => __('普通商品(金钱购买)', 'aksrt'),
|
|
'points' => __('积分商品(积分购买,依赖于用户积分功能)', 'aksrt'),
|
|
]);
|
|
?>
|
|
|
|
<div class="aksrt-pay-meta__field">
|
|
<div class="aksrt-pay-meta__title"><?php esc_html_e('订单时效', 'aksrt'); ?></div>
|
|
<div class="aksrt-pay-meta__control">
|
|
<label><input type="checkbox" name="aksrt_pay[order_expired_s]" value="1" <?php checked(!empty($meta['order_expired_s'])); ?> data-order-expired> <?php esc_html_e('启用订单有效期', 'aksrt'); ?></label>
|
|
<p class="description"><?php esc_html_e('购买后仅在有效期内可查看内容,超时后需再次购买。', 'aksrt'); ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="aksrt-pay-meta__field compact" data-order-expired-fields>
|
|
<div class="aksrt-pay-meta__title"><?php esc_html_e('有效时间', 'aksrt'); ?></div>
|
|
<div class="aksrt-pay-meta__control aksrt-pay-meta__inline">
|
|
<input type="number" min="0" step="1" name="aksrt_pay[order_expired_time]" value="<?php echo esc_attr((string) ($meta['order_expired_time'] ?? 0)); ?>">
|
|
<select name="aksrt_pay[order_expired_unit]">
|
|
<option value="day" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'day'); ?>><?php esc_html_e('天', 'aksrt'); ?></option>
|
|
<option value="hour" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'hour'); ?>><?php esc_html_e('小时', 'aksrt'); ?></option>
|
|
<option value="minute" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'minute'); ?>><?php esc_html_e('分钟', 'aksrt'); ?></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div data-pay-modo="points">
|
|
<?php $this->number('points_price', __('积分售价', 'aksrt'), (string) ($meta['points_price'] ?? 0), '1', __('积分', 'aksrt')); ?>
|
|
<?php $this->number('vip1_points', __('VIP1 积分售价', 'aksrt'), (string) ($meta['vip1_points'] ?? 0), '1', __('积分', 'aksrt'), __('填 0 则为 VIP1 免费', 'aksrt')); ?>
|
|
<?php $this->number('vip2_points', __('VIP2 积分售价', 'aksrt'), (string) ($meta['vip2_points'] ?? 0), '1', __('积分', 'aksrt'), __('会员价格不能高于售价,填 0 则为 VIP2 免费。', 'aksrt')); ?>
|
|
</div>
|
|
<div data-pay-modo="0">
|
|
<?php $this->number('price', __('执行价', 'aksrt'), (string) ($meta['price'] ?? '0.00'), '0.01', '', __('填 0 则为免费', 'aksrt')); ?>
|
|
<?php $this->number('original_price', __('原价', 'aksrt'), (string) ($meta['original_price'] ?? '0.00'), '0.01', '', __('显示在执行价格前面,并划掉。', 'aksrt')); ?>
|
|
<?php $this->textarea('promotion_tag', __('促销标签', 'aksrt'), (string) ($meta['promotion_tag'] ?? ''), 1); ?>
|
|
<?php $this->number('vip1_price', __('VIP1 价格', 'aksrt'), (string) ($meta['vip1_price'] ?? '0.00'), '0.01', '', __('填 0 则为 VIP1 免费', 'aksrt')); ?>
|
|
<?php $this->number('vip2_price', __('VIP2 价格', 'aksrt'), (string) ($meta['vip2_price'] ?? '0.00'), '0.01', '', __('会员价格不能高于执行价,填 0 则为 VIP2 免费。', 'aksrt')); ?>
|
|
</div>
|
|
|
|
<?php $this->number('pay_count', __('销量浮动', 'aksrt'), (string) ($meta['pay_count'] ?? 0), '1', '', __('为真实销量增加或减少的数量。', 'aksrt'), false); ?>
|
|
|
|
<div data-pay-type="gallery">
|
|
<div class="aksrt-pay-meta__field">
|
|
<div class="aksrt-pay-meta__title"><?php esc_html_e('付费图片', 'aksrt'); ?></div>
|
|
<div class="aksrt-pay-meta__control">
|
|
<input type="hidden" name="aksrt_pay[gallery_ids]" value="<?php echo esc_attr(implode(',', $gallery_ids)); ?>" data-gallery-input>
|
|
<div class="aksrt-pay-meta__gallery" data-gallery-preview></div>
|
|
<div class="aksrt-pay-meta__buttons"><button type="button" class="button" data-gallery-select><?php esc_html_e('新增图片', 'aksrt'); ?></button><button type="button" class="button-link-delete" data-gallery-clear><?php esc_html_e('清空图片', 'aksrt'); ?></button></div>
|
|
</div>
|
|
</div>
|
|
<?php $this->number('gallery_show', __('免费查看', 'aksrt'), (string) ($meta['gallery_show'] ?? 1), '1', __('张', 'aksrt'), __('不能大于付费图片数量,否则无效。', 'aksrt')); ?>
|
|
</div>
|
|
|
|
<div data-pay-type="video">
|
|
<?php $this->upload('video_url', __('视频资源', 'aksrt'), (string) ($meta['video_url'] ?? ''), 'video', __('输入视频地址或选择、上传本地视频。', 'aksrt')); ?>
|
|
<?php $this->upload('video_pic', __('视频封面(可选)', 'aksrt'), (string) ($meta['video_pic'] ?? ''), 'image'); ?>
|
|
<?php $this->text('video_title', __('本集标题', 'aksrt'), (string) ($meta['video_title'] ?? ''), __('如需添加剧集则需填写此处', 'aksrt'), __('第1集', 'aksrt')); ?>
|
|
<?php $this->group('video_episode', __('更多剧集', 'aksrt'), (array) ($meta['video_episode'] ?? []), 'video_row', __('添加剧集', 'aksrt'), __('为付费视频添加更多剧集。', 'aksrt')); ?>
|
|
<?php $this->number('video_scale_height', __('固定长宽比例', 'aksrt'), (string) ($meta['video_scale_height'] ?? 0), '5', '%', __('为 0 则不固定长宽比例。', 'aksrt')); ?>
|
|
</div>
|
|
|
|
<div data-pay-type="download">
|
|
<?php $this->group('downloads', __('资源下载', 'aksrt'), (array) ($meta['downloads'] ?? []), 'download_row', __('添加资源', 'aksrt')); ?>
|
|
<?php $this->group('attributes', __('资源属性', 'aksrt'), (array) ($meta['attributes'] ?? []), 'attribute_row', __('添加属性', 'aksrt')); ?>
|
|
<?php $this->text('demo_url', __('演示地址', 'aksrt'), (string) ($meta['demo_url'] ?? ''), '', 'https://', 'url'); ?>
|
|
</div>
|
|
|
|
<?php $this->text('pay_title', __('商品标题', 'aksrt'), (string) ($meta['pay_title'] ?? ''), __('可选,如需单独显示付费内容标题请填写。', 'aksrt')); ?>
|
|
<?php $this->textarea('pay_doc', __('商品简介', 'aksrt'), (string) ($meta['pay_doc'] ?? ''), 1, __('可选,如需单独显示付费内容介绍请填写。', 'aksrt')); ?>
|
|
<?php $this->textarea('pay_details', __('更多详情', 'aksrt'), (string) ($meta['pay_details'] ?? ''), 3, __('显示在付费内容卡片下方,支持安全 HTML。', 'aksrt')); ?>
|
|
<?php $this->textarea('pay_extra_hide', __('额外隐藏内容', 'aksrt'), (string) ($meta['pay_extra_hide'] ?? ''), 3, __('付费后显示的额外隐藏内容,支持安全 HTML。', 'aksrt')); ?>
|
|
|
|
<div class="aksrt-pay-meta__notice"><strong><?php esc_html_e('付费阅读', 'aksrt'); ?></strong> <?php esc_html_e('需配合古腾堡“隐藏内容块”或经典编辑器短代码使用:', 'aksrt'); ?> <code>[hidecontent type="payshow"]</code> <?php esc_html_e('隐藏内容', 'aksrt'); ?> <code>[/hidecontent]</code></div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/** @param array<string, string> $options */
|
|
private function radio(string $id, string $title, string $value, array $options, string $description = ''): void {
|
|
?>
|
|
<fieldset class="aksrt-pay-meta__field"><legend class="aksrt-pay-meta__title"><?php echo esc_html($title); ?></legend><div class="aksrt-pay-meta__control aksrt-pay-meta__radios">
|
|
<?php foreach ($options as $option => $label) : ?><label><input type="radio" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr((string) $option); ?>" <?php checked($value, (string) $option); ?>> <?php echo esc_html($label); ?></label><?php endforeach; ?>
|
|
<?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?>
|
|
</div></fieldset>
|
|
<?php
|
|
}
|
|
|
|
private function number(string $id, string $title, string $value, string $step, string $unit = '', string $description = '', bool $non_negative = true): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><div class="aksrt-pay-meta__number"><input id="aksrt-pay-<?php echo esc_attr($id); ?>" type="number" <?php echo $non_negative ? 'min="0"' : ''; ?> step="<?php echo esc_attr($step); ?>" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>"><?php if ($unit !== '') : ?><span><?php echo esc_html($unit); ?></span><?php endif; ?></div><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
|
<?php
|
|
}
|
|
|
|
private function text(string $id, string $title, string $value, string $description = '', string $placeholder = '', string $type = 'text'): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><input id="aksrt-pay-<?php echo esc_attr($id); ?>" type="<?php echo esc_attr($type); ?>" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" placeholder="<?php echo esc_attr($placeholder); ?>"><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
|
<?php
|
|
}
|
|
|
|
private function textarea(string $id, string $title, string $value, int $rows, string $description = ''): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><textarea id="aksrt-pay-<?php echo esc_attr($id); ?>" rows="<?php echo esc_attr((string) $rows); ?>" name="aksrt_pay[<?php echo esc_attr($id); ?>]"><?php echo esc_textarea($value); ?></textarea><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
|
<?php
|
|
}
|
|
|
|
private function upload(string $id, string $title, string $value, string $library, string $description = ''): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><div class="aksrt-pay-meta__upload"><input id="aksrt-pay-<?php echo esc_attr($id); ?>" type="url" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" data-media-input><button type="button" class="button" data-media-select data-library="<?php echo esc_attr($library); ?>"><?php esc_html_e('选择', 'aksrt'); ?></button><button type="button" class="button-link-delete" data-media-clear><?php esc_html_e('移除', 'aksrt'); ?></button></div><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
|
<?php
|
|
}
|
|
|
|
/** @param array<int, array<string, mixed>> $rows */
|
|
private function group(string $id, string $title, array $rows, string $renderer, string $button, string $description = ''): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><?php echo esc_html($title); ?></div><div class="aksrt-pay-meta__control"><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?><div data-group-list="<?php echo esc_attr($id); ?>"><?php foreach ($rows as $index => $row) { $this->{$renderer}((int) $index, (array) $row); } ?></div><button type="button" class="button" data-group-add="<?php echo esc_attr($id); ?>"><?php echo esc_html($button); ?></button><template data-group-template="<?php echo esc_attr($id); ?>"><?php $this->{$renderer}('__INDEX__', []); ?></template></div></div>
|
|
<?php
|
|
}
|
|
|
|
/** @param int|string $index */
|
|
private function video_row($index, array $row): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__group" data-group-row><input type="text" name="aksrt_pay[video_episode][<?php echo esc_attr((string) $index); ?>][title]" value="<?php echo esc_attr((string) ($row['title'] ?? '')); ?>" placeholder="<?php esc_attr_e('剧集标题', 'aksrt'); ?>"><div class="aksrt-pay-meta__upload"><input type="url" name="aksrt_pay[video_episode][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('选择视频或填写视频地址', 'aksrt'); ?>" data-media-input><button type="button" class="button" data-media-select data-library="video"><?php esc_html_e('选择', 'aksrt'); ?></button></div><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
|
|
<?php
|
|
}
|
|
|
|
/** @param int|string $index */
|
|
private function download_row($index, array $row): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__group" data-group-row><div class="aksrt-pay-meta__upload"><input type="url" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('上传文件或输入下载地址', 'aksrt'); ?>" data-media-input><button type="button" class="button" data-media-select data-library=""><?php esc_html_e('选择', 'aksrt'); ?></button></div><input type="text" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][label]" value="<?php echo esc_attr((string) ($row['label'] ?? '')); ?>" placeholder="<?php esc_attr_e('按钮文案', 'aksrt'); ?>"><textarea rows="1" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][extract_code]" placeholder="<?php esc_attr_e('资源备注、提取码或解压密码', 'aksrt'); ?>"><?php echo esc_textarea((string) ($row['extract_code'] ?? '')); ?></textarea><input type="hidden" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][copy_key]" value="<?php echo esc_attr((string) ($row['copy_key'] ?? '')); ?>"><input type="hidden" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][copy_val]" value="<?php echo esc_attr((string) ($row['copy_val'] ?? '')); ?>"><input type="hidden" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][class]" value="<?php echo esc_attr((string) ($row['class'] ?? '')); ?>"><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
|
|
<?php
|
|
}
|
|
|
|
/** @param int|string $index */
|
|
private function attribute_row($index, array $row): void {
|
|
?>
|
|
<div class="aksrt-pay-meta__group aksrt-pay-meta__group--inline" data-group-row><input type="text" name="aksrt_pay[attributes][<?php echo esc_attr((string) $index); ?>][key]" value="<?php echo esc_attr((string) ($row['key'] ?? '')); ?>" placeholder="<?php esc_attr_e('属性名称', 'aksrt'); ?>"><input type="text" name="aksrt_pay[attributes][<?php echo esc_attr((string) $index); ?>][value]" value="<?php echo esc_attr((string) ($row['value'] ?? '')); ?>" placeholder="<?php esc_attr_e('属性内容', 'aksrt'); ?>"><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
|
|
<?php
|
|
}
|
|
|
|
public function save(int $post_id, \WP_Post $post): void {
|
|
if ($post->post_type !== 'post' || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || wp_is_post_revision($post_id) || !current_user_can('edit_post', $post_id)) {
|
|
return;
|
|
}
|
|
if (empty($_POST['aksrt_pay_meta_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['aksrt_pay_meta_nonce'])), 'aksrt_pay_meta_save')) {
|
|
return;
|
|
}
|
|
|
|
$raw = isset($_POST['aksrt_pay']) && is_array($_POST['aksrt_pay']) ? wp_unslash($_POST['aksrt_pay']) : [];
|
|
$gallery = [];
|
|
$ids = array_values(array_filter(array_map('absint', preg_split('/[\s,]+/', (string) ($raw['gallery_ids'] ?? '')) ?: [])));
|
|
foreach (array_slice($ids, 0, 100) as $attachment_id) {
|
|
$url = wp_get_attachment_image_url($attachment_id, 'full');
|
|
if ($url) {
|
|
$gallery[] = $url;
|
|
}
|
|
}
|
|
|
|
$meta = DomainModel::sanitize_pay_meta([
|
|
'pay_type' => $raw['pay_type'] ?? 'no',
|
|
'pay_limit' => $raw['pay_limit'] ?? 0,
|
|
'pay_modo' => $raw['pay_modo'] ?? '0',
|
|
'order_expired_s' => !empty($raw['order_expired_s']),
|
|
'order_expired_time' => $raw['order_expired_time'] ?? 0,
|
|
'order_expired_unit' => $raw['order_expired_unit'] ?? 'day',
|
|
'price' => (string) ($raw['price'] ?? '0'),
|
|
'points_price' => $raw['points_price'] ?? 0,
|
|
'original_price' => (string) ($raw['original_price'] ?? '0'),
|
|
'promotion_tag' => (string) ($raw['promotion_tag'] ?? ''),
|
|
'vip1_price' => (string) ($raw['vip1_price'] ?? '0'),
|
|
'vip2_price' => (string) ($raw['vip2_price'] ?? '0'),
|
|
'vip1_points' => $raw['vip1_points'] ?? 0,
|
|
'vip2_points' => $raw['vip2_points'] ?? 0,
|
|
'pay_count' => $raw['pay_count'] ?? 0,
|
|
'gallery' => $gallery,
|
|
'gallery_show' => $raw['gallery_show'] ?? 1,
|
|
'video_url' => (string) ($raw['video_url'] ?? ''),
|
|
'video_pic' => (string) ($raw['video_pic'] ?? ''),
|
|
'video_title' => (string) ($raw['video_title'] ?? ''),
|
|
'video_episode' => $raw['video_episode'] ?? [],
|
|
'video_scale_height' => $raw['video_scale_height'] ?? 0,
|
|
'downloads' => $raw['downloads'] ?? [],
|
|
'attributes' => $raw['attributes'] ?? [],
|
|
'demo_url' => (string) ($raw['demo_url'] ?? ''),
|
|
'pay_title' => (string) ($raw['pay_title'] ?? ''),
|
|
'pay_doc' => (string) ($raw['pay_doc'] ?? ''),
|
|
'pay_details' => (string) ($raw['pay_details'] ?? ''),
|
|
'pay_extra_hide' => (string) ($raw['pay_extra_hide'] ?? ''),
|
|
]);
|
|
|
|
update_post_meta($post_id, DomainModel::PAY_META_KEY, $meta);
|
|
update_post_meta($post_id, DomainModel::PAY_TYPE_KEY, (string) $meta['pay_type']);
|
|
update_post_meta($post_id, DomainModel::PAY_PRICE_KEY, $meta['pay_modo'] === 'points' ? (int) $meta['points_price'] : (string) $meta['price']);
|
|
update_post_meta($post_id, '_aksrt_pay_modo', (string) $meta['pay_modo']);
|
|
update_post_meta($post_id, '_aksrt_pay_limit', (int) $meta['pay_limit']);
|
|
update_post_meta($post_id, DomainModel::RESOURCE_MARKER_KEY, DomainModel::is_resource_pay_type((string) $meta['pay_type']) ? 1 : 0);
|
|
}
|
|
}
|