diff --git a/assets/js/gdk.js b/assets/js/gdk.js index c65b2e7..7afdd9b 100644 --- a/assets/js/gdk.js +++ b/assets/js/gdk.js @@ -541,6 +541,24 @@ jQuery(function ($) { /**声明加载jQuery */ }); +/** + * 积分可见 + */ + $("#pay_points").click(function () { + var ajax_data = { + action: $("#pay_points").data("action"), + userid : $("#pay_points").data("userid"), + id : $("#pay_points").data("id"), + point : $("#pay_points").data("point") + + }; + $.post(ajax.url, ajax_data, function (b) { + b = $.trim(b); + if ('' !== b) { + show_hide_content('#hide_notice', b); + } + }); + }); diff --git a/class/points/class-points-shortcodes.php b/class/points/class-points-shortcodes.php index 42c947b..264032d 100644 --- a/class/points/class-points-shortcodes.php +++ b/class/points/class-points-shortcodes.php @@ -63,50 +63,37 @@ class GDK_Points_Shortcodes { public static function pay($atts, $content = null) { global $wpdb; $user_id = get_current_user_id(); - $description = get_the_ID(); - $result = $wpdb->get_row("SELECT description FROM " . GDK_Points_Database::points_get_table("users") . " WHERE user_id=" . $user_id . " AND description=" . $description . " AND status='accepted' LIMIT 0, 3;", ARRAY_A )['description']; //验证是否支付 + $pid = get_the_ID(); + $result = $wpdb->get_row("SELECT description FROM " . GDK_Points_Database::points_get_table("users") . " WHERE user_id=" . $user_id . " AND description=" . $pid . " AND status='accepted' LIMIT 0, 3;", ARRAY_A )['description']; //验证是否支付 extract(shortcode_atts(['point' => "10"], $atts)); $notice = ''; - $pay_content = get_post_meta($description, 'pay_content', true); - if (!empty($pay_content) && $pay_content != $content) { - update_post_meta($description, 'pay_content', $content, true); - } else { - add_post_meta($description, 'pay_content', $content, true); - } + add_post_meta($pid, '_point_content', $content, true) or update_post_meta($pid, '_point_content', $content);//没有新建,有就更新 if (is_user_logged_in()) { - if ($result == $description || current_user_can('administrator')) { - $notice.= '
本段内容需要支付 ' . $point . '金币查看
'; - $notice.= '您当前拥有 ' . GDK_Points::get_user_total_points($user_id, 'accepted') . ' 金币,您的金币不足,请充值
'; - $notice.= ''; - $notice.= '本段内容需要付费查看,您当前拥有 ' . GDK_Points::get_user_total_points($user_id, 'accepted') . ' 金币
'; - $notice.= ''; - $notice.= '查看本段内容需要支付 ' . $point . ' 金币
'; - $notice.= '您尚未登录,请 ' . $login_uri . ' 或者 立即注册
'; - $notice.= '您已登陆
您的ID是:'.$user_id.'
您的昵称是:'.$user->nickname.'
'; + //$result .= '您已登陆
您的ID是:'.$user_id.'
您的昵称是:'.$user->nickname.'
'; } return $result; } @@ -1129,13 +1130,6 @@ function editorial_hover_color( $hex, $steps ) { /** * Get minified css and removed space - * - * @since 1.2.5 - */ -/** - * Minify CSS - * - * @since 1.0.0 */ function pwd_minify_css( $css ) { @@ -1220,7 +1214,8 @@ function gdk_tag_dropdown(){ return $gdk_option_tag; } -function base64EncodeImage ($image_file) { +//转化图片为base64格式 +function base64img ($image_file) { $base64_image = ''; $image_info = getimagesize($image_file); $image_data = file_get_contents($image_file); diff --git a/functions/shortcode.php b/functions/shortcode.php index aa9ae68..47a7e16 100644 --- a/functions/shortcode.php +++ b/functions/shortcode.php @@ -202,7 +202,9 @@ add_shortcode('vip', 'gdk_login_to_read'); function gdk_secret_view($atts, $content = null) { $pid = get_the_ID(); add_post_meta($pid, '_pass_content', $content, true) or update_post_meta($pid, '_pass_content', $content); - if ( current_user_can( 'administrator' ) || gdk_is_weixin()) { return $content; }//admin show + if ( current_user_can( 'administrator' ) ) { + return ''; + }//admin show return '