10, 'order_by' => 'points', 'order' => 'DESC', ], $atts ); extract($options); $output = ''; $pointsusers = GDK_Points::get_users(); if (sizeof($pointsusers) > 0) { foreach ($pointsusers as $pointsuser) { $total = GDK_Points::get_user_total_points($pointsuser); $output .= '
'; $output .= ''; $output .= get_user_meta($pointsuser, 'nickname', true); $output .= ':'; $output .= ''; $output .= ' '.$total.' 金币'; $output .= ''; $output .= '
'; } } else { $output .= '

No users

'; } return $output; } public static function points_user_points($atts, $content = null) { $output = ''; $options = shortcode_atts( ['id' => ''], $atts ); extract($options); if ('' == $id) { $id = get_current_user_id(); } if (0 !== $id) { $points = GDK_Points::get_user_total_points($id, 'accepted'); $output .= $points; } return $output; } // 付费可见短代码开始 public static function pay($atts, $content = null) { $content = do_shortcode($content); global $wpdb; $user_id = get_current_user_id(); $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 = ''; add_post_meta($pid, '_point_content', $content, true) or update_post_meta($pid, '_point_content', $content); //没有新建,有就更新 if (is_user_logged_in()) { if ($result == $pid || current_user_can('administrator')) { $notice .= '
'; $notice .= $content; $notice .= '
'; } else { if (GDK_Points::get_user_total_points($user_id, 'accepted') < $point) { $notice .= '
付费内容'; $notice .= '

当前隐藏内容需要支付

'.$point.'金币'; $notice .= '

您当前拥有'.GDK_Points::get_user_total_points($user_id, 'accepted').'金币,金币不足,请充值

'; $notice .= buy_points(); $notice .= '
'; } else { $notice .= '
付费内容'; $notice .= '

当前隐藏内容需要支付

'.$point.'金币'; $notice .= '

您当前拥有'.GDK_Points::get_user_total_points($user_id, 'accepted').'金币

'; $notice .= '

'; $notice .= '
'; } } } else { $notice .= '
付费内容'; $notice .= '

当前隐藏内容需要支付

'.$point.'金币'; $notice .= '

您当前尚未登陆,请登陆后查看

'; $notice .= weixin_login_btn(); $notice .= '
'; } return $notice; } // 付费可见短代码结束 /** * Shortcode. 显示用户的金币细节 * * @param mixed $atts * @param null|mixed $content */ public static function points_user_points_details($atts, $content = null) { $options = shortcode_atts( [ 'user_id' => '', 'order_by' => 'point_id', 'order' => 'DESC', 'description' => true, ], $atts ); extract($options); date_default_timezone_set('Asia/Shanghai'); if (is_string($description) && (('0' == $description) || ('false' == strtolower($description)))) { $description = false; } $desc_th = ''; if ($description) { $desc_th = '描述'; } global $wp_query; $curauth = $wp_query->get_queried_object(); $user_id = $curauth->ID; $points = GDK_Points::get_points_by_user($user_id); $output = ''. ''. ''. ''. ''. $desc_th. ''; if (0 !== $user_id) { if (sizeof($points) > 0) { foreach ($points as $point) { $desc_td = ''; if ($description) { $desc_td = ''; } if ($point->points > 0) { $leibie = '充值'; } elseif ($point->points < 0) { $leibie = '消费'; } $output .= ''. ''. ''. ''. ''. $desc_td. ''; } } } $output .= '
日期时间'. '金币类别状态
'.$point->description.'
'.$point->datetime.''.$point->points.''.$leibie.''.$point->status.'
'; return $output; } } GDK_Points_Shortcodes::init();