当前位置: 首页>>代码示例>>PHP>>正文


PHP mycred函数代码示例

本文整理汇总了PHP中mycred函数的典型用法代码示例。如果您正苦于以下问题:PHP mycred函数的具体用法?PHP mycred怎么用?PHP mycred使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mycred函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Construct 
  */
 function __construct()
 {
     // Default settings
     $defaults = array('setup' => 'off', 'type' => 'mycred_default', 'rate' => 100, 'share' => 0, 'log' => array('purchase' => __('Payment for tickets to %link_with_title%', 'mycred'), 'refund' => __('Ticket refund for %link_with_title%', 'mycred')), 'refund' => 0, 'labels' => array('header' => __('Pay using your %_plural% balance', 'mycred'), 'button' => __('Pay Now', 'mycred'), 'link' => __('Pay', 'mycred'), 'checkout' => __('%plural% Cost', 'mycred')), 'messages' => array('success' => __('Thank you for your payment!', 'mycred'), 'error' => __("I'm sorry but you can not pay for these tickets using %_plural%", 'mycred')));
     // Settings
     $settings = get_option('mycred_eventsmanager_gateway_prefs');
     $this->prefs = mycred_apply_defaults($defaults, $settings);
     $this->mycred_type = $this->prefs['type'];
     // Load myCRED
     $this->core = mycred($this->mycred_type);
     // Apply Whitelabeling
     $this->label = mycred_label();
     $this->title = strip_tags($this->label);
     $this->status_txt = 'Paid using ' . strip_tags($this->label);
     parent::__construct();
     if (!$this->is_active()) {
         return;
     }
     // Currency
     add_filter('em_get_currencies', array($this, 'add_currency'));
     if ($this->single_currency()) {
         add_filter('em_get_currency_formatted', array($this, 'format_price'), 10, 4);
     }
     // Adjust Ticket Columns
     add_filter('em_booking_form_tickets_cols', array($this, 'ticket_columns'), 10, 2);
     add_action('em_booking_form_tickets_col_mycred', array($this, 'ticket_col'), 10, 2);
     add_filter('em_bookings_table_cols_col_action', array($this, 'bookings_table_actions'), 10, 2);
     add_action('em_cart_form_after_totals', array($this, 'checkout_total'));
     // Refund
     if ($this->prefs['refund'] != 0) {
         add_filter('em_booking_set_status', array($this, 'refunds'), 10, 2);
     }
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:36,代码来源:mycred-eventsmanager-pro.php

示例2: __construct

 /**
  * Construct
  */
 function __construct($args = array(), $hook_prefs = NULL, $type = 'mycred_default')
 {
     if (!empty($args)) {
         foreach ($args as $key => $value) {
             $this->{$key} = $value;
         }
     }
     // Grab myCRED Settings
     $this->core = mycred($type);
     if (!empty($type)) {
         $this->core->cred_id = sanitize_text_field($type);
         $this->mycred_type = $this->core->cred_id;
     }
     if ($this->mycred_type != 'mycred_default') {
         $this->is_main_type = false;
     }
     // Grab settings
     if ($hook_prefs !== NULL) {
         // Assign prefs if set
         if (isset($hook_prefs[$this->id])) {
             $this->prefs = $hook_prefs[$this->id];
         }
         // Defaults must be set
         if (!isset($this->defaults)) {
             $this->defaults = array();
         }
     }
     // Apply default settings if needed
     if (!empty($this->defaults)) {
         $this->prefs = mycred_apply_defaults($this->defaults, $this->prefs);
     }
 }
开发者ID:nfer,项目名称:mycred,代码行数:35,代码来源:mycred-abstract-hook.php

示例3: the_quiz_button

 function the_quiz_button($button, $quiz_id)
 {
     global $post;
     $quiz_id = get_the_ID();
     $user_id = get_current_user_id();
     $flag = 1;
     if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
         $pid = get_post_meta($quiz_id, 'vibe_quiz_product', true);
         if (isset($pid) && is_numeric($pid) && get_post_type($pid) == 'product') {
             $product_taken = wc_customer_bought_product('', $user_id, $pid);
             if (!$product_taken) {
                 $pid = get_permalink($pid);
                 $check = vibe_get_option('direct_checkout');
                 $check = intval($check);
                 if (isset($check) && $check) {
                     $pid .= '?redirect';
                 }
                 $flag = 0;
                 $html = '<a href="' . $pid . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>';
             } else {
                 $flag = 1;
             }
         }
     }
     if (in_array('paid-memberships-pro/paid-memberships-pro.php', apply_filters('active_plugins', get_option('active_plugins'))) && is_user_logged_in()) {
         $membership_ids = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_membership', false));
         if (!pmpro_hasMembershipLevel($membership_ids, $user_id) && isset($membership_ids) && count($membership_ids) >= 1) {
             $membership_taken = get_user_meta($user_id, $quiz_id, true);
             if (!$membership_taken) {
                 $pmpro_levels_page_id = get_option('pmpro_levels_page_id');
                 $link = get_permalink($pmpro_levels_page_id);
                 $html = '<a href="' . $link . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>';
                 $flag = 0;
             } else {
                 $flag = 1;
             }
         }
     }
     if (in_array('wplms-mycred-addon/wplms-mycred-addon.php', apply_filters('active_plugins', get_option('active_plugins')))) {
         $points = get_post_meta($quiz_id, 'vibe_quiz_mycred_points', true);
         $mycred = mycred();
         $balance = $mycred->get_users_cred($user_id);
         if ($balance < $points) {
             $flag = 0;
             $html = '<a href="#"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '<span>' . __('<br/>Not enough points.', 'vibe') . '</span></a>';
         }
         if (!$mycred->has_entry('purchase_quiz', $quiz_id, $user_id)) {
             $flag = 1;
             $deduct = -1 * $points;
             $mycred->update_users_balance($user_id, $deduct);
             $mycred->add_to_log('purchase_quiz', $user_id, $deduct, __('Student subscibed to quiz', 'wplms-mycred'), $quiz_id);
         } else {
             $flag = 1;
         }
     }
     if (!$flag) {
         return $html;
     }
     return $button;
 }
