豆豆の鱼.

Life record . 记录自己的日常琐事.

THE7主题 6.2.1 版本 增加国内社交按钮方法

screenshot THE7主题 6.2.1 版本 增加国内社交按钮方法

THE7主题 6.2.1 版本 增加国内社交按钮方法

THE7主题的社交分享暂时还不支持国内版本,在PHP源代码中检查也只发现了Weibo,其它都是诸如国外较出名的Facebook、Twitter、Linkedin、Pinterest、Google Plus、Instagram等,因此国内的小伙伴们想要添加社交基本都是第三方插件的辅助,这里讲一个方法,利用THE7子主题+修改部THE7父主题源码达到在THE7社交选项中就能自由添加国内社交按钮,这里感谢@wangweida0221的帮助,现在直接上干货。

方法:

第一步:

在THE7子主题the7dtchild内functions.php内添加小工具社交链接&图标

/** ============================== 小工具社交链接&图标 ============================== **/
function my_presscore_get_social_icons_data($icons) {
$icons[‘tencent-weibo’] = __(‘腾讯微博’, ‘the7mk2’);
$icons[‘renren’] = __(‘人人网’, ‘the7mk2’);
$icons[‘douban’] = __(‘豆瓣网’, ‘the7mk2’);
$icons[‘kaixinwang’] = __(‘开心网’, ‘the7mk2’);
$icons[‘qzone’] = __(‘QQ空间’, ‘the7mk2’);
$icons[‘baidu-tieba’] = __(‘百度贴吧’, ‘the7mk2’);
$icons[‘youku’] = __(‘优酷视频’, ‘the7mk2’);
$icons[‘tudou’] = __(‘土豆视频’, ‘the7mk2’);
$icons[‘taobao’] = __(‘淘宝网’, ‘the7mk2’);
$icons[‘aiqiyi’] = __(‘爱奇艺’, ‘the7mk2’);
return $icons;
}
add_filter( ‘presscore_get_social_icons_data’, ‘my_presscore_get_social_icons_data’ );

第二步:

在子主题the7dtchlid内的样式表style.css中添加社交图标样式定义及链接定义

以下代码添加到子主题的style.css中

