5
5
*
6
6
* @package WeChatShare
7
7
* @author Fuzqing
8
- * @version 1.0.5
8
+ * @version 1.0.6
9
9
* @link https://huangweitong.com
10
10
*
11
11
*
12
- * version 1.0.0 at 2018-6-14
13
- * 优化了代码
14
- * 更新了支持在线更新
15
- *
16
- * version 0.0.4 at 2018-4-30
17
- * 修复了某些bug,优化了代码逻辑
18
- * 把AccessToken、JsapiTicket写进配置里面,方便更新调用,之前版本是写到文件里面的
12
+ * version 1.0.6 at 2018-12-19
13
+ * 删除在线更新
14
+ * 删除自定义字段
19
15
*
20
- * version 0.0.3 at 2018-4-29
21
- * 更新支持pjax
22
- * 如果你启用了pjax,当切换页面时候,js不会重写绑定事件到新生成的节点上。
23
- * 你可以在pjax加载页面完成后重新加载js,以便将事件正确绑定ajax生成的DOM节点上。
24
- * 例如:$.getScript("/usr/plugins/WeChatShare/wx_share.js?ver="+Math.random());
25
- *
26
- * version 0.0.2 at 2018-4-27
27
- * 修复jssdk因为ssl判别证书的问题出现的notice
28
- *
29
- * version 0.0.1 at 2018-4-26
30
- * 实现分享博客文章到微信、朋友圈、QQ、QQ空间等
31
- * 包括: 自定义摘要 图标 标题
32
- * 本插件自带自定义摘要,如果填了摘要的话,也可以在前台调用
33
- * 调用字段<?php $description = $this->fields->description;?>
34
- * 具体其他使用方法,请查看官方文档:http://docs.typecho.org/help/custom-fields
35
16
*/
36
17
class WeChatShare_Plugin implements Typecho_Plugin_Interface
37
18
{
@@ -40,7 +21,7 @@ class WeChatShare_Plugin implements Typecho_Plugin_Interface
40
21
* 插件版本号
41
22
* @var string
42
23
*/
43
- const _VERSION = '1.0.5 ' ;
24
+ const _VERSION = '1.0.6 ' ;
44
25
/**
45
26
* 激活插件方法,如果激活失败,直接抛出异常
46
27
*
@@ -49,10 +30,6 @@ class WeChatShare_Plugin implements Typecho_Plugin_Interface
49
30
*/
50
31
public static Function activate ()
51
32
{
52
- // 检查curl
53
- if ( !function_exists ('curl_init ' ) ) {
54
- throw new Typecho_Plugin_Exception (_t ('你好,使用本插件必须开启curl扩展 ' ));
55
- }
56
33
$ info = WeChatShare_Plugin::wechatShareInstall ();
57
34
Helper::addAction ('wx-share ' , 'WeChatShare_Action ' );
58
35
Typecho_Plugin::factory ('admin/write-post.php ' )->bottom = array ('WeChatShare_Plugin ' , 'render ' );
@@ -86,62 +63,10 @@ public static function deactivate(){
86
63
*/
87
64
public static function config (Typecho_Widget_Helper_Form $ form )
88
65
{
89
- $ options = Typecho_Widget::widget ('Widget_Options ' );
90
- $ up_action_url = Typecho_Common::url ('/index.php/action/wx-share?do=update-plugin ' , $ options ->siteUrl );
91
- ?>
92
- <style>
93
- #update_txt{font-size:1.2em;font-weight:700}#update_notice{display:block;text-align:center;margin:5px}#update_body{font-weight:700;color:#1abc9c}.message{padding:10px;background-color:#fff;box-shadow:2px 2px 5px #888;font-size:1pc;line-height:1.875rem}.bttn-default{color:#fff}.bttn,.bttn-md,.bttn-primary{color:#1d89ff}.bttn,.bttn-md{margin:0;padding:0;border-width:0;border-color:transparent;background:transparent;font-weight:400;cursor:pointer;position:relative}.bttn-md{padding:5px 9pt}.bttn-md,.bttn-slant{font-size:20px;font-family:inherit}.bttn-slant{margin:0;padding:0;border-width:0;border-color:transparent;font-weight:400;cursor:pointer;position:relative;padding:5px 9pt;z-index:0;border:none;border-radius:0;background:transparent;color:#1d89ff;-webkit-transition:color .3s cubic-bezier(0.02,0.01,0.47,1),-webkit-transform .3s cubic-bezier(0.02,0.01,0.47,1);transition:color .3s cubic-bezier(0.02,0.01,0.47,1),-webkit-transform .3s cubic-bezier(0.02,0.01,0.47,1);transition:color .3s cubic-bezier(0.02,0.01,0.47,1),transform .3s cubic-bezier(0.02,0.01,0.47,1);transition:color .3s cubic-bezier(0.02,0.01,0.47,1),transform .3s cubic-bezier(0.02,0.01,0.47,1),-webkit-transform .3s cubic-bezier(0.02,0.01,0.47,1)}.bttn-slant:before{width:100%;background:#fafafa;-webkit-transition:box-shadow .2s cubic-bezier(0.02,0.01,0.47,1);transition:box-shadow .2s cubic-bezier(0.02,0.01,0.47,1)}.bttn-slant:after,.bttn-slant:before{position:absolute;top:0;left:0;z-index:-1;height:100%;content:'';-webkit-transform:skewX(20deg);transform:skewX(20deg)}.bttn-slant:after{width:0;background:hsla(0,0%,98%,.3);opacity:0;-webkit-transition:opacity .2s cubic-bezier(0.02,0.01,0.47,1),width .15s cubic-bezier(0.02,0.01,0.47,1);transition:opacity .2s cubic-bezier(0.02,0.01,0.47,1),width .15s cubic-bezier(0.02,0.01,0.47,1)}.bttn-slant:focus,.bttn-slant:hover{-webkit-transform:translateX(5px);transform:translateX(5px)}.bttn-slant:focus:after,.bttn-slant:hover:after{width:5px;opacity:1}.bttn-slant:focus:before,.bttn-slant:hover:before{box-shadow:inset 0 -1px 0 #a7c3ff,inset 0 1px 0 #a7c3ff,inset -1px 0 0 #a7c3ff}.bttn-slant.bttn-md{font-size:20px;font-family:inherit;padding:5px 9pt}.bttn-slant.bttn-primary{color:#fff}.bttn-slant.bttn-primary:focus:before,.bttn-slant.bttn-primary:hover:before{box-shadow:inset 0 -1px 0 #006de3,inset 0 1px 0 #006de3,inset -1px 0 0 #006de3}.bttn-slant.bttn-primary:before{background:#1d89ff}.bttn-slant.bttn-primary:after{background:#006de3}
94
- </style>
95
- <div class="message">
96
- <div id="update_txt">当前版本: <?php _e (self ::_VERSION ); ?> ,正在检测版本更新...</div>
97
- <div id="update_notice"></div>
98
- <div id="update_body"></div>
99
- </div>
100
- <script src="//cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
101
- <script src="//cdn.bootcss.com/marked/0.3.12/marked.min.js"></script>
102
- <script>
103
- $(function () {
104
- $.getJSON(
105
- 'https://api.github.com/repos/fuzqing/WeChatShare/releases/latest',
106
- function (data) {
107
- if (checkUpdater('<?php _e (self ::_VERSION );?> ', data.tag_name)) {
108
- $('#update_txt').html('当前版本:<?php _e (self ::_VERSION );?> ,检测到有 v'+data.tag_name+' 最新版本,请更新!');
109
- $('#update_notice').html('<button class="bttn-slant bttn-md bttn-primary" zipball_url="' + data.zipball_url + '" onClick="updatePlugin();" id="update-plugin">立即更新</button><hr>');
110
- $('#update_body').html('<span style="font-size:1.3em">版本说明:</span>' + marked(data.body));
111
- } else {
112
- $('#update_txt').html('当前版本:<?php _e (self ::_VERSION );?> ,当前没有新版本');
113
- }
114
- }
115
- );
116
- });
117
-
118
- // 版本比较
119
- function checkUpdater(currVer, remoteVer) {
120
- currVer = currVer || '0.0.0';
121
- remoteVer = remoteVer || '0.0.0';
122
- if (currVer == remoteVer) return false;
123
- var currVerAry = currVer.split('.');
124
- var remoteVerAry = remoteVer.split('.');
125
- var len = Math.max(currVerAry.length, remoteVerAry.length);
126
- for (var i = 0; i < len; i++) {
127
- if (~~remoteVerAry[i] > ~~currVerAry[i]) return true;
128
- }
129
-
130
- return false;
131
- }
132
-
133
- function updatePlugin() {
134
- var zipball_url = $("#update-plugin").attr('zipball_url');
135
- $.post("<?php echo $ up_action_url ;?> ", {zipball_url:zipball_url} ,success,"");
136
- function success(data){
137
- $('#update_txt').html('');
138
- $('#update_notice').html('<span style="font-size:1.4em;color:#1d89f;font-weight:700;">'+data+'</span>');
139
-
140
- }
141
- return false;
142
- }
143
- </script>
144
- <?php
66
+ $ options = Typecho_Widget::widget ('Widget_Options ' );
67
+
68
+ $ up_action_url = Typecho_Common::url ('/index.php/action/wx-share?do=update-plugin ' , $ options ->siteUrl );
69
+
145
70
/** 公众号配置 */
146
71
$ wx_AppID = new Typecho_Widget_Helper_Form_Element_Text ('wx_AppID ' , NULL , NULL , _t ('APPID ' ),'请登录微信公众号获取 ' );
147
72
@@ -208,50 +133,13 @@ public static function render()
208
133
$ wx_image = $ wx_share [0 ]['wx_image ' ];
209
134
}
210
135
}
211
- $ str = '<tr><td><input type="hidden" name="fieldNames[]" my-description="my-description" value="description" id="fieldname"><label class="typecho-label" for="description">文章自定义摘要</label><input type="hidden" name="fieldTypes[]" value="str" id="fieldtype" class="text-s w-100"></td><td colspan="3"><textarea name="fieldValues[]" onfocus="get_describe(this);" id="fieldvalue" class="text-s w-100" rows="4"> ' .$ description .'</textarea></td></tr> ' ;
212
-
136
+
213
137
$ data = '<style>:-moz-placeholder {color: #E0E0E0; opacity:1;}::-moz-placeholder {color: #E0E0E0;opacity:1;}input:-ms-input-placeholder{color: #E0E0E0;opacity:1;}input::-webkit-input-placeholder{color: #E0E0E0;opacity:1;}</style><form id="wx_share" ><fieldset><legend>微信分享</legend><ol style="list-style-type:none;><li style="padding-bottom: 5px;"><label for="wx_title">标题:</label><input style="width: 80%" type="text" class="wx_title" value=" ' .$ wx_title .'" name="wx_title" ></li><li style="padding-bottom: 5px;"><label for="wx_url">链接:</label><input type="text" style="width: 80%" value=" ' .$ wx_url .'" name="wx_url"></li><li style="padding-bottom: 5px;display:block;"><span style="float:left" for="wx_describe">摘要:</span><textarea rows="4" class="wx_describe" name="wx_description" style="width: 80%" > ' .$ wx_description .'</textarea></li><li style="padding-bottom: 5px;"><label for="wx_image">图标:</label><input type="text" class="wx_image" value=" ' .$ wx_image .'" style="width: 80%" name="wx_image"></li></ol></fieldset><input type="hidden" name="cid" value=" ' .$ match ['1 ' ].'"></form> ' ;
214
138
215
139
?>
216
140
217
141
<script>
218
- //监控摘要自定义字段的输入,同步更新微信摘要
219
- function get_describe(self){
220
- $(self).on('input propertychange', function(event) {
221
- var _val = $(self).val();
222
- var wx_describe = $(".wx_describe").val();
223
- if (wx_describe !== null || wx_describe !== undefined || wx_describe !== '') {
224
-
225
- $(".wx_describe").val(_val);
226
- }
227
-
228
-
229
- });
230
- $(self).blur(function(){
231
- $(self).off('input propertychange');
232
- });
233
- }
234
142
$(document).ready(function(){
235
- //添加description自定义字段
236
- $("#custom-field table tbody").prepend('<?php echo $ str ?> ');
237
- //自动打开自定义字段
238
- $(".i-caret-right").click();
239
- //多出来的一个自定义字段
240
- $("#custom-field table input").each(function () {
241
- if(!$(this).val()) {
242
- $("#custom-field table tr .btn-xs").parents('tr').fadeOut(function () {
243
- $(this).remove();
244
- });
245
- $("#custom-field table tr .btn-xs").parents('form').trigger('field');
246
- }
247
- if($(this).val() == 'description' && $(this).attr('my-description') == undefined) {
248
- $(this).parents('tr').fadeOut(function () {
249
- $(this).remove();
250
- });
251
- $(this).parents('form').trigger('field');
252
- }
253
- });
254
-
255
143
256
144
//添加微信分享
257
145
$("#custom-field").after('<?php echo $ data ?> ');
0 commit comments