开发者ID:VibeThemes,项目名称:wplms_sell_quiz,代码行数:60,代码来源:sell_quiz.php

示例4: __construct

 /**
  * Construct
  */
 function __construct($args = array(), $service_prefs = NULL)
 {
     if (!empty($args)) {
         foreach ($args as $key => $value) {
             $this->{$key} = $value;
         }
     }
     // Grab myCRED Settings
     $this->core = mycred();
     // Grab settings
     if ($service_prefs !== NULL) {
         // Assign prefs if set
         if (isset($service_prefs[$this->id])) {
             $this->prefs = $service_prefs[$this->id];
         }
         // Defaults must be set
         if (!isset($this->defaults) || empty($this->defaults)) {
             $this->defaults = array();
         }
     }
     // Apply default settings if needed
     if (!empty($this->defaults)) {
         $this->prefs = wp_parse_args($this->prefs, $this->defaults);
     }
 }
开发者ID:nfer,项目名称:mycred,代码行数:28,代码来源:mycred-abstract-service.php

示例5: __construct

 /**
  * Construct
  */
 function __construct()
 {
     // Default settings
     $defaults = array('labels' => array('gateway' => $this->label, 'payment' => $this->label . ' ' . __('Payments', 'mycred'), 'button' => __('Pay Now', 'mycred')), 'type' => 'mycred_default', 'rate' => 100, 'share' => 0, 'log' => __('Payment for Event Registration', 'mycred'), 'messages' => array('solvent' => 'Click "Pay Now" to pay using your %plural%.', 'insolvent' => 'Unfortunately you do not have enough %plural% to pay for this event.', 'visitors' => 'Payments using %_plural% is only available for registered members.'));
     // Settings
     $settings = get_option('mycred_espresso_gateway_prefs');
     $this->prefs = mycred_apply_defaults($defaults, $settings);
     $this->mycred_type = $this->prefs['type'];
     // Load myCRED
     $this->core = mycred($this->mycred_type);
 }
开发者ID:nfer,项目名称:mycred,代码行数:14,代码来源:mycred-eventespresso3.php

