2020-04-04 12:06:39 +08:00
|
|
|
|
<?php
|
2020-04-09 20:33:35 +08:00
|
|
|
|
/**
|
|
|
|
|
* 仪表盘赞助商列表小部件
|
|
|
|
|
*
|
|
|
|
|
* @author Jialong
|
|
|
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GPLv3 Licence
|
|
|
|
|
*/
|
|
|
|
|
$plugin_url = plugin_dir_url(__FILE__);
|
2020-04-04 12:06:39 +08:00
|
|
|
|
echo <<<ETO
|
2020-04-10 14:16:18 +08:00
|
|
|
|
<link rel="stylesheet" type="text/css" href="{$plugin_url}css/global.css"/>
|
2020-04-09 20:33:35 +08:00
|
|
|
|
|
2020-04-10 14:16:18 +08:00
|
|
|
|
<div id="sponsor-container"></div>
|
|
|
|
|
<div class="url-container">
|
|
|
|
|
<a class="url-item" target="_blank" href="https://www.ibadboy.net/archives/3204.html">项目主页</a>
|
|
|
|
|
<a href="#" class="url-item addGroup">入群交流</a>
|
|
|
|
|
<a class="url-item" target="_blank" href="https://www.ibadboy.net/archives/3204.html#%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98">常见问题</a>
|
|
|
|
|
<div class="close">不再显示</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-04-09 20:33:35 +08:00
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
jQuery.ajax({
|
|
|
|
|
url: "https://wp-mirror-dev.ibadboy.net/api/v1/donors",
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (data) {
|
|
|
|
|
for (let i = 0; i < data.data.length; i++) {
|
|
|
|
|
var _html = '<div class="sponsor-item-container">' +
|
|
|
|
|
'<img class="sponsor-item-logo" src="' + data.data[i].logo_url + '" alt="logo" />' +
|
|
|
|
|
'<div class="sponsor-item-synopsis">' +
|
|
|
|
|
'<a href="'+data.data[i].url+'" target="_blank" class="sponsor-item-title">' +
|
|
|
|
|
'<img class="sponsor-item-title-icon" src="' + getIcon(data.data[i].type) + '" />' +
|
|
|
|
|
data.data[i].name + '</a>' +
|
|
|
|
|
'<div class="sponsor-tag-container">' + getSubsidize(data.data[i].mode) + '</div>' + '</div>' +
|
|
|
|
|
'</div>';
|
|
|
|
|
jQuery("#sponsor-container").append(_html)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function getIcon(type) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 1:
|
|
|
|
|
return '{$plugin_url}image/enterprise.svg';
|
|
|
|
|
case 2:
|
|
|
|
|
return '{$plugin_url}image/personage.svg';
|
|
|
|
|
case 3:
|
|
|
|
|
return '{$plugin_url}image/school.svg';
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSubsidize(mode) {
|
2020-04-10 14:16:18 +08:00
|
|
|
|
const data = mode.split(',');
|
|
|
|
|
let _html = '';
|
2020-04-09 20:33:35 +08:00
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
|
_html += '<div class="sponsor-item-content">' + data[i] + '</div>';
|
|
|
|
|
}
|
|
|
|
|
return _html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jQuery('.addGroup').on('click', function () {
|
2020-04-10 14:16:18 +08:00
|
|
|
|
alert('加入WP中国仓库源建设计划QQ交流群:1046115671');
|
|
|
|
|
});
|
2020-04-09 20:33:35 +08:00
|
|
|
|
|
|
|
|
|
jQuery('.close').on('click', function () {
|
|
|
|
|
window.open("https://www.ibadboy.net/archives/3683.html");
|
2020-04-10 14:16:18 +08:00
|
|
|
|
});
|
2020-04-09 20:33:35 +08:00
|
|
|
|
</script>
|
2020-04-04 12:06:39 +08:00
|
|
|
|
ETO;
|