进行了一些小修复
This commit is contained in:
@@ -86,6 +86,11 @@ if (file_exists($js)) {
|
||||
'summary' => !empty($ctx['ai_available']),
|
||||
'tags' => !empty($ctx['ai_available']),
|
||||
],
|
||||
'editor' => [
|
||||
'canUploadImage' => !empty($ctx['can_upload_img']),
|
||||
'canHide' => !empty($ctx['can_hide']),
|
||||
'canPay' => !empty($ctx['can_pay']),
|
||||
],
|
||||
'uploads' => [
|
||||
'image' => !empty($ctx['can_upload_img']) ? [
|
||||
'url' => esc_url_raw(rest_url('aksrt/v1/front-submit/upload/image')),
|
||||
@@ -118,6 +123,25 @@ if (file_exists($js)) {
|
||||
'pickImage' => __('选择图片', 'aksrt'),
|
||||
'pickVideo' => __('选择视频封面图', 'aksrt'),
|
||||
'videoUrl' => __('请输入视频地址', 'aksrt'),
|
||||
'close' => __('关闭', 'aksrt'),
|
||||
'insertImage' => __('插入图片', 'aksrt'),
|
||||
'uploadImage' => __('上传图片', 'aksrt'),
|
||||
'externalImage' => __('外链图片', 'aksrt'),
|
||||
'selectImages' => __('选择或拖入图片', 'aksrt'),
|
||||
'imageUploadHint' => __('可批量选择,上传完成后自动插入正文', 'aksrt'),
|
||||
'selectedImages' => __('已选择 %d 张图片', 'aksrt'),
|
||||
'confirmUpload' => __('确认上传', 'aksrt'),
|
||||
'externalImageHint' => __('每行填写一个图片地址:', 'aksrt'),
|
||||
'confirmInsert' => __('确认插入', 'aksrt'),
|
||||
'invalidImage' => __('请选择有效的图片文件', 'aksrt'),
|
||||
'invalidImageUrl' => __('请填写有效的图片地址', 'aksrt'),
|
||||
'uploadUnavailable' => __('当前账号不能上传图片', 'aksrt'),
|
||||
'hiddenContent' => __('隐藏内容', 'aksrt'),
|
||||
'hiddenPlaceholder' => __('隐藏内容', 'aksrt'),
|
||||
'replyVisible' => __('回复可见', 'aksrt'),
|
||||
'loginVisible' => __('登录可见', 'aksrt'),
|
||||
'vipVisible' => __('VIP 可见', 'aksrt'),
|
||||
'payVisible' => __('付费可见', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,36 @@ $is_can_new = !empty($ctx['is_can_new']);
|
||||
<?php else : ?>
|
||||
<div class="newposts-editor">
|
||||
<?php
|
||||
$toolbar1 = 'formatselect,bold,italic,bullist,numlist,alignleft,aligncenter,alignright,link,blockquote,code,fullscreen';
|
||||
$toolbar1 = ['formatselect', 'bold', 'italic', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'link'];
|
||||
if (!empty($ctx['can_upload_img'])) {
|
||||
$toolbar1[] = 'aksrt_image';
|
||||
}
|
||||
if (!empty($ctx['can_hide'])) {
|
||||
$toolbar1[] = 'aksrt_hide';
|
||||
}
|
||||
$toolbar1 = implode(',', array_merge($toolbar1, ['blockquote', 'code', 'fullscreen']));
|
||||
$plugins = 'paste,link,lists,fullscreen,wordpress,wplink,charmap';
|
||||
$editor_plugin_path = get_template_directory() . '/assets/js/front-submit-editor.js';
|
||||
$editor_plugin_url = get_template_directory_uri() . '/assets/js/front-submit-editor.js';
|
||||
if (file_exists($editor_plugin_path)) {
|
||||
$editor_plugin_url = add_query_arg('ver', (string) filemtime($editor_plugin_path), $editor_plugin_url);
|
||||
}
|
||||
$editor_css_path = get_template_directory() . '/assets/css/frontend/pages/submit-editor.css';
|
||||
$editor_css_url = get_template_directory_uri() . '/assets/css/frontend/pages/submit-editor.css';
|
||||
if (file_exists($editor_css_path)) {
|
||||
$editor_css_url = add_query_arg('ver', (string) filemtime($editor_css_path), $editor_css_url);
|
||||
}
|
||||
$external_plugins = static function (array $external, string $editor_id) use ($editor_plugin_url): array {
|
||||
if ($editor_id === 'post_content') {
|
||||
$external['aksrt_editor_tools'] = $editor_plugin_url;
|
||||
}
|
||||
return $external;
|
||||
};
|
||||
$editor_content_css = static function (string $styles) use ($editor_css_url): string {
|
||||
return $styles . ($styles !== '' ? ',' : '') . $editor_css_url;
|
||||
};
|
||||
add_filter('mce_external_plugins', $external_plugins, 10, 2);
|
||||
add_filter('mce_css', $editor_content_css);
|
||||
$editor_settings = [
|
||||
'textarea_name' => 'post_content',
|
||||
'textarea_rows' => 20,
|
||||
@@ -61,34 +89,10 @@ $is_can_new = !empty($ctx['is_can_new']);
|
||||
],
|
||||
];
|
||||
wp_editor((string) $ctx['current_content'], 'post_content', $editor_settings);
|
||||
remove_filter('mce_external_plugins', $external_plugins, 10);
|
||||
remove_filter('mce_css', $editor_content_css, 10);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($ctx['can_hide']) || !empty($ctx['can_pay']) || !empty($ctx['can_upload_img'])) : ?>
|
||||
<div class="newposts-editor-tools">
|
||||
<?php if (!empty($ctx['can_upload_img'])) : ?>
|
||||
<button type="button" class="but" data-insert-upload-image>
|
||||
<i class="fa fas fa-image"></i> <?php esc_html_e('上传图片', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ctx['can_hide'])) : ?>
|
||||
<button type="button" class="but" data-insert-shortcode="hide" title="<?php esc_attr_e('插入登录后可见', 'aksrt'); ?>">
|
||||
<i class="fa fas fa-eye-slash"></i> <?php esc_html_e('登录可见', 'aksrt'); ?>
|
||||
</button>
|
||||
<button type="button" class="but" data-insert-shortcode="reply" title="<?php esc_attr_e('插入回复后可见', 'aksrt'); ?>">
|
||||
<i class="fa fas fa-comment-dots"></i> <?php esc_html_e('回复可见', 'aksrt'); ?>
|
||||
</button>
|
||||
<button type="button" class="but" data-insert-shortcode="vip" title="<?php esc_attr_e('插入 VIP 可见', 'aksrt'); ?>">
|
||||
<i class="fa fas fa-certificate"></i> <?php esc_html_e('VIP 可见', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ctx['can_pay'])) : ?>
|
||||
<button type="button" class="but" data-insert-shortcode="payshow" title="<?php esc_attr_e('插入付费可见内容', 'aksrt'); ?>">
|
||||
<i class="fa fas fa-lock"></i> <?php esc_html_e('付费可见', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="flex ac jsb mt10">
|
||||
|
||||
Reference in New Issue
Block a user