示例6: __construct

 /**
  * Construct
  */
 function __construct()
 {
     parent::__construct('myCRED_Sell_Content_Module', array('module_name' => 'sell_content', 'register' => false, 'defaults' => array('post_types' => 'post,page', 'type' => 'mycred_default', 'pay' => 'none', 'pay_percent' => 100, 'templates' => array('members' => '<p>Buy this %post_type% for only %price% %buy_button%</p>', 'visitors' => '<p><a href="%login_url_here%">Login</a> to buy access to this %post_type%.</p>', 'cantafford' => "<p>You do not have enough %plural% to buy access to this %post_type%.</p>\n<p><strong>Price</strong>: %price%</p>"), 'defaults' => array('price' => 10, 'overwrite_price' => 0, 'button_label' => __('Buy Now', 'mycred'), 'overwrite_buttonlabel' => 0, 'expire' => 0), 'logs' => array('buy' => 'Purchase of %link_with_title%', 'sell' => 'Sale of %link_with_title%')), 'add_to_core' => true));
     // Adjust Module to the selected point type
     $this->mycred_type = 'mycred_default';
     if (isset($this->sell_content['type'])) {
         $this->mycred_type = $this->sell_content['type'];
     }
     $this->core = mycred($this->mycred_type);
     add_filter('mycred_email_before_send', array($this, 'email_notices'), 10, 2);
 }
开发者ID:rafasashi,项目名称:mycred,代码行数:14,代码来源:myCRED-addon-sell-content.php