/* 社交链接图标定义 */
.dt-icon-tencent-weibo:before, .tencent-weibo .soc-font-icon:before {
content: “\e926”;
}
.dt-icon-renren:before, .renren .soc-font-icon:before {
content: “\e929”;
}
.dt-icon-douban:before, .douban .soc-font-icon:before {
content: “\e92b”;
}
.dt-icon-kaixinwang:before, .kaixinwang .soc-font-icon:before {
content: “\e931”;
}
.dt-icon-qzone:before, .qzone .soc-font-icon:before {
content: “\e92e”;
}
.dt-icon-baidu-tieba:before, .baidu-tieba .soc-font-icon:before {
content: “\e932”;
}
.dt-icon-youku:before, .youku .soc-font-icon:before {
content: “\e936”;
}
.dt-icon-tudou:before, .tudou .soc-font-icon:before {
content: “\e92a”;
}
.dt-icon-taobao:before, .taobao .soc-font-icon:before {
content: “\e930”;
}
.dt-icon-aiqiyi:before, .aiqiyi .soc-font-icon:before {
content: “\e935”;
}
/* 社交享分图标定义及默认样式 */
.single-share-box .share-buttons a.weibo:before { content: “\F18A”; }
.single-share-box .share-buttons a.weibo { border-color:rgba(232, 52, 59, 0.5); color:#e8343b; }
.single-share-box .share-buttons a.weibo:hover { border-color:#8343b; background-color:#e8343b; color:#fff; }

.single-share-box .share-buttons a.tencent-weibo:before { content: “\F1d5”; }
.single-share-box .share-buttons a.tencent-weibo { color:#128abc; border-color:rgba(18, 138, 188, 0.5); }
.single-share-box .share-buttons a.tencent-weibo:hover { border-color:#128abc; background-color:#128abc; color:#fff; }

.single-share-box .share-buttons a.renren-share:before { content: “\F18B”; }
.single-share-box .share-buttons a.renren-share { color:#1362a7; border-color:rgba(19, 98, 167, 0.5); }
.single-share-box .share-buttons a.renren-share:hover { border-color:#1362a7; background-color:#1362a7; color:#fff; }

.single-share-box .share-buttons a.wechat:before { content: “\F1D7”; }
.single-share-box .share-buttons a.wechat { color:#46c129; border-color:rgba(70, 193, 41, 0.5); }
.single-share-box .share-buttons a.wechat:hover { border-color:#46c129; background-color:#46c129; color:#fff; }

.single-share-box .share-buttons a.qq:before { content: “\F1D6”; }
.single-share-box .share-buttons a.qq { color:#116abc; border-color:rgba(17, 106, 188, 0.5); }
.single-share-box .share-buttons a.qq:hover { border-color:#116abc; background-color:#116abc; color:#fff; }

.single-share-box .share-buttons a.douban:before { content: “\F394”; }
.single-share-box .share-buttons a.douban { color:#2e9e3a; border-color:rgba(46, 158, 58, 0.5); }
.single-share-box .share-buttons a.douban:hover { border-color:#2e9e3a; background-color:#2e9e3a; color:#fff; }

第三步:

1、接下来进行源码修改,修改Weibo为中文新浪微博

路径:dt-the7/inc/helpers/options.php

找到以下代码部分:

function presscore_get_social_icons_data() {
$icons = array(
‘weibo’ =>; __(‘Weibo’, ‘the7mk2’), #修改前

…….

修改为:

‘weibo’ =>; __(‘新浪微博’, ‘the7mk2’), #修改后

……

2、添加社交分享按钮

路径:dt-the7/inc/helpers/options.php

找到

if ( ! function_exists( ‘presscore_themeoptions_get_social_buttons_list’ ) ) :

/**
* Social buttons.
*/
function presscore_themeoptions_get_social_buttons_list() {
return array(
‘facebook’ =>; __(‘Facebook’, ‘the7mk2’),
‘twitter’ =>; __(‘Twitter’, ‘the7mk2’),
‘google+’ =>; __(‘Google+’, ‘the7mk2’),
‘pinterest’ =>; __(‘Pinterest’, ‘the7mk2’),
‘linkedin’ =>; __(‘LinkedIn’, ‘the7mk2’),
‘whatsapp’ =>; __(‘WhatsApp’, ‘the7mk2’),

);
}

修改为:

if ( ! function_exists( ‘presscore_themeoptions_get_social_buttons_list’ ) ) :

/**
* Social buttons.
*/
function presscore_themeoptions_get_social_buttons_list() {
return array(
‘facebook’ =>; __(‘Facebook’, ‘the7mk2’),
‘twitter’ =>; __(‘Twitter’, ‘the7mk2’),
‘google+’ =>; __(‘Google+’, ‘the7mk2’),
‘pinterest’ =>; __(‘Pinterest’, ‘the7mk2’),
‘linkedin’ =>; __(‘LinkedIn’, ‘the7mk2’),
‘whatsapp’ =>; __(‘WhatsApp’, ‘the7mk2’),
‘weibo’ =>; __(‘新浪微博’, ‘the7mk2’),
‘tencent-weibo’ =>; __(‘腾讯微博’, ‘the7mk2’),
‘renren-share’ =>; __(‘人人网’, ‘the7mk2’),
‘douban’ =>; __(‘豆瓣网’, ‘the7mk2’),
‘qq’ =>; __(‘QQ好友’, ‘the7mk2’),
‘wechat’ =>; __(‘微信’, ‘the7mk2’),

);
}

3、添加分享按钮对应参数

路径:dt-the7/inc/helpers/html-helpers.php

搜索:case ‘twitter’: 并在 switch ( $button ) { 后、case ‘twitter’:之前添加下面代码:

case ‘weibo’:
$icon_class = ‘weibo’;
$url = add_query_arg( array( ‘url’ =>; rawurlencode( $u ), ‘text’ =>; urlencode( $t ) ), ‘http://www.jiathis.com/send/?webid=tsina&url=’ );
break;

case ‘tencent-weibo’:
$icon_class = ‘tencent-weibo’;
$url = add_query_arg( array( ‘url’ =>; rawurlencode( $u ), ‘text’ =>; urlencode( $t ) ), ‘http://www.jiathis.com/send/?webid=tqq&url=’ );
break;

case ‘renren-share’:
$icon_class = ‘renren-share’;
$url = add_query_arg( array( ‘url’ =>; rawurlencode( $u ), ‘text’ =>; urlencode( $t ) ), ‘http://www.jiathis.com/send/?webid=renren&url=’ );
break;

case ‘douban’:
$icon_class = ‘douban’;
$url = add_query_arg( array( ‘url’ =>; rawurlencode( $u ), ‘text’ =>; urlencode( $t ) ), ‘http://www.jiathis.com/send/?webid=douban&url=’ );
break;

case ‘wechat’:
$icon_class = ‘wechat’;
$url = add_query_arg( array( ‘url’ =>; rawurlencode( $u ), ‘text’ =>; urlencode( $t ) ), ‘http://www.jiathis.com/send/?webid=weixin&url=’ );
break;

case ‘qq’:
$icon_class = ‘qq’;
$url = add_query_arg( array( ‘url’ =>; rawurlencode( $u ), ‘text’ =>; urlencode( $t ) ), ‘http://www.jiathis.com/send/?webid=cqq&url=’ );
break;

小结

当然,这个方法是我的好友@wangweida0221研究出来的,在此感谢好友的分享。

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注