@@ -1428,18 +1428,26 @@ function the_content_filter($content){
1428
1428
add_filter ('the_content ' , 'the_content_filter ' );
1429
1429
//使用 CDN 加速 gravatar
1430
1430
function gravatar_cdn ($ url ){
1431
- $ cdn = get_option ('argon_gravatar_cdn ' , 'gravatar.loli.net/avatar/ ' );
1431
+ $ cdn = get_option ('argon_gravatar_cdn ' , 'gravatar.loli.net/avatar/ ' );
1432
1432
$ cdn = str_replace ("http:// " , "" , $ cdn );
1433
1433
$ cdn = str_replace ("https:// " , "" , $ cdn );
1434
1434
if (substr ($ cdn , -1 ) != '/ ' ){
1435
1435
$ cdn .= "/ " ;
1436
1436
}
1437
- $ url = preg_replace ("/\/\/(.*?).gravatar.com\/avatar\// " , "// " . $ cdn , $ url );
1437
+ $ url = preg_replace ("/\/\/(.*?).gravatar.com\/avatar\// " , "// " . $ cdn , $ url );
1438
1438
return $ url ;
1439
1439
}
1440
1440
if (get_option ('argon_gravatar_cdn ' , '' ) != '' ){
1441
1441
add_filter ('get_avatar_url ' , 'gravatar_cdn ' );
1442
1442
}
1443
+ function text_gravatar ($ url ){
1444
+ $ url = preg_replace ("/[\?\&]d[^&]+/i " , "" , $ url );
1445
+ $ url .= '&d=404 ' ;
1446
+ return $ url ;
1447
+ }
1448
+ if (get_option ('argon_text_gravatar ' , 'false ' ) == 'true ' ){
1449
+ add_filter ('get_avatar_url ' , 'text_gravatar ' );
1450
+ }
1443
1451
//说说点赞
1444
1452
function get_shuoshuo_upvotes ($ ID ){
1445
1453
$ count_key = 'upvotes ' ;
@@ -1865,7 +1873,7 @@ function shortcode_alert($attr,$content=""){
1865
1873
if (isset ($ attr ['title ' ])){
1866
1874
$ out .= "<strong> " . $ attr ['title ' ] . "</strong> " ;
1867
1875
}
1868
- $ out .= $ content . "</div> " ;
1876
+ $ out .= $ content . "</span></ div> " ;
1869
1877
return $ out ;
1870
1878
}
1871
1879
add_shortcode ('admonition ' ,'shortcode_admonition ' );
@@ -2172,6 +2180,7 @@ function shortcode_github($attr,$content=""){
2172
2180
$ author = isset ($ attr ['author ' ]) ? $ attr ['author ' ] : '' ;
2173
2181
$ project = isset ($ attr ['project ' ]) ? $ attr ['project ' ] : '' ;
2174
2182
$ getdata = isset ($ attr ['getdata ' ]) ? $ attr ['getdata ' ] : 'frontend ' ;
2183
+ $ size = isset ($ attr ['size ' ]) ? $ attr ['size ' ] : 'full ' ;
2175
2184
2176
2185
$ description = "" ;
2177
2186
$ stars = "" ;
@@ -2210,8 +2219,12 @@ function shortcode_github($attr,$content=""){
2210
2219
restore_error_handler ();
2211
2220
}
2212
2221
2213
- $ out = "<div class='github-info-card card shadow-sm' data-author=' " . $ author . "' data-project=' " . $ project . "' githubinfo-card-id=' " . $ github_info_card_id . "' data-getdata=' " . $ getdata . "' data-description=' " . $ description . "' data-stars=' " . $ stars . "' data-forks=' " . $ forks . "'> " ;
2214
- $ out .= "<div class='github-info-card-header'><a href='https://github.com/' ref='nofollow' target='_blank' title='Github' no-pjax><span><i class='fa fa-github'></i> Github</span></a></div> " ;
2222
+ $ out = "<div class='github-info-card github-info-card- " . $ size . " card shadow-sm' data-author=' " . $ author . "' data-project=' " . $ project . "' githubinfo-card-id=' " . $ github_info_card_id . "' data-getdata=' " . $ getdata . "' data-description=' " . $ description . "' data-stars=' " . $ stars . "' data-forks=' " . $ forks . "'> " ;
2223
+ $ out .= "<div class='github-info-card-header'><a href='https://github.com/' ref='nofollow' target='_blank' title='Github' no-pjax><span><i class='fa fa-github'></i> " ;
2224
+ if ($ size != "mini " ){
2225
+ $ out .= " GitHub " ;
2226
+ }
2227
+ $ out .= "</span></a></div> " ;
2215
2228
$ out .= "<div class='github-info-card-body'>
2216
2229
<div class='github-info-card-name-a'>
2217
2230
<a href='https://github.com/ " . $ author . "/ " . $ project . "' target='_blank' no-pjax>
@@ -2221,10 +2234,10 @@ function shortcode_github($attr,$content=""){
2221
2234
<div class='github-info-card-description'></div>
2222
2235
</div> " ;
2223
2236
$ out .= "<div class='github-info-card-bottom'>
2224
- <span class='github-info-card-meta'>
2237
+ <span class='github-info-card-meta github-info-card-meta-stars '>
2225
2238
<i class='fa fa-star'></i> <span class='github-info-card-stars'></span>
2226
2239
</span>
2227
- <span class='github-info-card-meta'>
2240
+ <span class='github-info-card-meta github-info-card-meta-forks '>
2228
2241
<i class='fa fa-code-fork'></i> <span class='github-info-card-forks'></span>
2229
2242
</span>
2230
2243
</div> " ;
@@ -3487,6 +3500,24 @@ function themeoptions_page(){
3487
3500
<p class="description"><?php _e ('开启后,过长的评论会被折叠,需要手动展开 ' , 'argon ' );?> </p>
3488
3501
</td>
3489
3502
</tr>
3503
+ <tr>
3504
+ <th><label>Gravatar CDN</label></th>
3505
+ <td>
3506
+ <input type="text" class="regular-text" name="argon_gravatar_cdn" value="<?php echo get_option ('argon_gravatar_cdn ' , '' ); ?> "/>
3507
+ <p class="description"><?php _e ('使用 CDN 来加速 Gravatar 在某些地区的访问,填写 CDN 地址,留空则不使用。 ' , 'argon ' );?> </br><?php _e ('在中国速度较快的一些 CDN : ' , 'argon ' );?> <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">gravatar.loli.net/avatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">cdn.v2ex.com/gravatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">dn-qiniu-avatar.qbox.me/avatar/</code></p>
3508
+ </td>
3509
+ </tr>
3510
+ <tr>
3511
+ <th><label>评论文字头像</label></th>
3512
+ <td>
3513
+ <select name="argon_text_gravatar">
3514
+ <?php $ argon_text_gravatar = get_option ('argon_text_gravatar ' ); ?>
3515
+ <option value="false" <?php if ($ argon_text_gravatar =='false ' ){echo 'selected ' ;} ?> ><?php _e ('禁用 ' , 'argon ' );?> </option>
3516
+ <option value="true" <?php if ($ argon_text_gravatar =='true ' ){echo 'selected ' ;} ?> ><?php _e ('启用 ' , 'argon ' );?> </option>
3517
+ </select>
3518
+ <p class="description"><?php _e ('在评论者没有设置 Gravatar 时自动生成文字头像,头像颜色由邮箱哈希计算。生成时会在 Console 中抛出 404 错误,但没有影响。 ' , 'argon ' );?> </p>
3519
+ </td>
3520
+ </tr>
3490
3521
<tr><th class="subtitle"><h2><?php _e ('杂项 ' , 'argon ' );?> </h2></th></tr>
3491
3522
<tr>
3492
3523
<th><label><?php _e ('是否启用 Pjax ' , 'argon ' );?> </label></th>
@@ -3560,13 +3591,6 @@ function themeoptions_page(){
3560
3591
<p class="description"><?php _e ('开启后,博客首页文章和说说穿插显示 ' , 'argon ' );?> </p>
3561
3592
</td>
3562
3593
</tr>
3563
- <tr>
3564
- <th><label>Gravatar CDN</label></th>
3565
- <td>
3566
- <input type="text" class="regular-text" name="argon_gravatar_cdn" value="<?php echo get_option ('argon_gravatar_cdn ' , '' ); ?> "/>
3567
- <p class="description"><?php _e ('使用 CDN 来加速 Gravatar 在某些地区的访问,填写 CDN 地址,留空则不使用。 ' , 'argon ' );?> </br><?php _e ('在中国速度较快的一些 CDN : ' , 'argon ' );?> <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">gravatar.loli.net/avatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">cdn.v2ex.com/gravatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">dn-qiniu-avatar.qbox.me/avatar/</code></p>
3568
- </td>
3569
- </tr>
3570
3594
<tr>
3571
3595
<th><label><?php _e ('是否修正时区错误 ' , 'argon ' );?> </label></th>
3572
3596
<td>
@@ -3984,6 +4008,7 @@ function argon_update_themeoptions(){
3984
4008
argon_update_option ('argon_related_post_sort_order ' );
3985
4009
argon_update_option ('argon_related_post_limit ' );
3986
4010
argon_update_option ('argon_article_header_style ' );
4011
+ argon_update_option ('argon_text_gravatar ' );
3987
4012
3988
4013
//LazyLoad 相关
3989
4014
argon_update_option ('argon_enable_lazyload ' );
0 commit comments