示例7: mycred_bbp_add_balance_in_profile

 function mycred_bbp_add_balance_in_profile()
 {
     $user_id = bbp_get_displayed_user_id();
     $mycred = mycred();
     if ($mycred->exclude_user($user_id)) {
         return;
     }
     $balance = $mycred->get_users_cred($user_id, $mycred->mycred_type);
     $layout = $mycred->plural() . ': ' . $mycred->format_creds($balance);
     $layout = apply_filters('mycred_bbp_authors_profile_balance', $layout, $balance, $user_id);
     echo apply_filters('mycred_bbp_profile_balance', '<div class="users-mycred-balance">' . $layout . '</div>', $user_id, $balance);
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:12,代码来源:mycred-hook-bbPress.php

示例8: mycred_render_shortcode_load_coupon

    function mycred_render_shortcode_load_coupon($atts, $content = NULL)
    {
        if (!is_user_logged_in()) {
            return $content;
        }
        $mycred = mycred();
        if (!isset($mycred->coupons)) {
            return '<p><strong>Coupon Add-on settings are missing! Please visit the myCRED > Settings page to save your settings before using this shortcode.</strong></p>';
        }
        // Prep
        $output = '
<div class="mycred-coupon-form">';
        $user_id = get_current_user_id();
        // No show for excluded users
        if ($mycred->exclude_user($user_id)) {
            return '';
        }
        // On submits
        if (isset($_POST['mycred_coupon_load']['token']) && wp_verify_nonce($_POST['mycred_coupon_load']['token'], 'mycred-load-coupon' . $user_id)) {
            $coupon = mycred_get_coupon_post($_POST['mycred_coupon_load']['couponkey']);
            $load = mycred_use_coupon($_POST['mycred_coupon_load']['couponkey'], $user_id);
            // Coupon does not exist
            if ($load === 'missing') {
                $output .= '<p class="mycred-coupon-status">' . $mycred->coupons['invalid'] . '</p>';
            } elseif ($load === 'expired') {
                $output .= '<p class="mycred-coupon-status">' . $mycred->coupons['expired'] . '</p>';
            } elseif ($load === 'max') {
                $output .= '<p class="mycred-coupon-status">' . $mycred->coupons['user_limit'] . '</p>';
            } elseif ($load === 'min_balance') {
                $min = get_post_meta($coupon->ID, 'min', true);
                $template = str_replace('%min%', $min, $mycred->coupons['min']);
                $output .= '<p class="mycred-coupon-status">' . $template . '</p>';
            } elseif ($load === 'max_balance') {
                $max = get_post_meta($coupon->ID, 'max', true);
                $template = str_replace('%max%', $max, $mycred->coupons['max']);
                $output .= '<p class="mycred-coupon-status">' . $template . '</p>';
            } else {
                $output .= '<p class="mycred-coupon-status">' . $mycred->coupons['success'] . '</p>';
            }
        }
        $output .= '
	<form action="" method="post">
		<p>
			<label for="mycred-coupon-code">' . __('Coupon', 'mycred') . '</label><br />
			<input type="text" name="mycred_coupon_load[couponkey]" id="mycred-coupon-couponkey" value="" /> 
			<input type="hidden" name="mycred_coupon_load[token]" value="' . wp_create_nonce('mycred-load-coupon' . $user_id) . '" />
			<input type="submit" class="btn btn-primary btn-large button button-large button-primary" value="' . __('Apply Coupon', 'mycred') . '" />
		</p>
	</form>
</div>';
        return apply_filters('mycred_load_coupon', $output, $atts, $content);
    }
开发者ID:nfer,项目名称:mycred,代码行数:52,代码来源:mycred-coupon-shortcodes.php

示例9: __construct

 /**
  * Construct
  */
 function __construct($key = NULL)
 {
     $this->handle_magic();
     $this->core = mycred();
     $this->key = $key;
     $this->method = $_SERVER['REQUEST_METHOD'];
     $this->uri = explode('/', $_SERVER['REQUEST_URI']);
     $this->format = '';
     $this->parse_call();
     $this->get_host_IP();
     // Let others play
     do_action_ref_array('mycred_remote', array(&$this));
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:16,代码来源:mycred-remote.php

示例10: __construct

 /**
  * Construct
  */
 function __construct()
 {
     // Default settings
     $defaults = array('setup' => 'off', 'type' => 'mycred_default', 'rate' => 100, 'share' => 0, 'log' => array('purchase' => __('Payment for tickets to %link_with_title%', 'mycred'), 'refund' => __('Ticket refund for %link_with_title%', 'mycred')), 'refund' => 0, 'labels' => array('header' => __('Pay using your %_plural% balance', 'mycred'), 'button' => __('Pay Now', 'mycred'), 'link' => __('Pay', 'mycred')), 'messages' => array('success' => __('Thank you for your payment!', 'mycred'), 'error' => __("I'm sorry but you can not pay for these tickets using %_plural%", 'mycred')));
     // Settings
     $settings = get_option('mycred_eventsmanager_gateway_prefs');
     $this->prefs = mycred_apply_defaults($defaults, $settings);
     $this->mycred_type = $this->prefs['type'];
     // Load myCRED
     $this->core = mycred($this->mycred_type);
     // Apply Whitelabeling
     $this->label = mycred_label();
 }
开发者ID:nfer,项目名称:mycred,代码行数:16,代码来源:mycred-eventsmanager.php

示例11: widget

 /**
  * Widget Output
  */
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     // Prep
     $title = $instance['title'];
     $mycred = mycred();
     if (!isset($mycred->transfers)) {
         return '<p>' . __('The myCRED Transfer add-on has not yet been setup!', 'mycred') . '</p>';
     }
     $pref = $mycred->transfers;
     global $mycred_load_transfer;
     // Members
     if (is_user_logged_in()) {
         // Excluded users
         $user_id = get_current_user_id();
         if ($mycred->exclude_user($user_id)) {
             return;
         }
         echo $before_widget;
         // Title
         if (!empty($title)) {
             echo $before_title;
             echo $mycred->template_tags_general($title);
             echo $after_title;
         }
         // Prep shortcode
         $attr = array('show_balance' => $instance['show_balance'], 'show_limit' => $instance['show_limit']);
         if (isset($instance['button']) && !empty($instance['button'])) {
             $attr['button'] = $instance['button'];
         }
         echo mycred_transfer_render($attr, '');
         $mycred_load_transfer = true;
         echo $after_widget;
     } else {
         $mycred_load = false;
         // If login message is set
         if (!empty($pref['templates']['login'])) {
             echo $before_widget;
             if (!empty($instance['title'])) {
                 echo $before_title;
                 echo $mycred->template_tags_general($title);
                 echo $after_title;
             }
             // Show login message
             echo '<p>' . $mycred->template_tags_general($pref['templates']['login']) . '</p>';
             echo $after_widget;
         }
         return;
     }
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:53,代码来源:mycred-transfer-widgets.php

示例12: __toString

 public function __toString()
 {
     $mycred = mycred();
     $count = 1;
     $output = '<ul class="wl-leaderboard">';
     foreach ($this->data as $position => $data) {
         $avatar = get_avatar($data->user_id, 24);
         $output .= "<li>{$avatar}<span><strong>{$data->user_login}</strong> avec " . $mycred->format_creds($data->total) . '</span>';
         $output .= "<span class=\"pull\">{$count}</span>";
         $output .= '</li>';
         $count++;
     }
     $output .= '</ul>';
     return $output;
 }
开发者ID:warlegend,项目名称:wl-leaderboards,代码行数:15,代码来源:leaderboard.php

示例13: __construct

 /**
  * Construct
  */
 function __construct($module_id = '', $args = array(), $type = 'mycred_default')
 {
     // Module ID is required
     if (empty($module_id)) {
         wp_die('myCRED_Module() Error. A Module ID is required!');
     }
     $this->module_id = $module_id;
     $this->core = mycred($type);
     if (!empty($type)) {
         $this->core->cred_id = sanitize_text_field($type);
         $this->mycred_type = $this->core->cred_id;
     }
     if ($this->mycred_type != 'mycred_default') {
         $this->is_main_type = false;
     }
     $this->point_types = mycred_get_types();
     // Default arguments
     $defaults = array('module_name' => '', 'option_id' => '', 'defaults' => array(), 'labels' => array('menu' => '', 'page_title' => ''), 'register' => true, 'screen_id' => '', 'add_to_core' => false, 'accordion' => false, 'cap' => 'plugin', 'menu_pos' => 10);
     $args = wp_parse_args($args, $defaults);
     $this->module_name = $args['module_name'];
     $this->option_id = $args['option_id'];
     if (!$this->is_main_type) {
         $this->option_id .= '_' . $this->mycred_type;
     }
     $this->settings_name = 'myCRED-' . $this->module_name;
     if (!$this->is_main_type) {
         $this->settings_name .= '-' . $this->mycred_type;
     }
     $this->labels = $args['labels'];
     $this->register = $args['register'];
     $this->screen_id = $args['screen_id'];
     if (!$this->is_main_type && !empty($this->screen_id)) {
         $this->screen_id = 'myCRED_' . $this->mycred_type . substr($this->screen_id, 6);
     }
     $this->add_to_core = $args['add_to_core'];
     $this->accordion = $args['accordion'];
     $this->cap = $args['cap'];
     $this->menu_pos = $args['menu_pos'];
     $this->default_prefs = $args['defaults'];
     $this->current_user_id = get_current_user_id();
     $this->now = current_time('timestamp');
     $this->set_settings();
 }
开发者ID:sebastianringel,项目名称:stammtisch,代码行数:46,代码来源:mycred-abstract-module.php

示例14: widget

 public function widget($args, $instance)
 {
     if (!$instance['show_visitors'] && !is_user_logged_in()) {
         return;
     }
     $leaderboard = WL_Leaderboard::current($instance['number']);
     $mycred = mycred();
     // Start constructing Widget
     $output = $args['before_widget'];
     // Title (if not empty)
     if (!empty($instance['title'])) {
         $output .= $args['before_title'];
         // Allow general template tags in the title
         $output .= $mycred->template_tags_general($instance['title']);
         $output .= $args['after_title'];
     }
     $output .= $leaderboard;
     $output .= $args['after_widget'];
     echo $output;
 }
开发者ID:warlegend,项目名称:wl-leaderboards,代码行数:20,代码来源:widget.php

示例15: get_spending

 /**
  * Get Spending
  * @version 1.0
  */
 function get_spending()
 {
     global $wpdb;
     if ($this->args['ctypes'] == 'all') {
         $point_types = $this->ctypes;
     } else {
         $point_types = array($this->args['ctypes'] => $this->ctypes[$this->args['ctypes']]);
     }
     $series = $ctypes = $categories = array();
     $num = 0;
     if (count($point_types) > 0) {
         foreach ($point_types as $type_id => $label) {
             $num++;
             $count = $wpdb->get_var("SELECT COUNT( * ) FROM {$this->core->log_table} WHERE ctype = '{$type_id}';");
             if ($count === NULL) {
                 $count = $num;
             }
             $ctypes[$count] = $type_id;
         }
         ksort($ctypes, SORT_NUMERIC);
     }
     foreach ($ctypes as $count => $type_id) {
         $values = array();
         foreach ($this->dates as $date) {
             $query = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT SUM( creds ) \n\t\t\t\t\t\tFROM {$this->core->log_table} \n\t\t\t\t\t\tWHERE creds < 0 \n\t\t\t\t\t\tAND ctype = %s \n\t\t\t\t\t\tAND time BETWEEN %d AND %d;", $type_id, $date['from'], $date['until']));
             if ($query === NULL) {
                 $query = 0;
             }
             $values[] = abs($query);
             if (!in_array($date['label'], $categories)) {
                 $categories[] = esc_attr($date['label']);
             }
         }
         $mycred = mycred($type_id);
         $series[] = "{ label : '" . esc_js($mycred->plural()) . "', fillColor : '" . str_replace(',1)', ',0.3)', $this->colors[$type_id]) . "', strokeColor : '" . $this->colors[$type_id] . "', pointColor : '" . $this->colors[$type_id] . "', data : [" . implode(', ', $values) . "] }";
     }
     return array('categories' => $categories, 'series' => $series);
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:42,代码来源:mycred-stats-widget-daily-loses.php


注:本文中的mycred函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。