function mycred_render_shortcode_give($atts, $content = '')
 {
     extract(shortcode_atts(array('amount' => '', 'user_id' => '', 'log' => '', 'ref' => 'gift', 'limit' => 0, 'type' => 'mycred_default'), $atts));
     if (!is_user_logged_in() && $user_id == '') {
         return $content;
     }
     $mycred = mycred($type);
     if ($user_id == '') {
         $user_id = get_current_user_id();
     } else {
         $user_id = absint($user_id);
     }
     // Check for exclusion
     if ($mycred->exclude_user($user_id)) {
         return;
     }
     // Limit
     $limit = absint($limit);
     if ($limit != 0 && mycred_count_ref_instances($ref, $user_id, $type) >= $limit) {
         return;
     }
     $mycred->add_creds($ref, $user_id, $amount, $log, '', '', $type);
 }
 /**
  * BuddyPress Profile
  * @since 1.4
  * @version 1.1
  */
 public function buddypress_profile()
 {
     // Prep
     $output = '';
     $user_id = bp_displayed_user_id();
     // Check for exclusion
     if ($this->core->exclude_user($user_id)) {
         return;
     }
     // If it is my profile or other members allowed to view eachothers profiles or if we are admins
     if (bp_is_my_profile() || mycred_is_admin()) {
         $users_ref_link = $this->get_ref_link($user_id, home_url('/'));
         $output .= '<div class="bp-widget mycred">';
         // Title if set
         if ($this->prefs['buddypress']['title'] != '') {
             $output .= '<h4>' . $this->prefs['buddypress']['title'] . '</h4>';
         }
         // Table
         $output .= '<table class="profile-fields">';
         $output .= sprintf('<tr class="field_1 field_ref_link"><td class="label">%s</td><td>%s</td></tr>', __('Link', 'mycred'), $users_ref_link);
         // Show Visitor referral count
         if ($this->prefs['visit']['creds'] != 0) {
             $output .= sprintf('<tr class="field_2 field_ref_count_visit"><td class="label">%s</td><td>%s</td></tr>', __('Visitors Referred', 'mycred'), mycred_count_ref_instances('visitor_referral', $user_id, $this->mycred_type));
         }
         // Show Signup referral count
         if ($this->prefs['signup']['creds'] != 0) {
             $output .= sprintf('<tr class="field_3 field_ref_count_signup"><td class="label">%s</td><td>%s</td></tr>', __('Signups Referred', 'mycred'), mycred_count_ref_instances('signup_referral', $user_id, $this->mycred_type));
         }
         $output .= '</table>';
         // Description if set
         if (!empty($this->prefs['buddypress']['desc'])) {
             $output .= wpautop(wptexturize($this->prefs['buddypress']['desc']));
         }
         $output .= '</div>';
     }
     $output = do_shortcode($output);
     echo apply_filters('mycred_affiliate_bp_profile', $output, $user_id, $users_ref_link, $this);
 }
示例#3
0
 function mycred_render_shortcode_give($atts)
 {
     if (!is_user_logged_in()) {
         return;
     }
     extract(shortcode_atts(array('amount' => NULL, 'user_id' => '', 'log' => '', 'ref' => 'gift', 'limit' => 0, 'type' => 'mycred_default'), $atts));
     if ($amount === NULL) {
         return '<strong>' . __('error', 'mycred') . '</strong> ' . __('Amount missing!', 'mycred');
     }
     if (empty($log)) {
         return '<strong>' . __('error', 'mycred') . '</strong> ' . __('Log Template Missing!', 'mycred');
     }
     $mycred = mycred();
     if (empty($user_id)) {
         $user_id = get_current_user_id();
     }
     // Check for exclusion
     if ($mycred->exclude_user($user_id)) {
         return;
     }
     // Limit
     $limit = abs($limit);
     if ($limit != 0 && mycred_count_ref_instances($ref, $user_id) >= $limit) {
         return;
     }
     $amount = $mycred->number($amount);
     $mycred->add_creds($ref, $user_id, $amount, $log, '', '', $type);
 }