feat: add smtp test function (#141)

pull/155/head
Seaton Jiang 2020-02-23 15:03:21 +08:00
parent ad7cd532e8
commit c26ab00926
6 changed files with 352 additions and 317 deletions

View File

@ -62,6 +62,7 @@ class Options_Framework_Admin {
// Displays notice after options save
add_action( 'optionsframework_after_validate', array( $this, 'save_options_notice' ) );
add_action( 'optionsframework_after_sendmail', array( $this, 'send_mail_notice' ) );
}
public function add_top_options_page()
@ -252,20 +253,27 @@ class Options_Framework_Admin {
}
}
// Hook to run after validation
do_action( 'optionsframework_after_validate', $clean );
if ( isset( $_POST['sendmail'] ) ) {
wp_mail( get_bloginfo( 'admin_email' ) ,__('[测试]邮件服务配置成功', 'kratos'),__('恭喜您 SMTP 邮件服务配置成功!', 'kratos'));
do_action( 'optionsframework_after_sendmail', $clean );
return $clean;
} else {
do_action( 'optionsframework_after_validate', $clean );
return $clean;
}
}
/**
* Display message when options have been saved
*/
function save_options_notice() {
add_settings_error( 'options-framework', 'save_options', __( '保存成功', 'kratos' ), 'updated fade' );
}
function send_mail_notice() {
add_settings_error( 'options-framework', 'send_mail', __( '发送完成,请留意邮箱:' . get_bloginfo( 'admin_email' ), 'kratos' ), 'updated fade' );
}
/**
* Get the default values for all the theme options
*

View File

@ -7,12 +7,14 @@
* @copyright 2010-2014 WP Theming
*/
class Options_Framework_Interface {
class Options_Framework_Interface
{
/**
* Generates the tabs that are used in the options menu
*/
static function optionsframework_tabs() {
public static function optionsframework_tabs()
{
$counter = 0;
$options = &Options_Framework::_optionsframework_options();
$menu = '';
@ -34,7 +36,8 @@ class Options_Framework_Interface {
/**
* Generates the options fields that are used in the form.
*/
static function optionsframework_fields() {
public static function optionsframework_fields()
{
global $allowedtags;
@ -74,8 +77,7 @@ class Options_Framework_Interface {
}
if ($value['type'] != 'editor') {
$output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
}
else {
} else {
$output .= '<div class="option">' . "\n" . '<div>' . "\n";
}
}
@ -112,7 +114,6 @@ class Options_Framework_Interface {
$output .= apply_filters('optionsframework_' . $value['type'], $option_name, $value, $val);
}
switch ($value['type']) {
// Basic text input
@ -150,7 +151,6 @@ class Options_Framework_Interface {
$output .= '</select>';
break;
// Radio Box
case "radio":
$name = $option_name . '[' . $value['id'] . ']';
@ -184,9 +184,11 @@ class Options_Framework_Interface {
case "color":
$default_color = '';
if (isset($value['std'])) {
if ( $val != $value['std'] )
if ($val != $value['std']) {
$default_color = ' data-default-color="' . $value['std'] . '" ';
}
}
$output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" class="of-color" type="text" value="' . esc_attr($val) . '"' . $default_color . ' />';
break;
@ -223,8 +225,7 @@ class Options_Framework_Interface {
case "about":
global $wp_version;
$version = $wp_version;
$output .= '<div class="section section-info">
<div class="about-content">
$output .= '<div class="about-content">
<img src="' . get_template_directory_uri() . '/inc/options-framework/images/about.png">
<h4>' . __('基础信息', 'kratos') . '</h3>
<ul>
@ -248,9 +249,11 @@ class Options_Framework_Interface {
<h4>' . __('打赏支持', 'kratos') . '</h3>
<img src="' . get_template_directory_uri() . '/inc/options-framework/images/donate.png">
<p class="tips">' . __('项目的发展需要您的支持和鼓励,打赏时请确认作者姓名为<b>姜学栋</b>', 'kratos') . '</p>
</div>
</div>';
break;
case "sendmail":
$output .= '<input type="submit" name="sendmail" class="button-secondary" value="' . __('测试邮件', 'kratos') . '">';
break;
// Heading for Navigation

View File

@ -32,6 +32,7 @@ jQuery(document).ready(function($) {
jQuery('#section-m_port').fadeToggle(400);
jQuery('#section-m_username').fadeToggle(400);
jQuery('#section-m_passwd').fadeToggle(400);
jQuery('#section-m_sendmail').fadeToggle(400);
});
if (jQuery('#m_smtp:checked').val() !== undefined) {
@ -40,6 +41,7 @@ jQuery(document).ready(function($) {
jQuery('#section-m_port').show();
jQuery('#section-m_username').show();
jQuery('#section-m_passwd').show();
jQuery('#section-m_sendmail').show();
}
// Loads the color pickers

View File

@ -3,7 +3,7 @@
* 主题选项
* @author Seaton Jiang <seaton@vtrois.com>
* @license MIT License
* @version 2020.02.15
* @version 2020.02.23
*/
function getrobots()
@ -326,6 +326,12 @@ function kratos_options()
'type' => 'password',
);
$options[] = array(
'id' => 'm_sendmail',
'class' => 'hidden',
'type' => 'sendmail',
);
$options[] = array(
'name' => __('顶部配置', 'kratos'),
'type' => 'heading',

View File

@ -3,7 +3,7 @@
* 侧栏小工具
* @author Seaton Jiang <seaton@vtrois.com>
* @license MIT License
* @version 2020.02.22
* @version 2020.02.23
*/
// 添加小工具

View File

@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Project-Id-Version: Kratos\n"
"POT-Creation-Date: 2020-02-22 15:03+0800\n"
"POT-Creation-Date: 2020-02-23 15:01+0800\n"
"PO-Revision-Date: 2020-02-14 23:32+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -66,84 +66,96 @@ msgstr ""
msgid "搜点什么呢?"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:70
#: inc/options-framework/includes/class-options-framework-admin.php:71
#: inc/options-framework/includes/class-options-framework-admin.php:84
#: inc/options-framework/includes/class-options-framework-admin.php:72
#: inc/options-framework/includes/class-options-framework-admin.php:85
#: inc/options-framework/includes/class-options-framework-admin.php:86
msgid "主题设置"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:180
#: inc/options-framework/includes/class-options-framework-admin.php:181
msgid "保存配置"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:181
#: inc/options-framework/includes/class-options-framework-admin.php:182
msgid "恢复默认"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:181
#: inc/options-framework/includes/class-options-framework-admin.php:182
msgid "单击「确定」进行恢复,但所有的配置都将丢失!"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:212
#: inc/options-framework/includes/class-options-framework-admin.php:213
msgid "恢复完成"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:266
#: inc/options-framework/includes/class-options-framework-admin.php:257
msgid "[测试]邮件服务配置成功"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:257
msgid "恭喜您 SMTP 邮件服务配置成功!"
msgstr ""
#: inc/options-framework/includes/class-options-framework-admin.php:270
msgid "保存成功"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:229
#: inc/options-framework/includes/class-options-framework-admin.php:274
msgid "发送完成,请留意邮箱:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:230
msgid "基础信息"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:231
#: inc/options-framework/includes/class-options-interface.php:232
msgid "PHP 版本:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:232
#: inc/options-framework/includes/class-options-interface.php:233
msgid "Kratos 版本:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:233
#: inc/options-framework/includes/class-options-interface.php:234
msgid "WordPress 版本:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:234
#: inc/options-framework/includes/class-options-interface.php:235
msgid "User Agent 信息:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:236
#: inc/options-framework/includes/class-options-interface.php:237
msgid ""
"提示:在提交主题相关问题反馈时,请将上面「基础信息」中的内容复制到环境信息"
"中。"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:237
#: inc/options-framework/includes/class-options-interface.php:238
msgid "资料文档"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:239
#: inc/options-framework/includes/class-options-interface.php:240
msgid "说明文档:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:240
#: inc/options-framework/includes/class-options-interface.php:241
msgid "代码托管:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:241
#: inc/options-framework/includes/class-options-interface.php:242
msgid "问题反馈:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:242
#: inc/options-framework/includes/class-options-interface.php:243
msgid "更新日志:"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:244
#: inc/options-framework/includes/class-options-interface.php:245
msgid "讨论交流"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:245
#: inc/options-framework/includes/class-options-interface.php:246
msgid ""
"欢迎使用 Kratos 主题开始文章创作,诚邀您加入主题交流 QQ 群:<a href="
"\"https://shang.qq.com/wpa/qunwpa?"
@ -151,11 +163,11 @@ msgid ""
"target=\"_blank\">734508</a>"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:246
#: inc/options-framework/includes/class-options-interface.php:247
msgid "版权声明"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:247
#: inc/options-framework/includes/class-options-interface.php:248
msgid ""
"主题源码使用 <a href=\"https://github.com/Vtrois/Kratos/blob/master/LICENSE"
"\" target=\"_blank\">MIT 协议</a> 进行许可,说明文档使用 <a href=\"https://"
@ -163,14 +175,18 @@ msgid ""
"4.0</a> 进行许可。"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:248
#: inc/options-framework/includes/class-options-interface.php:249
msgid "打赏支持"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:250
#: inc/options-framework/includes/class-options-interface.php:251
msgid "项目的发展需要您的支持和鼓励,打赏时请确认作者姓名为<b>姜学栋</b>"
msgstr ""
#: inc/options-framework/includes/class-options-interface.php:256
msgid "测试邮件"
msgstr ""
#: inc/options-framework/includes/class-options-media-uploader.php:62
msgid "没有选择任何文件"
msgstr ""
@ -457,7 +473,7 @@ msgstr ""
msgid "个人昵称"
msgstr ""
#: inc/theme-options.php:271 inc/theme-widgets.php:146
#: inc/theme-options.php:271 inc/theme-widgets.php:140
msgid "个人简介"
msgstr ""
@ -513,123 +529,123 @@ msgstr ""
msgid "填写邮箱密码"
msgstr ""
#: inc/theme-options.php:330
#: inc/theme-options.php:336
msgid "顶部配置"
msgstr ""
#: inc/theme-options.php:335
#: inc/theme-options.php:341
msgid "顶部图片"
msgstr ""
#: inc/theme-options.php:342
#: inc/theme-options.php:348
msgid "副标题"
msgstr ""
#: inc/theme-options.php:349
#: inc/theme-options.php:355
msgid "标题描述"
msgstr ""
#: inc/theme-options.php:356
#: inc/theme-options.php:362
msgid "页脚配置"
msgstr ""
#: inc/theme-options.php:361
#: inc/theme-options.php:367
msgid "选择需要开启的社交图标"
msgstr ""
#: inc/theme-options.php:362
#: inc/theme-options.php:368
msgid "国内平台"
msgstr ""
#: inc/theme-options.php:367
#: inc/theme-options.php:373
msgid "新浪微博"
msgstr ""
#: inc/theme-options.php:380
#: inc/theme-options.php:386
msgid "哔哩哔哩"
msgstr ""
#: inc/theme-options.php:393
#: inc/theme-options.php:399
msgid "CODING"
msgstr ""
#: inc/theme-options.php:406
#: inc/theme-options.php:412
msgid "码云 Gitee"
msgstr ""
#: inc/theme-options.php:419
#: inc/theme-options.php:425
msgid "海外平台"
msgstr ""
#: inc/theme-options.php:424
#: inc/theme-options.php:430
msgid "Twitter"
msgstr ""
#: inc/theme-options.php:437
#: inc/theme-options.php:443
msgid "Telegram"
msgstr ""
#: inc/theme-options.php:450
#: inc/theme-options.php:456
msgid "LinkedIn"
msgstr ""
#: inc/theme-options.php:463
#: inc/theme-options.php:469
msgid "YouTube"
msgstr ""
#: inc/theme-options.php:476
#: inc/theme-options.php:482
msgid "Github"
msgstr ""
#: inc/theme-options.php:489
#: inc/theme-options.php:495
msgid "Stack Overflow"
msgstr ""
#: inc/theme-options.php:502
#: inc/theme-options.php:508
msgid "其他"
msgstr ""
#: inc/theme-options.php:507
#: inc/theme-options.php:513
msgid "电子邮箱"
msgstr ""
#: inc/theme-options.php:520
#: inc/theme-options.php:526
msgid "工信部备案信息"
msgstr ""
#: inc/theme-options.php:527
#: inc/theme-options.php:533
msgid "公安网备案信息"
msgstr ""
#: inc/theme-options.php:534
#: inc/theme-options.php:540
msgid "公安网备案连接"
msgstr ""
#: inc/theme-options.php:541
#: inc/theme-options.php:547
msgid "版权信息"
msgstr ""
#: inc/theme-options.php:548
#: inc/theme-options.php:554
msgid "广告配置"
msgstr ""
#: inc/theme-options.php:553
#: inc/theme-options.php:559
msgid "文章页面广告"
msgstr ""
#: inc/theme-options.php:554
#: inc/theme-options.php:560
msgid "开启顶部广告"
msgstr ""
#: inc/theme-options.php:567 inc/theme-options.php:587
#: inc/theme-options.php:573 inc/theme-options.php:593
msgid "选填广告连接,如果不填则只显示图片"
msgstr ""
#: inc/theme-options.php:574
#: inc/theme-options.php:580
msgid "开启底部广告"
msgstr ""
#: inc/theme-options.php:594
#: inc/theme-options.php:600
msgid "关于主题"
msgstr ""
@ -695,92 +711,92 @@ msgstr ""
msgid "侧边栏工具"
msgstr ""
#: inc/theme-widgets.php:77
#: inc/theme-widgets.php:71
msgid "图片广告"
msgstr ""
#: inc/theme-widgets.php:78
#: inc/theme-widgets.php:72
msgid "显示自定义图片广告的工具"
msgstr ""
#: inc/theme-widgets.php:94 inc/theme-widgets.php:116
#: inc/theme-widgets.php:88 inc/theme-widgets.php:110
msgid "广告"
msgstr ""
#: inc/theme-widgets.php:122
#: inc/theme-widgets.php:116
msgid "副标题:"
msgstr ""
#: inc/theme-widgets.php:126
#: inc/theme-widgets.php:120
msgid "链接地址:"
msgstr ""
#: inc/theme-widgets.php:130
#: inc/theme-widgets.php:124
msgid "广告图片:"
msgstr ""
#: inc/theme-widgets.php:132 inc/theme-widgets.php:196
#: inc/theme-widgets.php:126 inc/theme-widgets.php:190
msgid "选择图片"
msgstr ""
#: inc/theme-widgets.php:147
#: inc/theme-widgets.php:141
msgid "可跳转后台的个人简介展示工具"
msgstr ""
#: inc/theme-widgets.php:194
#: inc/theme-widgets.php:188
msgid "背景图片:"
msgstr ""
#: inc/theme-widgets.php:208 inc/theme-widgets.php:231
#: inc/theme-widgets.php:202 inc/theme-widgets.php:225
msgid "标签聚合"
msgstr ""
#: inc/theme-widgets.php:209
#: inc/theme-widgets.php:203
msgid "文章标签的展示工具"
msgstr ""
#: inc/theme-widgets.php:254
#: inc/theme-widgets.php:248
msgid "显示数量:"
msgstr ""
#: inc/theme-widgets.php:258
#: inc/theme-widgets.php:252
msgid "显示排序:"
msgstr ""
#: inc/theme-widgets.php:260
#: inc/theme-widgets.php:254
msgid "降序"
msgstr ""
#: inc/theme-widgets.php:261
#: inc/theme-widgets.php:255
msgid "升序"
msgstr ""
#: inc/theme-widgets.php:262 inc/theme-widgets.php:292
#: inc/theme-widgets.php:297
#: inc/theme-widgets.php:256 inc/theme-widgets.php:286
#: inc/theme-widgets.php:291
msgid "随机"
msgstr ""
#: inc/theme-widgets.php:275
#: inc/theme-widgets.php:269
msgid "文章聚合"
msgstr ""
#: inc/theme-widgets.php:276
#: inc/theme-widgets.php:270
msgid "展示最热、随机、最新文章的工具"
msgstr ""
#: inc/theme-widgets.php:290 inc/theme-widgets.php:295
#: inc/theme-widgets.php:284 inc/theme-widgets.php:289
msgid "最新"
msgstr ""
#: inc/theme-widgets.php:291 inc/theme-widgets.php:296
#: inc/theme-widgets.php:285 inc/theme-widgets.php:290
msgid "热点"
msgstr ""
#: inc/theme-widgets.php:334
#: inc/theme-widgets.php:328
msgid "展示数量:"
msgstr ""
#: inc/theme-widgets.php:338
#: inc/theme-widgets.php:332
msgid "统计天数:"
msgstr ""