mirror of
https://github.com/yunluo/gdk.git
synced 2024-05-04 23:43:23 +02:00
优化单页下载功能
This commit is contained in:
parent
8e7abc696e
commit
19236aed05
|
@ -100,6 +100,8 @@ body{font-family:"Microsoft YaHei"}
|
|||
.wp-block[data-align=wide] {max-width:810pt}
|
||||
.wp-block[data-align=full] {max-width:none}
|
||||
#activity-widget #the-comment-list .avatar{width:50px}
|
||||
.form-field-download_name,.form-field-download_size{width:45%;float:left}
|
||||
.form-field-download_link{clear:both}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -16,14 +16,6 @@ if (!class_exists('myCustomFields')) {
|
|||
* @var array $customFields 开始组件自定义面板数组
|
||||
*/
|
||||
public $customFields = array(
|
||||
array(
|
||||
"name" => "pay_content",
|
||||
"title" => "免登陆付费查看内容",
|
||||
"description" => "这里可以输入免费可支付可查看的内容",
|
||||
"type" => "textarea",
|
||||
"scope" => array("post"),
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
array(
|
||||
"name" => "thumb",
|
||||
"title" => "自定义缩略图",
|
||||
|
@ -50,20 +42,12 @@ if (!class_exists('myCustomFields')) {
|
|||
),
|
||||
array(
|
||||
"name" => "download_link",
|
||||
"title" => "单页下载下载链接【新版】",
|
||||
"title" => "单页下载下载链接",
|
||||
"description" => "按照链接,名字,备注的格式,注意中间是用英文逗号,换行可添加多个,举个栗子:<code>https://www.baidu.com,百度官网,中国最大的搜索引擎网站</code>",
|
||||
"type" => "textarea",
|
||||
"scope" => array("post"),
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
array(
|
||||
"name" => "demo",
|
||||
"title" => "代码演示",
|
||||
"description" => "请在这里输入您的演示代码",
|
||||
"type" => "textarea",
|
||||
"scope" => array("post"),
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
);
|
||||
/**
|
||||
* PHP 5 Constructor
|
||||
|
@ -82,7 +66,7 @@ if (!class_exists('myCustomFields')) {
|
|||
{
|
||||
if (function_exists('add_meta_box')) {
|
||||
foreach ($this->postTypes as $postType) {
|
||||
add_meta_box('my-custom-fields', 'Git 主题文章发布选项', array($this, 'displayCustomFields'), $postType, 'normal', 'high');
|
||||
add_meta_box('my-custom-fields', '文章选项', array($this, 'displayCustomFields'), $postType, 'normal', 'high');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +106,7 @@ if (!class_exists('myCustomFields')) {
|
|||
// 通过则输出
|
||||
if ($output) {
|
||||
?>
|
||||
<div class="form-field form-required">
|
||||
<div class="form-field form-required form-field-<?php echo $customField['name'];?>">
|
||||
<?php switch ($customField['type']) {
|
||||
case "checkbox":{
|
||||
// Checkbox 组件
|
||||
|
@ -131,7 +115,6 @@ if (!class_exists('myCustomFields')) {
|
|||
if (get_post_meta($post->ID, $this->prefix . $customField['name'], true) == "1") {
|
||||
echo ' checked="checked"';
|
||||
}
|
||||
|
||||
echo '" style="width: auto;" />';
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -481,17 +481,6 @@ $gdk_options = [
|
|||
'type' => 'text',
|
||||
'std' => 'wp-content|wp-includes',
|
||||
],
|
||||
[
|
||||
'name' => 'CDN自定义缩略图样式',
|
||||
'desc' => '国内CDN服务商均支持的功能,使用自定义图片样式功能进行裁剪缩略图,默认使用的分隔符为【!】,默认开启',
|
||||
'id' => 'gdk_cdn_style',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'CDN服务商',
|
||||
'desc' => '选择使用国内CDN服务商,此项主要影响CDN缩略图,请选择对应服务商',
|
||||
|
@ -512,12 +501,6 @@ $gdk_options = [
|
|||
'id' => 'gdk_cdn_water',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => 'CDN镜像后台化',
|
||||
'desc' => '启用【一般可不启用,如果您启用CDN镜像之后并在FTP删除了本地文件,则必须开启】',
|
||||
'id' => 'gdk_adminqn_b',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'title' => '微信登录设置',
|
||||
'type' => 'title',
|
||||
|
@ -531,7 +514,7 @@ $gdk_options = [
|
|||
[
|
||||
'name' => '是否启用强制微信登录',
|
||||
'desc' => '启用 【开启后,将禁用WordPress自带的登录,所有登录地址都跳转到微信的登录,如需临时使用自带登录,可以使用这个链接:你的域名/wp-login.php?loggedout=true】',
|
||||
'id' => 'gdk_weauth_oauth_force',
|
||||
'id' => 'gdk_weauth_force',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
|
|
|
@ -179,7 +179,7 @@ function pay_view()
|
|||
}
|
||||
//无脑输出400错误
|
||||
if (isset($_POST['id'])) {
|
||||
payjs_action('在线付费查看', 'PP' . $_POST['id'], $_POST['money']); //标题,文章id
|
||||
payjs_action('付费查看:'.get_the_title($_POST['id']), 'PP' . $_POST['id'], $_POST['money']); //标题,文章id
|
||||
}
|
||||
}
|
||||
add_action('wp_ajax_pay_view', 'pay_view');
|
||||
|
|
|
@ -761,7 +761,7 @@ function mail_temp($mail_title, $mail_cotent, $link, $link_title)
|
|||
{
|
||||
|
||||
$content = '<div style="width:500px;margin:auto">
|
||||
<div style="background:#2695f3;color:#FFF;padding:20px 10px;">' . $mail_title . '</div>
|
||||
<div style="background:#2695f3;font-weight:bold;color:#FFF;padding:20px 10px;">' . $mail_title . '</div>
|
||||
<div style="padding:10px;margin:5px;border-bottom:dashed 1px #ddd;">' . $mail_cotent . '</div>
|
||||
<a href="' . $link . '" style="display:block;margin:auto;margin-top:40px;padding:10px;width:120px;outline:0;border:1px solid #2695f3;border-radius:25px;color:#2695f3;text-align:center;font-weight:700;font-size:14px;text-decoration:none;" rel="noopener" target="_blank">' . $link_title . '</a>
|
||||
<br><br>
|
||||
|
|
|
@ -21,15 +21,15 @@ if (gdk_option('gdk_cdn_water')) {
|
|||
//文章首尾添加自定义内容
|
||||
function gdk_add_content($content)
|
||||
{
|
||||
$before = gdk_option('gdk_artical_top');
|
||||
$after = gdk_option('gdk_artical_bottom');
|
||||
if(empty($before) && empty($after)){
|
||||
|
||||
$before = gdk_option('gdk_artical_top');
|
||||
$after = gdk_option('gdk_artical_bottom');
|
||||
if (empty($before) && empty($after) && !is_single()) {
|
||||
return $content;
|
||||
}else{
|
||||
} else {
|
||||
return $before . '<br>' . $content . '<br>' . $after;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
add_filter('the_content', 'gdk_add_content');
|
||||
|
||||
|
@ -175,7 +175,7 @@ function gdk_smtp($phpmailer)
|
|||
$phpmailer->Password = gdk_option('gdk_smtp_password'); //密码
|
||||
$phpmailer->From = gdk_option('gdk_smtp_mail'); //邮箱地址
|
||||
$phpmailer->SMTPAuth = true;
|
||||
$phpmailer->SMTPSecure = 'ssl';
|
||||
$phpmailer->SMTPSecure = 'ssl';
|
||||
$phpmailer->IsSMTP();
|
||||
}
|
||||
|
||||
|
@ -332,3 +332,48 @@ if (gdk_option('gdk_article_list')) {
|
|||
}
|
||||
add_filter('the_content', 'article_index');
|
||||
}
|
||||
|
||||
function weauth_page_activate()
|
||||
{
|
||||
$awesome_page_id = get_option('weixin_page_id');
|
||||
if (!$awesome_page_id) {
|
||||
$post = array(
|
||||
'post_title' => '微信登录', //这里是自动生成页面的页面标题
|
||||
'post_content' => '[gdk_login_btn]', //这里是页面的内容
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'page',
|
||||
'post_name' => 'weixin',
|
||||
);
|
||||
$postID = wp_insert_post($post);
|
||||
update_post_meta($postID, '_wp_page_template', ''); //这里是生成页面的模板类型
|
||||
update_option('weixin_page_id', $postID);
|
||||
}
|
||||
|
||||
}
|
||||
add_action('admin_init', 'weauth_page_activate');
|
||||
|
||||
//强制微信登录
|
||||
function force_weauth_login_url($login_url, $redirect, $force_reauth)
|
||||
{
|
||||
$login_url = get_permalink(get_option('weixin_page_id'));
|
||||
if (!empty($redirect)) {
|
||||
$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
|
||||
}
|
||||
if ($force_reauth) {
|
||||
$login_url = add_query_arg('reauth', '1', $login_url);
|
||||
}
|
||||
return $login_url;
|
||||
}
|
||||
|
||||
function change_my_register_url($url)
|
||||
{
|
||||
if (is_admin()) {
|
||||
return $url;
|
||||
}
|
||||
return wp_login_url();
|
||||
}
|
||||
|
||||
if (gdk_option('gdk_weauth_oauth') && gdk_option('gdk_weauth_force')) {
|
||||
add_filter('login_url', 'force_weauth_login_url', 10, 3);
|
||||
add_filter('register_url', 'change_my_register_url');
|
||||
}
|
||||
|
|
|
@ -162,18 +162,15 @@ function gdk_ton($atts, $content = null)
|
|||
return '<a class="lhb" id="showdiv" href="#fancydlbox" >文件下载</a><div id="fancydlbox" style="cursor:default;display:none;width:800px;"><div class="part" style="padding:20px 0;"><h2>下载声明:</h2> <div class="fancydlads" align="left"><p>' . gdk_option('gdk_fancydlcp') . '</p></div></div><div class="part" style="padding:20px 0;"><h2>文件信息:</h2> <div class="dlnotice" align="left"><p>文件名称:' . $filename . '<br />文件大小:' . $filesize . '<br />发布日期:' . get_the_modified_time('Y年n月j日') . '</p></div></div><div class="part" id="download_button_part"><a id="download_button" target="_blank" href="' . $href . '"><span></span>' . $filedown . '</a> </div><div class="part" style="padding:20px 0;"><div class="moredl" style="text-align:center;">[更多地址] : ' . $content . '</div></div><div class="dlfooter">' . gdk_option('gdk_fancydlad') . '</div></div>';
|
||||
}
|
||||
add_shortcode('fanctdl', 'gdk_ton');
|
||||
//代码演示短代码
|
||||
function gdk_demo($atts, $content = null)
|
||||
{
|
||||
return '<a class="lhb" href="' . get_permalink(gdk_page_id('demo')) . '?pid=' . get_the_ID() . '" target="_blank" rel="nofollow">' . $content . '</a>';
|
||||
}
|
||||
add_shortcode('demo', 'gdk_demo');
|
||||
|
||||
|
||||
//下载单页短代码
|
||||
function gdk_download($atts, $content = null)
|
||||
{
|
||||
return '<a class="lhb" href="' . get_permalink(gdk_page_id('download')) . '?pid=' . get_the_ID() . '" target="_blank" rel="nofollow">' . $content . '</a>';
|
||||
extract(shortcode_atts(array('title' => '点击下载',), $atts));
|
||||
return '<a class="cm-btn primary" href="' . home_url() . '?dl=' . get_the_ID() . '" target="_blank" rel="nofollow">' . $title . '</a>';
|
||||
}
|
||||
add_shortcode('download', 'gdk_download');
|
||||
add_shortcode('pdownload', 'gdk_download');
|
||||
|
||||
//为WordPress添加展开收缩功能
|
||||
function gdk_xcollapse($atts, $content = null)
|
||||
|
|
Loading…
Reference in a new issue