/** * My History Content * @since 0.1 * @version 1.2 */ public function my_history_screen() { global $bp; $mycred_types = mycred_get_types(); $type = 'mycred_default'; if (isset($_REQUEST['show-ctype']) && array_key_exists($_REQUEST['show-ctype'], $mycred_types)) { $type = $_REQUEST['show-ctype']; } $args = array('user_id' => bp_displayed_user_id(), 'number' => apply_filters('mycred_bp_history_num_to_show', $this->buddypress['history_num']), 'ctype' => $type); if (isset($_GET['paged']) && $_GET['paged'] != '') { $args['paged'] = $_GET['paged']; } if (isset($bp->canonical_stack['action']) && $bp->canonical_stack['action'] != $this->buddypress['history_url']) { $args['time'] = $bp->canonical_stack['action']; } $log = new myCRED_Query_Log($args); unset($log->headers['column-username']); ob_start(); if (count($mycred_types) > 1) { ?> <form action="" id="mycred-sort-cred-history-form" method="get" style="display: block; height: 48px; float: right;"><label>Show:</label> <?php mycred_types_select_from_dropdown('show-ctype', 'mycred-select-type', $type); ?> <input type="submit" class="btn btn-large btn-primary button button-large button-primary" value="<?php _e('Go', 'mycred'); ?> " /></form> <?php } ?> <style type="text/css"> .pagination-links { float: right; } .tablenav { vertical-align: middle; } </style> <div class="wrap" id="myCRED-wrap"> <?php $log->mobile_support(); ?> <form method="get" action=""> <div class="tablenav top clear clearfix"> <?php if ($log->have_entries() && $log->max_num_pages > 1) { $log->navigation('top'); } ?> </div> <?php $log->display(); ?> <div class="tablenav bottom clear clearfix"> <?php if ($log->have_entries() && $log->max_num_pages > 1) { $log->navigation('bottom'); } ?> </div> </form> </div> <?php $log->reset_query(); $output = ob_get_contents(); ob_end_clean(); echo apply_filters('mycred_bp_history_page', $output, $this); }
function mycred_display_badge_requirements($post_id = NULL, $sep = '<br />') { $requirements = mycred_get_badge_requirements($post_id); if (empty($requirements)) { $reply = '-'; } else { $types = mycred_get_types(); $references = mycred_get_all_references(); $output = array(); foreach ($requirements as $row => $needs) { if (!isset($types[$needs['type']])) { $point_type = '-'; } else { $point_type = $types[$needs['type']]; } if (!isset($references[$needs['reference']])) { $ref = '-'; } else { $ref = $references[$needs['reference']]; } if ($needs['by'] == 'count') { $output[] = $point_type . ' ' . __('for', 'mycred') . ' ' . $ref . ' ' . $needs['amount'] . ' ' . __('time(s)', 'mycred'); } else { $output[] = $needs['amount'] . ' ' . $point_type . ' ' . __('for', 'mycred') . ' ' . $ref . ' ' . __('in total', 'mycred'); } } $reply = implode($sep, $output) . '.'; } return apply_filters('mycred_badge_display_requirements', $reply, $post_id, $sep); }
function mycred_render_my_ranks($atts, $content = NULL) { extract(shortcode_atts(array('user_id' => NULL, 'show_title' => 1, 'show_logo' => 0, 'logo_size' => 'post-thumbnail', 'first' => 'logo'), $atts)); if ($user_id === NULL && !is_user_logged_in()) { return; } if ($user_id === NULL) { $user_id = get_current_user_id(); } $mycred_types = mycred_get_types(); $show = array(); foreach ($mycred_types as $type_id => $label) { $row = array(); $rank_id = mycred_get_users_rank_id($user_id, $type_id); if ($show_logo) { $row[] = mycred_get_rank_logo($rank_id, $logo_size); } if ($show_title) { $row[] = get_the_title($rank_id); } if ($first != 'logo') { $row = array_reverse($row); } $show = array_merge($row, $show); } if (empty($show)) { return; } return '<div class="mycred-all-ranks">' . implode(' ', $show) . '</div>'; }
/** * 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); $this->point_types = mycred_get_types(); if ($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); } }
/** * Initialise Gateway Settings Form Fields * @since 0.1 * @version 1.4 */ function init_form_fields() { // Fields $fields['enabled'] = array('title' => __('Enable/Disable', 'mycred'), 'type' => 'checkbox', 'label' => __('Enable myCRED Payment', 'mycred'), 'default' => 'no', 'description' => __('Users who are not logged in or excluded from using myCRED will not have access to this gateway!', 'mycred')); $fields['title'] = array('title' => __('Title', 'mycred'), 'type' => 'text', 'description' => __('Title to show for this payment option.', 'mycred'), 'default' => __('Pay with myCRED', 'mycred'), 'desc_tip' => true); $fields['description'] = array('title' => __('Customer Message', 'mycred'), 'type' => 'textarea', 'default' => $this->mycred->template_tags_general('Deduct the amount from your %_plural% balance.')); $fields['log_template'] = array('title' => __('Log Template', 'mycred'), 'type' => 'text', 'description' => $this->mycred->available_template_tags(array('general'), '%order_id%, %order_link%'), 'default' => 'Payment for Order: #%order_id%'); $fields['log_template_refund'] = array('title' => __('Refund Log Template', 'mycred'), 'type' => 'text', 'description' => $this->mycred->available_template_tags(array('general'), '%order_id%, %reason%'), 'default' => 'Payment refund for order #%order_id% Reason: %reason%'); // Multiple Point Types Setup $mycred_types = mycred_get_types(); if (count($mycred_types) > 1) { $fields['point_type'] = array('title' => __('Point Type', 'mycred'), 'type' => 'select', 'label' => __('Select the point type users can use to pay.', 'mycred'), 'options' => $mycred_types, 'default' => 'mycred_default'); } else { $fields['point_type'] = array('type' => 'hidden', 'value' => 'mycred_default'); } // Only add exchange rate if the currecy is not set to mycred if ($this->use_exchange()) { $exchange_desc = __('How much is 1 %_singular% worth in %currency%?', 'mycred'); $exchange_desc = $this->mycred->template_tags_general($exchange_desc); $exchange_desc = str_replace('%currency%', get_woocommerce_currency(), $exchange_desc); $fields['exchange_rate'] = array('title' => __('Exchange Rate', 'mycred'), 'type' => 'text', 'description' => $exchange_desc, 'default' => 1, 'desc_tip' => true); $fields['show_total'] = array('title' => __('Show Total', 'mycred'), 'type' => 'select', 'label' => $this->mycred->template_tags_general(__('Show the final price in %_plural% .', 'mycred')), 'options' => array('' => __('Do not show', 'mycred'), 'cart' => __('Show in Cart', 'mycred'), 'checkout' => __('Show on Checkout Page', 'mycred'), 'all' => __('Show in Cart and on Checkout Page', 'mycred')), 'default' => ''); $fields['total_label'] = array('title' => __('Label', 'mycred'), 'type' => 'text', 'default' => $this->mycred->template_tags_general(__('Order Total in %_plural%', 'mycred')), 'desc_tip' => true); } // Profit Sharing added in 1.3 $fields['profit_sharing_percent'] = array('title' => __('Profit Sharing', 'mycred'), 'type' => 'text', 'description' => __('Option to share sales with the product owner. Use zero to disable.', 'mycred'), 'default' => 0, 'desc_tip' => true); $fields['profit_sharing_log'] = array('title' => __('Log Template', 'mycred'), 'type' => 'text', 'description' => __('Log entry template for profit sharing.', 'mycred') . ' ' . $this->mycred->available_template_tags(array('general', 'post')), 'default' => 'Sale of %post_title%'); $fields['profit_sharing_refund_log'] = array('title' => __('Refund Log Template', 'mycred'), 'type' => 'text', 'description' => __('Log entry template for refunds of profit shares.', 'mycred') . ' ' . $this->mycred->available_template_tags(array('general', 'post')), 'default' => 'Refund for order #%order_id%'); $this->form_fields = apply_filters('mycred_woo_fields', $fields, $this); }
/** * Construct */ function __construct($gateway_prefs) { $types = mycred_get_types(); $default_exchange = array(); foreach ($types as $type => $label) { $default_exchange[$type] = 1; } parent::__construct(array('id' => 'bitpay', 'label' => 'Bitpay', 'gateway_logo_url' => plugins_url('assets/images/bitpay.png', myCRED_PURCHASE), 'defaults' => array('api_key' => '', 'currency' => 'USD', 'exchange' => $default_exchange, 'item_name' => __('Purchase of myCRED %plural%', 'mycred'), 'speed' => 'high', 'notifications' => 1)), $gateway_prefs); }
/** * Construct */ function __construct($gateway_prefs) { $types = mycred_get_types(); $default_exchange = array(); foreach ($types as $type => $label) { $default_exchange[$type] = 1; } parent::__construct(array('id' => 'paypal-standard', 'label' => 'PayPal', 'gateway_logo_url' => plugins_url('assets/images/paypal.png', myCRED_PURCHASE), 'defaults' => array('sandbox' => 0, 'currency' => '', 'account' => '', 'item_name' => 'Purchase of myCRED %plural%', 'exchange' => $default_exchange)), $gateway_prefs); }
/** * Construct */ function __construct($gateway_prefs) { $types = mycred_get_types(); $default_exchange = array(); foreach ($types as $type => $label) { $default_exchange[$type] = 1; } parent::__construct(array('id' => 'skrill', 'label' => 'Skrill Payment', 'gateway_logo_url' => plugins_url('assets/images/skrill.png', myCRED_PURCHASE), 'defaults' => array('sandbox' => 0, 'currency' => '', 'account' => '', 'word' => '', 'account_title' => '', 'account_logo' => '', 'confirmation_note' => '', 'email_receipt' => 0, 'item_name' => 'Purchase of myCRED %plural%', 'exchange' => $default_exchange)), $gateway_prefs); }
/** * Construct */ function __construct($gateway_prefs) { global $netbilling_errors; $types = mycred_get_types(); $default_exchange = array(); foreach ($types as $type => $label) { $default_exchange[$type] = 1; } parent::__construct(array('id' => 'netbilling', 'label' => 'NETbilling', 'gateway_logo_url' => plugins_url('assets/images/netbilling.png', myCRED_PURCHASE), 'defaults' => array('sandbox' => 0, 'account' => '', 'site_tag' => '', 'item_name' => 'Purchase of myCRED %plural%', 'exchange' => $default_exchange, 'cryptokey' => '', 'currency' => 'USD')), $gateway_prefs); }
function mycred_update_to_onesix($version = NULL) { if ($version === NULL) { return; } // 1.6 Update if (version_compare($version, '1.6', '<')) { global $wpdb; $types = mycred_get_types(); // Remove Login hook markers if (count($types) == 1) { $wpdb->delete($wpdb->usermeta, array('meta_key' => 'mycred_last_login'), array('%s')); } else { foreach ($types as $type_id => $label) { $wpdb->delete($wpdb->usermeta, array('meta_key' => 'mycred_last_login_' . $type_id), array('%s')); } } // Update email notices to support multiple point types if (class_exists('myCRED_Email_Notice_Module')) { $notices = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'mycred_email_notice' AND post_status != 'trash';"); if (!empty($notices)) { foreach ($notices as $notice_id) { update_post_meta((int) $notice_id, 'mycred_email_ctype', 'all'); } } } // Update ranks to support multiple point types if (class_exists('myCRED_Ranks_Module')) { $ranks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'mycred_rank' AND post_status != 'trash';"); if (!empty($ranks)) { foreach ($ranks as $rank_id) { update_post_meta((int) $rank_id, 'ctype', 'mycred_default'); } } } } elseif (version_compare($version, '1.6.7', '<')) { $addons = mycred_get_option('mycred_pref_addons'); $addons = maybe_unserialize($addons); // Remove built-in add-ons Paths. if (!empty($addons['installed'])) { foreach ($addons['installed'] as $id => $info) { $addons['installed'][$id]['path'] = str_replace(myCRED_ADDONS_DIR, '', $info['path']); } mycred_update_option('mycred_pref_addons', $addons); } } // Update complted update_option('mycred_version', myCRED_VERSION); }
function mycred_get_type_color($type = NULL) { //$set = array( 'rgba(221,73,167,1)', 'rgba(106,187,218,1)', 'rgba(111,70,161,1)' ); //$set = array( 'rgba(213,78,33,1)', 'rgba(46,162,204,1)', 'rgba(34,34,34,1)' ); $set = array('rgba(204,175,11,1)', 'rgba(221,130,59,1)', 'rgba(207,73,68,1)', 'rgba(180,60,56,1)', 'rgba(34,34,34,1)'); $types = mycred_get_types(); $colors = array(); $row = 0; foreach ($types as $type_id => $label) { $colors[$type_id] = $set[$row]; $row++; } $result = $colors; if ($type !== NULL && array_key_exists($type, $colors)) { $result = $colors[$type]; } return apply_filters('mycred_point_type_colors', $result, $set, $type, $types); }
/** * Construct */ function __construct($widget_id = NULL, $args = array(), $default = NULL) { if ($widget_id === NULL) { return false; } $this->id = str_replace(array('_', '-', ' '), '', $widget_id); $this->ctypes = mycred_get_types(); if (!is_array($default)) { $default = array('ctypes' => 'all', 'span' => 0, 'number' => 5); } $this->args = wp_parse_args($args, $default); if ($this->args['ctypes'] == 'all') { $this->core = mycred(); } else { $this->core = mycred($this->args['ctypes']); } $this->colors = mycred_get_type_color(); $this->now = current_time('timestamp'); }
/** * 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(); }
function mycred_update_to_onesix($version = NULL) { if ($version === NULL) { return; } // 1.6 Update if (version_compare($version, '1.6', '<')) { global $wpdb; $types = mycred_get_types(); // Remove Login hook markers if (count($types) == 1) { $wpdb->delete($wpdb->usermeta, array('meta_key' => 'mycred_last_login'), array('%s')); } else { foreach ($types as $type_id => $label) { $wpdb->delete($wpdb->usermeta, array('meta_key' => 'mycred_last_login_' . $type_id), array('%s')); } } // Update email notices to support multiple point types if (class_exists('myCRED_Email_Notice_Module')) { $notices = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'mycred_email_notice' AND post_status != 'trash';"); if (!empty($notices)) { foreach ($notices as $notice_id) { update_post_meta((int) $notice_id, 'mycred_email_ctype', 'all'); } } } // Update ranks to support multiple point types if (class_exists('myCRED_Ranks_Module')) { $ranks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'mycred_rank' AND post_status != 'trash';"); if (!empty($ranks)) { foreach ($ranks as $rank_id) { update_post_meta((int) $rank_id, 'ctype', 'mycred_default'); } } } } // Update complted update_option('mycred_version', myCRED_VERSION); }
function mycred_display_badge_requirements($post_id = NULL, $sep = '<br />') { $requirements = mycred_get_badge_requirements($post_id); if (empty($requirements)) { $reply = '-'; } else { $types = mycred_get_types(); $references = mycred_get_all_references(); $req_count = count($requirements); $output = array(); foreach ($requirements as $level => $needs) { if ($needs['type'] == '') { $needs['type'] = 'mycred_default'; } if (!isset($types[$needs['type']])) { continue; } $mycred = mycred($needs['type']); $point_type = $mycred->plural(); if (!isset($references[$needs['reference']])) { $ref = '-'; } else { $ref = $references[$needs['reference']]; } $level_label = ''; if ($req_count > 1) { $level_label = '<strong>' . sprintf(__('Level %s', 'mycred'), $level + 1) . '</strong>'; } if ($needs['by'] == 'count') { $output[] = sprintf(_x('%s for %s %s - %s', '"Points" for "reference" "x time(s)" - Level', 'mycred'), $point_type, $ref, sprintf(_n('1 time', '%d times', $needs['amount'], 'mycred'), $needs['amount']), $level_label); } else { $output[] = sprintf(_x('%s for %s in total', '"x points" for "reference" in total', 'mycred'), $mycred->format_creds($needs['amount']), $ref); } } $reply = implode($sep, $output); } return apply_filters('mycred_badge_display_requirements', $reply, $post_id, $sep); }
/** * Get users balance * Returns the users balance unformated. * * @param $user_id (int), required user id * @param $type (string), optional cred type to check for * @returns zero if user id is not set or if no creds were found, else returns amount * @since 0.1 * @version 1.4 */ public function get_users_balance($user_id = NULL, $type = NULL) { if ($user_id === NULL) { return $this->zero(); } $types = mycred_get_types(); if ($type === NULL || !array_key_exists($type, $types)) { $type = $this->get_cred_id(); } $balance = mycred_get_user_meta($user_id, $type, '', true); if ($balance == '') { $balance = $this->zero(); } // Let others play $balance = apply_filters('mycred_get_users_cred', $balance, $this, $user_id, $type); return $this->number($balance); }
function mycred_woo_payout_rewards($order_id) { // Get Order $order = new WC_Order($order_id); // If we paid with myCRED we do not award points by default if ($order->payment_method == 'mycred' && apply_filters('mycred_woo_reward_mycred_payment', false) === false) { return; } // Get items $items = $order->get_items(); // Get point types $types = mycred_get_types(); // Loop foreach ($types as $type => $label) { // Load type $mycred = mycred($type); // Check for exclusions if ($mycred->exclude_user($order->user_id)) { continue; } // Calculate reward $reward = $mycred->zero(); foreach ($items as $item) { $prefs = (array) get_post_meta($item['product_id'], 'mycred_reward', true); if (isset($prefs[$type]) && $prefs[$type] != '') { $reward = $reward + $prefs[$type] * $item['qty']; } } // Award if ($reward != $mycred->zero()) { // Let others play with the reference and log entry $reference = apply_filters('mycred_woo_reward_reference', 'reward', $order_id, $type); $log = apply_filters('mycred_woo_reward_log', '%plural% reward for store purchase', $order_id, $type); // Execute $mycred->add_creds($reference, $order->user_id, $reward, $log, $order_id, array('ref_type' => 'post'), $type); } } }
/** * Construct * @since 1.6 * @version 1.0 */ public function __construct() { // Get all types $this->point_types = mycred_get_types(); // Get the used type (if used) $type = 'mycred_default'; $currency = affiliate_wp()->settings->get('currency', 'mycred_default'); if (array_key_exists($currency, $this->point_types)) { $type = $currency; } // Load myCRED $this->mycred = mycred($type); }
/** * Uninstall * TODO: Add a call to all add-ons to allow them to uninstall their own * settings and data once the core is gone. * @filter 'mycred_uninstall_this' * @since 0.1 * @version 1.3 */ public function uninstall() { // Everyone should use this filter to delete everything else they have created before returning the option ids. $installed = apply_filters('mycred_uninstall_this', array('mycred_pref_core', 'mycred_pref_hooks', 'mycred_pref_addons', 'mycred_pref_bank')); // Delete each option foreach ($installed as $option_id) { delete_option($GLOBALS['blog_id'], $option_id); } // Delete flags delete_option('mycred_setup_completed'); delete_option('mycred_version'); delete_option('mycred_version_db'); delete_option('mycred_key'); // Delete widget options delete_option('widget_mycred_widget_balance'); delete_option('widget_mycred_widget_list'); delete_option('widget_mycred_widget_transfer'); delete_option('mycred_ref_hook_counter'); // Remove Add-on settings delete_option('mycred_espresso_gateway_prefs'); delete_option('mycred_eventsmanager_gateway_prefs'); // Clear Cron wp_clear_scheduled_hook('mycred_reset_key'); wp_clear_scheduled_hook('mycred_banking_recurring_payout'); wp_clear_scheduled_hook('mycred_banking_do_batch'); wp_clear_scheduled_hook('mycred_banking_interest_compound'); wp_clear_scheduled_hook('mycred_banking_do_compound_batch'); wp_clear_scheduled_hook('mycred_banking_interest_payout'); wp_clear_scheduled_hook('mycred_banking_interest_do_batch'); global $wpdb; // Get log table if (defined('MYCRED_LOG_TABLE')) { $table_name = MYCRED_LOG_TABLE; } else { if (mycred_centralize_log()) { $table_name = $wpdb->base_prefix . 'myCRED_log'; } else { $table_name = $wpdb->prefix . 'myCRED_log'; } } // Delete log table $wpdb->query("DROP TABLE IF EXISTS {$table_name};"); // Multisite if (is_multisite()) { delete_site_option('mycred_network'); } // Delete custom post types $post_types = apply_filters('mycred_custom_post_types', array('mycred_rank', 'mycred_email_notice')); if (is_array($post_types) || !empty($post_types)) { $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ('" . implode("','", $post_types) . "');"); } // Delete all point types $mycred_types = mycred_get_types(); foreach ($mycred_types as $type => $label) { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s;", $type)); } // Good bye. }
function mycred_markpress_payout_rewards($order) { // Payment info $payment_info = get_post_meta($order->ID, 'mp_payment_info', true); if (!isset($payment_info['gateway_private_name']) || $payment_info['gateway_private_name'] == 'myCRED' && apply_filters('mycred_marketpress_reward_mycred_payment', false) === false) { return; } // Get buyer ID global $wpdb; $meta_id = 'mp_order_history'; if (is_multisite()) { global $blog_id; $meta_id = 'mp_order_history_' . $blog_id; } // Get buyer $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value LIKE %s", $meta_id, '%s:2:"id";i:' . $order->ID . ';%')); if ($user_id === NULL && !is_user_logged_in()) { return; } elseif ($user_id === NULL) { $user_id = get_current_user_id(); } // Get point types $types = mycred_get_types(); // Loop foreach ($types as $type => $label) { // Load type $mycred = mycred($type); // Check for exclusions if ($mycred->exclude_user($user_id)) { continue; } // Calculate reward $reward = $mycred->zero(); foreach ($order->mp_cart_info as $product_id => $variations) { foreach ($variations as $variation => $data) { $prefs = (array) get_post_meta((int) $product_id, 'mycred_reward', true); if (isset($prefs[$type]) && $prefs[$type] != '') { $reward = $reward + $prefs[$type] * $data['quantity']; } } } // Award if ($reward != $mycred->zero()) { // Let others play with the reference and log entry $reference = apply_filters('mycred_marketpress_reward_reference', 'marketpress_reward', $order_id, $type); $log = apply_filters('mycred_marketpress_reward_log', '%plural% reward for store purchase', $order_id, $type); // Execute $mycred->add_creds($reference, $order->user_id, $reward, $log, $order->ID, array('ref_type' => 'post'), $type); } } }
/** * Admin Footer * Inserts the Inline Edit Form modal. * @since 1.2 * @version 1.3.1 */ public function admin_footer() { // Security if (!$this->core->can_edit_creds()) { return; } $screen = get_current_screen(); if ($screen->id == 'users') { if ($this->core->can_edit_creds() && !$this->core->can_edit_plugin()) { $req = '(<strong>' . __('required', 'mycred') . '</strong>)'; } else { $req = '(' . __('optional', 'mycred') . ')'; } ob_start(); ?> <div id="edit-mycred-balance" style="display: none;"> <div class="mycred-adjustment-form"> <p class="row inline" style="width: 20%"><label><?php _e('ID', 'mycred'); ?> :</label><span id="mycred-userid"></span></p> <p class="row inline" style="width: 40%"><label><?php _e('User', 'mycred'); ?> :</label><span id="mycred-username"></span></p> <p class="row inline" style="width: 40%"><label><?php _e('Current Balance', 'mycred'); ?> :</label> <span id="mycred-current"></span></p> <div class="clear"></div> <input type="hidden" name="mycred_update_users_balance[token]" id="mycred-update-users-balance-token" value="<?php echo wp_create_nonce('mycred-update-users-balance'); ?> " /> <input type="hidden" name="mycred_update_users_balance[type]" id="mycred-update-users-balance-type" value="" /> <p class="row"><label for="mycred-update-users-balance-amount"><?php _e('Amount', 'mycred'); ?> :</label><input type="text" name="mycred_update_users_balance[amount]" id="mycred-update-users-balance-amount" value="" /><br /><span class="description"><?php _e('A positive or negative value', 'mycred'); ?> .</span></p> <p class="row"><label for="mycred-update-users-balance-entry"><?php _e('Log Entry', 'mycred'); ?> :</label><input type="text" name="mycred_update_users_balance[entry]" id="mycred-update-users-balance-entry" value="" /><br /><span class="description"><?php echo $req; ?> </span></p> <p class="row"><input type="button" name="mycred-update-users-balance-submit" id="mycred-update-users-balance-submit" value="<?php _e('Update Balance', 'mycred'); ?> " class="button button-primary button-large" /></p> <div class="clear"></div> </div> <div class="clear"></div> </div> <?php $content = ob_get_contents(); ob_end_clean(); echo apply_filters('mycred_admin_inline_editor', $content); } elseif ($screen->id == 'user-edit' || $screen->id == 'profile' || $screen->id == 'users_page_bp-profile-edit') { global $bp; if ($this->using_bp && version_compare($bp->version, '2.1', '>=')) { $types = mycred_get_types(); $user_id = get_current_user_id(); if (isset($_GET['user_id'])) { $user_id = (int) $_GET['user_id']; } $tabs = array(); foreach ($types as $type => $label) { $mycred = mycred($type); if ($mycred->exclude_user($user_id)) { continue; } $classes = 'nav-tab'; if (isset($_GET['ctype']) && $_GET['ctype'] == $type) { $classes .= ' nav-tab-active'; } $tabs[] = array('label' => $mycred->plural(), 'url' => esc_url(add_query_arg(array('page' => 'mycred-edit-balance', 'user_id' => $user_id, 'ctype' => $type), admin_url('users.php'))), 'classes' => $classes); } $user = get_userdata($user_id); $tabs = apply_filters('mycred_edit_profile_tabs_bp', $tabs, $user); $output = ''; foreach ($tabs as $tab) { $output .= '<a class="' . $tab['classes'] . '" href="' . $tab['url'] . '">' . esc_attr($tab['label']) . '</a>'; } ob_start(); ?> <script type="text/javascript"> jQuery(document).ready(function($) { $( 'h2#profile-nav' ).append( '<?php echo $output; ?> ' ); }); </script> <?php $content = ob_get_contents(); ob_end_clean(); echo apply_filters('mycred_admin_bp_nav', $content); } } }
function mycred_wpecom_gateway_settings() { global $wpdb, $mycred_wpecom_settings; if (!isset($mycred_wpecom_settings['type'])) { $type = 'mycred_default'; } else { $type = $mycred_wpecom_settings['type']; } $mycred = mycred($type); // Get current currency $currency_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A); $selected_currency = esc_attr(get_option('currency_type')); foreach ($currency_data as $currency) { if ($selected_currency != $currency['id']) { continue; } else { if (!empty($currency['symbol_html'])) { $selected_currency = $currency['symbol_html']; } else { $selected_currency = $currency['code']; } break; } } $output = ' <tr> <td colspan="2"><strong>' . __('General', 'mycred') . '</strong></td> </tr> <tr> <td width="150">' . __('Log Template for Payments', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[log]" value="' . esc_attr($mycred_wpecom_settings['log']) . '" style="width:50%;" /><br /><span class="description">' . $mycred->available_template_tags(array('general'), '%order_id%') . '</span></td> </tr>'; $mycred_types = mycred_get_types(); if (count($mycred_types) == 1) { $output .= '<input type="hidden" name="mycred_gateway[type]" value="mycred_default" />'; } else { $output .= ' <tr> <td width="150">' . __('Point Type', 'mycred') . '</td> <td>' . mycred_types_select_from_dropdown('mycred_gateway[type]', 'mycred-point-type', $type, true) . '</td> </tr>'; } $output .= ' <tr> <td width="150">' . __('Exchange Rate', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[rate]" value="' . esc_attr($mycred_wpecom_settings['rate']) . '" style="width:50px;" /><br /><span class="description">' . sprintf(__('How much is 1 %s worth in %s', 'mycred'), $selected_currency, $mycred->plural()) . '</span></td> </tr> <tr> <td colspan="2"><strong>' . __('Profit Sharing', 'mycred') . '</strong></td> </tr> <tr> <td width="150">' . __('Payout', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[share]" value="' . esc_attr($mycred_wpecom_settings['share']) . '" style="width:50px;" /> %<br /><span class="description">' . __('Option to share sales with the product owner. Use zero to disable.', 'mycred') . '</span></td> </tr> <tr> <td width="150">' . __('Log Template', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[share_log]" value="' . esc_attr($mycred_wpecom_settings['share_log']) . '" style="width:50%;" /><br /><span class="description">' . $mycred->available_template_tags(array('general', 'post')) . '</span></td> </tr> <tr> <td colspan="2"><strong>' . __('Messages', 'mycred') . '</strong></td> </tr> <tr> <td width="150">' . __('Instructions', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[message]" value="' . esc_attr($mycred_wpecom_settings['message']) . '" style="width:50%;" /><br /><span class="description">' . __('Optional instructions to show users when selecting this gateway. Leave empty to hide.', 'mycred') . '</span></td> </tr> <tr> <td width="150">' . __('Visitors', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[visitor]" value="' . esc_attr($mycred_wpecom_settings['visitor']) . '" style="width:50%;" /><br /><span class="description">' . __('Message to show visitors who are not logged in.', 'mycred') . '</span></td> </tr> <tr> <td width="150">' . __('Insufficient Funds', 'mycred') . '</td> <td><input type="text" name="mycred_gateway[low_funds]" value="' . esc_attr($mycred_wpecom_settings['low_funds']) . '" style="width:50%;" /><br /><span class="description">' . $mycred->template_tags_general(__('Message to show when users does not have enough %plural% to pay using this gateway.', 'mycred')) . '</span></td> </tr>'; return apply_filters('mycred_wpecom_settings', $output); }
/** * Gateway Settings * Included first when the gateway is activated. * @since 1.2 * @version 1.2 */ public function gateway_settings() { global $org_options; $exchange_message = sprintf(__('How many %s is 1 %s worth?', 'mycred'), $this->core->plural(), $org_options['currency_symbol']); $mycred_types = mycred_get_types(); ?> <?php if ($this->update) { ?> <h2 style="color: green;"><?php _e('Gateways Settings Successfully Updated', 'mycred'); ?> </h2> <?php } ?> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?> #mycred-gate"> <?php do_action('mycred_espresso_before_prefs'); ?> <table width="99%" border="0" cellspacing="5" cellpadding="5"> <tr> <td valign="top"> <h4><?php _e('Labels', 'mycred'); ?> </h4> <ul> <li> <label for="mycred-prefs-gateway-labels"><?php _e('Gateway Title', 'mycred'); ?> </label> <input type="text" name="mycred_prefs[labels][gateway]" id="mycred-prefs-gateway-labels" size="30" value="<?php echo $this->prefs['labels']['gateway']; ?> " /><br /> <span class="description"><?php _e('Title to show on Payment page', 'mycred'); ?> .</span> </li> <li> <label for="mycred-prefs-payment-labels"><?php _e('Payment Type', 'mycred'); ?> </label> <input type="text" name="mycred_prefs[labels][payment]" id="mycred-prefs-payment-labels" size="30" value="<?php echo $this->prefs['labels']['payment']; ?> " /><br /> <span class="description"><?php _e('Title to show on receipts and logs', 'mycred'); ?> .</span> </li> <li> <label for="mycred-prefs-button-labels"><?php _e('Button Label', 'mycred'); ?> </label> <input type="text" name="mycred_prefs[labels][button]" id="mycred-prefs-button-labels" size="30" value="<?php echo $this->prefs['labels']['button']; ?> " /><br /> <span class="description"><?php _e('Pay Button', 'mycred'); ?> </span> </li> </ul> <?php if (count($mycred_types) > 1) { ?> <ul> <li> <label for="mycred-prefs-payment-type"><?php _e('Point Type', 'mycred'); ?> </label> <?php mycred_types_select_from_dropdown('mycred_prefs[type]', 'mycred-prefs-payment-type', $this->prefs['type']); ?> </li> </ul> <?php } else { ?> <input type="hidden" name="mycred_prefs[type]" id="mycred-prefs-payment-type" value="mycred_default" /> <?php } ?> <h4><?php _e('Price', 'mycred'); ?> </h4> <ul> <li id="mycred-event-exchange-box"> <label for="mycred-prefs-price-x-rate"><?php _e('Exchange Rate', 'mycred'); ?> </label> <input type="text" name="mycred_prefs[rate]" id="mycred-prefs-price-x-rate" size="30" value="<?php echo $this->prefs['rate']; ?> " /><br /> <span class="description"><?php echo $exchange_message; ?> </span> </li> <li> <p><strong><?php _e('Important!', 'mycred'); ?> </strong></p> <ol> <li><?php _e('You can disable purchases using this gateway by adding a custom Event Meta: <code>mycred_no_sale</code>', 'mycred'); ?> </li> <li><?php _e('Users must be logged in to use this gateway!', 'mycred'); ?> </li> </ol> </li> <li id="mycred-event-profit-sharing"> <label for="mycred-prefs-profit-share"><?php _e('Profit Sharing', 'mycred'); ?> </label> <input type="text" name="mycred_prefs[share]" id="mycred-prefs-profit-share" size="5" value="<?php echo $this->prefs['share']; ?> " /> %<br /> <span class="description"><?php _e('Option to share sales with the product owner. Use zero to disable.', 'mycred'); ?> </span> </li> </ul> <h4><?php _e('Log', 'mycred'); ?> </h4> <ul> <li> <label for="mycred-prefs-log"><?php _e('Log Entry', 'mycred'); ?> </label> <input type="text" name="mycred_prefs[log]" id="mycred-prefs-log" size="30" value="<?php echo $this->prefs['log']; ?> " /><br /> <span class="description"><?php echo $this->core->available_template_tags(array('general')); ?> </span> </li> </ul> </td> <td valign="top"> <h4><?php _e('Templates', 'mycred'); ?> </h4> <ul> <li> <label for="mycred-prefs-message-solvent"><?php _e('Solvent users', 'mycred'); ?> </label> <textarea name="mycred_prefs[messages][solvent]" id="mycred-prefs-message-solvent" style="width: 90%; max-width: 90%; min-height: 90px;"><?php echo stripslashes($this->prefs['messages']['solvent']); ?> </textarea><br /> <span class="description"><?php _e('Message to show users on the payment page before they are charged. Leave empty to hide.', 'mycred'); ?> <br /><?php echo $this->core->available_template_tags(array('general')); ?> </span> </li> <li> <label for="mycred-prefs-message-insolvent"><?php _e('Insolvent users', 'mycred'); ?> </label> <textarea name="mycred_prefs[messages][insolvent]" id="mycred-prefs-message-solvent" style="width: 90%; max-width: 90%; min-height: 90px;"><?php echo stripslashes($this->prefs['messages']['insolvent']); ?> </textarea><br /> <span class="description"><?php _e('Message to show users who do not have enough points to pay.', 'mycred'); ?> <br /><?php echo $this->core->available_template_tags(array('general')); ?> </span> </li> <li> <label for="mycred-prefs-message-insolvent"><?php _e('Visitors', 'mycred'); ?> </label> <textarea name="mycred_prefs[messages][visitors]" id="mycred-prefs-message-visitors" style="width: 90%; max-width: 90%; min-height: 90px;"><?php echo stripslashes($this->prefs['messages']['visitors']); ?> </textarea><br /> <span class="description"><?php _e('Message to show visitors (users not logged in) on the payment page.', 'mycred'); ?> <br /><?php echo $this->core->available_template_tags(array('general')); ?> </span> </li> </ul> </td> </tr> </table> <?php do_action('mycred_espresso_after_prefs'); ?> <input type="hidden" name="mycred-gateway-action" value="update-settings" /> <input type="hidden" name="mycred-gateway-token" value="<?php echo wp_create_nonce('mycred-espresso-update'); ?> " /> <p><input class="button-primary" type="submit" name="Submit" value="<?php _e('Update Settings', 'mycred'); ?> " /></p> </form> <?php }
/** * Metabox: Coupon Setup * @since 1.4 * @version 1.0 */ public function metabox_coupon_setup($post) { global $mycred; $value = get_post_meta($post->ID, 'value', true); if (empty($value)) { $value = 1; } $expires = get_post_meta($post->ID, 'expires', true); $mycred_types = mycred_get_types(); $set_type = get_post_meta($post->ID, 'type', true); ?> <style type="text/css"> table { width: 100%; } table th { width: 20%; text-align: right; } table th label { padding-right: 12px; } table td { width: 80%; padding-bottom: 6px; } table td textarea { width: 95%; } </style> <input type="hidden" name="mycred-coupon-nonce" value="<?php echo wp_create_nonce('update-mycred-coupon'); ?> " /> <table class="table wide-fat"> <tbody> <tr valign="top"> <th scope="row"><label for="mycred-coupon-value"><?php _e('Value', 'mycred'); ?> </label></th> <td> <input type="text" name="mycred_coupon[value]" id="mycred-coupon-value" value="<?php echo $mycred->number($value); ?> " /><br /> <span class="description"><?php echo $mycred->template_tags_general(__('The amount of %plural% this coupon is worth.', 'mycred')); ?> </span> <?php if (count($mycred_types) > 1) { ?> <br /><label for="mycred-coupon-type"><?php _e('Point Type', 'mycred'); ?> </label><br /><?php mycred_types_select_from_dropdown('mycred_coupon[type]', 'mycred-coupon-type', $set_type); ?> <span class="description"><?php _e('Select the point type that this coupon is applied.', 'mycred'); ?> </span> <?php } ?> </td> </tr> <tr valign="top"> <th scope="row"><label for="mycred-coupon-value"><?php _e('Expire', 'mycred'); ?> </label></th> <td> <input type="text" name="mycred_coupon[expires]" id="mycred-coupon-expire" value="<?php echo $expires; ?> " placeholder="YYYY-MM-DD" /><br /> <span class="description"><?php _e('Optional date when this coupon expires. Expired coupons will be trashed.', 'mycred'); ?> </span> </td> </tr> </tbody> </table> <?php do_action('mycred_coupon_after_setup', $post); ?> <?php }
function mycred_widgets_init() { // Register Widgets register_widget('myCRED_Widget_Balance'); register_widget('myCRED_Widget_Leaderboard'); $mycred_types = mycred_get_types(); if (count($mycred_types) > 1) { register_widget('myCRED_Widget_Wallet'); } // Let others play do_action('mycred_widgets_init'); }
/** * Widget Output */ function widget($args, $instance) { extract($args, EXTR_SKIP); $mycred = mycred(); // If we are logged in if (is_user_logged_in()) { // Current user id $user_id = get_current_user_id(); // Start echo $before_widget; // Title if (!empty($instance['title'])) { echo $before_title; echo $mycred->template_tags_general($instance['title']); echo $after_title; } $mycred_types = mycred_get_types(); if (!empty($mycred_types) && !empty($instance['types'])) { foreach ($mycred_types as $type => $label) { $type_setup = mycred($type); // If user is excluded from using this point type if ($type_setup->exclude_user($user_id)) { continue; } // If type is selected if (!in_array($type, (array) $instance['types'])) { continue; } $balance = $type_setup->get_users_balance($user_id, $type); $row_template = $type_setup->template_tags_general($instance['row']); $row_template = $type_setup->template_tags_amount($row_template, $balance); $row_template = str_replace('%label%', $label, $row_template); echo '<div class="balance ' . $type . '">' . $row_template . '</div>'; } } // End echo $after_widget; } elseif (!is_user_logged_in() && $instance['show_visitors']) { echo $before_widget; // Title if (!empty($instance['title'])) { echo $before_title; echo $mycred->template_tags_general($instance['title']); echo $after_title; } $message = $instance['message']; $message = $mycred->template_tags_general($message); echo '<div class="myCRED-wallet-message"><p>' . nl2br($message) . '</p></div>'; echo $after_widget; } }
function mycred_load_banking() { global $mycred_modules; $mycred_types = mycred_get_types(); foreach ($mycred_types as $type => $title) { $mycred_modules[$type]['banking'] = new myCRED_Banking_Module($type); $mycred_modules[$type]['banking']->load(); } }
function mycred_render_shortcode_total_points($atts) { extract(shortcode_atts(array('type' => 'mycred_default', 'ref' => '', 'ref_id' => '', 'user_id' => '', 'formatted' => 1), $atts)); $types = mycred_get_types(); if (!array_key_exists($type, $types)) { $type = 'mycred_default'; } // First we construct the meta_key $point_type = $type; if (is_multisite() && $GLOBALS['blog_id'] > 1 && !mycred_centralize_log()) { $type .= '_' . $GLOBALS['blog_id']; } elseif (is_multisite() && $GLOBALS['blog_id'] > 1 && !mycred_override_settings()) { $type .= '_' . $GLOBALS['blog_id']; } $mycred = mycred($point_type); global $wpdb; // Simple if ($ref == '' && $ref_id == '' && $user_id == '') { // Add up all balances $total = $wpdb->get_var($wpdb->prepare("SELECT SUM( meta_value ) FROM {$wpdb->usermeta} WHERE meta_key = %s", $type)); } else { $wheres = array(); $wheres[] = $wpdb->prepare("ctype = %s", $point_type); $ref = sanitize_key($ref); if (strlen($ref) > 0) { // Either we have just one reference $multiple = explode(',', $ref); if (count($multiple) == 1) { $wheres[] = $wpdb->prepare("ref = %s", $ref); } else { $_clean = array(); foreach ($multiple as $ref) { $ref = sanitize_key($ref); if (strlen($ref) > 0) { $_clean[] = $ref; } } if (!empty($_clean)) { $wheres[] = "ref IN ( '" . implode("', '", $_clean) . "' )"; } } } $ref_id = sanitize_text_field($ref); if (strlen($ref_id) > 0) { $wheres[] = $wpdb->prepare("ref_id = %d", $ref_id); } $user_id = sanitize_text_field($ref); if (strlen($user_id) > 0) { $wheres[] = $wpdb->prepare("user_id = %d", $user_id); } $wheres = implode(" AND ", $wheres); $total = $wpdb->get_var("SELECT SUM( creds ) FROM {$mycred->log_table} WHERE {$wheres};"); } if ($total === NULL) { $total = 0; } if ($formatted == 1) { return $mycred->format_creds($total); } return $total; }
/** * Insert Ballance into Profile * @since 0.1 * @version 1.1 */ public function show_my_balance($user) { $user_id = $user->ID; $mycred_types = mycred_get_types(); foreach ($mycred_types as $type => $label) { $mycred = mycred($type); if ($mycred->exclude_user($user_id)) { continue; } $balance = $mycred->get_users_cred($user_id, $type); $balance = $mycred->format_creds($balance); ?> <tr> <th scope="row"><?php echo $mycred->template_tags_general(__('%singular% balance', 'mycred')); ?> </th> <td><h2 style="margin:0;padding:0;"><?php echo $balance; ?> </h2></td> </tr> <?php } }
/** * Getway Settings * @since 1.3 * @version 1.3 */ function mysettings() { global $page, $action; $gateway_link = admin_url('edit.php?post_type=' . EM_POST_TYPE_EVENT . '&page=events-manager-options#bookings'); if ($this->prefs['setup'] == 'multi') { $box = 'display: block;'; } else { $box = 'display: none;'; } $exchange_message = sprintf(__('How many %s is 1 %s worth?', 'mycred'), $this->core->plural(), em_get_currency_symbol()); $mycred_types = mycred_get_types(); do_action('mycred_em_before_settings', $this); ?> <h4><?php _e('Setup', 'mycred'); ?> </h4> <table class="form-table"> <?php if (count($mycred_types) > 1) { ?> <tr> <th scope="row"><?php _e('Point Type', 'mycred'); ?> </th> <td> <?php mycred_types_select_from_dropdown('mycred_gateway[type]', 'mycred-gateway-type', $this->prefs['type']); ?> </td> </tr> <?php } else { ?> <input type="hidden" name="mycred_gateway[type]" value="mycred_default" /> <?php } ?> <tr> <th scope="row"><?php _e('Payments', 'mycred'); ?> </th> <td> <input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-off" value="off"<?php checked($this->prefs['setup'], 'off'); ?> /> <label for="mycred-gateway-setup-off"><?php echo $this->core->template_tags_general(__('Disabled - Users CAN NOT pay for tickets using %plural%.', 'mycred')); ?> </label><br /> <input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-single" value="single"<?php checked($this->prefs['setup'], 'single'); ?> /> <label for="mycred-gateway-setup-single"><?php echo $this->core->template_tags_general(__('Single - Users can ONLY pay for tickets using %plural%.', 'mycred')); ?> </label><br /> <input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-multi" value="multi"<?php checked($this->prefs['setup'], 'multi'); ?> /> <label for="mycred-gateway-setup-multi"><?php echo $this->core->template_tags_general(__('Multi - Users can pay for tickets using other gateways or %plural%.', 'mycred')); ?> </label> </td> </tr> <tr> <th scope="row"><?php _e('Refunds', 'mycred'); ?> </th> <td> <input name="mycred_gateway[refund]" type="text" id="mycred-gateway-log-refund" value="<?php echo $this->prefs['refund']; ?> " size="5" /> %<br /> <span class="description"><?php _e('The percentage of the paid amount to refund if a user cancels their booking. Use zero for no refunds. No refunds are given to "Rejected" bookings!', 'mycred'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Profit Sharing', 'mycred'); ?> </th> <td> <input name="mycred_gateway[share]" type="text" id="mycred-gateway-profit-sharing" value="<?php echo $this->prefs['share']; ?> " size="5" /> %<br /> <span class="description"><?php _e('Option to share sales with the product owner. Use zero to disable.', 'mycred'); ?> </span> </td> </tr> </table> <table class="form-table" id="mycred-exchange-rate" style="<?php echo $box; ?> "> <tr> <th scope="row"><?php _e('Exchange Rate', 'mycred'); ?> </th> <td> <input name="mycred_gateway[rate]" type="text" id="mycred-gateway-rate" size="6" value="<?php echo $this->prefs['rate']; ?> " /><br /> <span class="description"><?php echo $exchange_message; ?> </span> </td> </tr> </table> <h4><?php _e('Log Templates', 'mycred'); ?> </h4> <table class="form-table"> <tr> <th scope="row"><?php _e('Purchases', 'mycred'); ?> </th> <td> <input name="mycred_gateway[log][purchase]" type="text" id="mycred-gateway-log-purchase" style="width: 95%;" value="<?php echo $this->prefs['log']['purchase']; ?> " size="45" /><br /> <span class="description"><?php echo $this->core->available_template_tags(array('general', 'post')); ?> ></span> </td> </tr> <tr> <th scope="row"><?php _e('Refunds', 'mycred'); ?> </th> <td> <input name="mycred_gateway[log][refund]" type="text" id="mycred-gateway-log-refund" style="width: 95%;" value="<?php echo $this->prefs['log']['refund']; ?> " size="45" /><br /> <span class="description"><?php echo $this->core->available_template_tags(array('general', 'post')); ?> </span> </td> </tr> </table> <script type="text/javascript"> jQuery(function($){ $('input[name="mycred_gateway[setup]"]').change(function(){ if ( $(this).val() == 'multi' ) { $('#mycred-exchange-rate').show(); } else { $('#mycred-exchange-rate').hide(); } }); }); </script> <h4><?php _e('Labels', 'mycred'); ?> </h4> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Payment Link Label', 'mycred'); ?> </th> <td> <input name="mycred_gateway[labels][link]" type="text" id="mycred-gateway-labels-link" style="width: 95%" value="<?php echo $this->prefs['labels']['link']; ?> " size="45" /><br /> <span class="description"><?php _e('The payment link shows / hides the payment form under "My Bookings". No HTML allowed.', 'mycred'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Payment Header', 'mycred'); ?> </th> <td> <input name="mycred_gateway[labels][header]" type="text" id="mycred-gateway-labels-header" style="width: 95%" value="<?php echo $this->prefs['labels']['header']; ?> " size="45" /><br /> <span class="description"><?php _e('Shown on top of the payment form. No HTML allowed.', 'mycred'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Button Label', 'mycred'); ?> </th> <td> <input name="mycred_gateway[labels][button]" type="text" id="mycred-gateway-labels-button" style="width: 95%" value="<?php echo $this->prefs['labels']['button']; ?> " size="45" /><br /> <span class="description"><?php _e('The button label for payments. No HTML allowed!', 'mycred'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Cart & Checkout Cost', 'mycred'); ?> </th> <td> <input name="mycred_gateway[labels][checkout]" type="text" id="mycred-gateway-labels-button" style="width: 95%" value="<?php echo $this->prefs['labels']['checkout']; ?> " size="45" /><br /> <span class="description"><?php echo $this->core->template_tags_general(__('Label for cost in %plural%', 'mycred')); ?> </span><br /><?php echo $this->core->available_template_tags(array('general')); ?> </span> </td> </tr> </table> <h4><?php _e('Messages', 'mycred'); ?> </h4> <table class='form-table'> <tr valign="top"> <th scope="row"><?php _e('Successful Payments', 'mycred'); ?> </th> <td> <input type="text" name="mycred_gateway[messages][success]" id="mycred-gateway-messages-success" style="width: 95%;" value="<?php echo stripslashes($this->prefs['messages']['success']); ?> " /><br /> <span class="description"><?php _e('No HTML allowed!', 'mycred'); ?> <br /><?php echo $this->core->available_template_tags(array('general')); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Insufficient Funds', 'mycred'); ?> </th> <td> <input type="text" name="mycred_gateway[messages][error]" id="mycred-gateway-messages-error" style="width: 95%;" value="<?php echo stripslashes($this->prefs['messages']['error']); ?> " /><br /> <span class="description"><?php _e('No HTML allowed!', 'mycred'); ?> <br /><?php echo $this->core->available_template_tags(array('general')); ?> </span> </td> </tr> </table> <?php do_action('mycred_em_after_settings', $this); }