以上就是本篇文章【WordPress文章下载增强插件源码 支持几乎所有网盘】的全部内容了,欢迎阅览 ! 文章地址:https://sicmodule.kub2b.com/quote/13303.html
栏目首页
相关文章
动态
同类文章
热门文章
网站地图
返回首页 企库往资讯移动站https://sicmodule.kub2b.com/mobile/,查看更多
WordPress文章下载增强插件源码 支持几乎所有网盘
2024-12-26 10:35
<?php
namespace core_download;
class Plugin
{
static function init()
{
add_action('admin_menu', [static::class, 'regMenu']);
add_action('add_meta_boxes', [static::class, 'addmetaBox']);
add_action('save_post', [static::class, 'savemetaBox']);
add_filter('the_content', [static::class, 'addDownloadWrap']);
add_action('wp_footer', [static::class, 'handleFooter']);
add_action('admin_footer', [static::class, 'adminFooter']);
}
static function handleFooter()
{
global $core_download_set;
print_r("<style>.core-download-warp {--theme-color: " . $core_download_set['set']['theme_color'] . ";--border-radius:" . $core_download_set['set']['border_radius'] . "px;}</style>");
}
static function addDownloadWrap($content)
{
$post_id = get_the_ID();
$download_data = Options::getmetaBoxOptions($post_id);
global $core_download_set;
if (!$download_data['open'] || count($download_data['download_list']) == 0 || $core_download_set['set']['open'] === false) {
return $content;
}
$list = $download_data['download_list'];
$download_data_html = '';
foreach ($list as $item) {
$item['icon'] = file_get_contents(Config::$img_dir . "/icon/{$item['name']}.svg");
$item['copy_icon'] = Config::$img_url . "/copy.svg";
$item['netdisk_name'] = self::netdiskNameToWord($item['name']);
if ($item['resource_name'] == '') {
$item['hide_netdisk_name'] = 'true';
}
if ($item['key'] == '') {
$item['hide_key'] = 'true';
$item['key'] = '无';
}
$download_data_html .= Template::getTemplateHtmlByDOMdocument('download-url-item', $item);
}
$data['download_data'] = $download_data_html;
$data['title'] = get_the_title();
$data['open_link'] = file_get_contents(Config::$img_dir . "/open-link.svg");
$data['content'] = stripslashes(base64_decode($download_data['content']));
$data['copyright_str'] = $core_download_set['set']['copyright_str'];
$data['front_logo'] = file_get_contents(Config::$img_dir . "/front_logo.svg");
$data['warn_icon'] = file_get_contents(Config::$img_dir . "/warn_icon.svg");
$data['complaint_url'] = $core_download_set['set']['complaint_url'];
$content .= Template::getTemplateHtml('download-warp', $data);
return $content;
}
static function netdiskNameToWord($name)
{
$cloud_list = [
'local' => '本地下载',
'aliyun' => '阿里云盘',
'baidu' => '百度云盘',
'360' => '360网盘',
'ct' => '诚通网盘',
'lanzou' => '蓝奏云',
'123' => '123盘',
'github' => 'github',
'quark' => '夸克',
'uc' => 'UC',
'weiyun' => '微云',
'wenshushu' => '文叔叔',
'xunlei' => '迅雷',
'jianguo' => '坚果云',
'tianyi' => '天翼云',
'hecai' => '和彩云',
'onedrive' => 'OneDrive'
];
return $cloud_list[$name];
}
static function regMenu()