86 lines
3.4 KiB
PHP
86 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Submit actions + drafts list.
|
|
*
|
|
* @var array $ctx
|
|
* @package AKSRT
|
|
*/
|
|
defined('ABSPATH') || exit;
|
|
|
|
$settings = $ctx['settings'];
|
|
$is_can_new = !empty($ctx['is_can_new']);
|
|
$edit_post = $ctx['edit_post'];
|
|
$status = (string) $ctx['post_status'];
|
|
$can_draft = !empty($ctx['user_id']) && empty($ctx['is_guest']) && !empty($settings['draft_save']);
|
|
if ($edit_post && in_array($status, ['publish', 'pending'], true)) {
|
|
// Still allow draft button? zibll hides draft for publish/pending.
|
|
$can_draft = false;
|
|
}
|
|
?>
|
|
<div class="aksrt-submit-panel">
|
|
<div class="aksrt-submit-panel__body aksrt-submit-actions">
|
|
<p class="aksrt-submit-ready"><?php esc_html_e('Are you ready', 'aksrt'); ?></p>
|
|
|
|
<input type="hidden" name="posts_id" value="<?php echo esc_attr((string) (int) $ctx['edit_id']); ?>">
|
|
<input type="hidden" name="status" id="submit-status" value="pending">
|
|
<input type="hidden" name="_nonce" value="<?php echo esc_attr(wp_create_nonce('aksrt_submit')); ?>">
|
|
|
|
<?php if (!$is_can_new) : ?>
|
|
<p class="aksrt-submit-hint"><?php esc_html_e('暂无发布权限', 'aksrt'); ?></p>
|
|
<?php else : ?>
|
|
<?php if (!empty($ctx['is_guest'])) : ?>
|
|
<p class="aksrt-submit-hint"><?php esc_html_e('您当前未登录,不能保存草稿,文章提交后不可再修改!', 'aksrt'); ?></p>
|
|
<?php endif; ?>
|
|
|
|
<?php if (function_exists('aksrt_is_captcha_enabled_for') && function_exists('aksrt_render_captcha') && aksrt_is_captcha_enabled_for('front_submit')) : ?>
|
|
<div class="aksrt-submit-captcha">
|
|
<?php aksrt_render_captcha('front_submit'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="aksrt-submit-actions__btns">
|
|
<?php if ($can_draft) : ?>
|
|
<button type="button" class="but jb-green aksrt-submit-btn" data-action="posts_draft">
|
|
<i class="fa fas fa-dot-circle"></i> <?php esc_html_e('保存草稿', 'aksrt'); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
<button type="button" class="but jb-blue aksrt-submit-btn" data-action="posts_save" id="aksrt-submit-btn">
|
|
<i class="fa fas fa-check-square"></i>
|
|
<?php
|
|
printf(
|
|
/* translators: %s: 发布|审核|保存 */
|
|
esc_html__('提交%s', 'aksrt'),
|
|
esc_html((string) $ctx['submit_label'])
|
|
);
|
|
?>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty($ctx['user_drafts'])) : ?>
|
|
<div class="aksrt-submit-panel aksrt-submit-drafts">
|
|
<div class="aksrt-submit-panel__title">
|
|
<i class="fa fas fa-file-alt"></i> <?php esc_html_e('我的草稿', 'aksrt'); ?>
|
|
</div>
|
|
<div class="aksrt-submit-panel__body">
|
|
<?php foreach ($ctx['user_drafts'] as $draft) :
|
|
$edit_url = function_exists('aksrt_get_new_post_url')
|
|
? aksrt_get_new_post_url((int) $draft->ID)
|
|
: add_query_arg('edit', $draft->ID, get_permalink());
|
|
?>
|
|
<div class="aksrt-submit-drafts__item" data-draft-id="<?php echo esc_attr((string) $draft->ID); ?>">
|
|
<a href="<?php echo esc_url($edit_url); ?>" class="aksrt-submit-drafts__link">
|
|
<span class="aksrt-submit-drafts__name"><?php echo esc_html($draft->post_title ?: __('无标题', 'aksrt')); ?></span>
|
|
<time><?php echo esc_html(get_the_modified_date('Y-m-d H:i', $draft)); ?></time>
|
|
</a>
|
|
<button type="button" class="aksrt-submit-drafts__delete" data-draft-id="<?php echo esc_attr((string) $draft->ID); ?>" title="<?php esc_attr_e('删除草稿', 'aksrt'); ?>">
|
|
<i class="fa fas fa-trash-alt"></i>
|
|
</button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|