/** * 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); } }
/** * Construct */ function myCRED_Widget_Transfer() { // Basic details about our widget $widget_ops = array('classname' => 'widget-my-cred-transfer', 'description' => __('Allow transfers between users.', 'mycred')); $this->WP_Widget('mycred_widget_transfer', sprintf(__('(%s) Transfer', 'mycred'), mycred_label(true)), $widget_ops); $this->alt_option_name = 'mycred_widget_transfer'; }
/** * Init Widget */ public static function init() { if (!current_user_can(apply_filters('mycred_overview_capability', 'edit_users'))) { return; } // Add widget wp_add_dashboard_widget(self::mycred_wid, sprintf(__('%s Overview', 'mycred'), mycred_label()), array('myCRED_Dashboard_Widget_Overview', 'widget')); }
/** * 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(); }
/** * Construct */ function __construct($type = 'mycred_default') { parent::__construct('myCRED_Stats_Module', array('module_name' => 'stats', 'register' => false), $type); $this->label = sprintf('%s %s', mycred_label(), __('Statistics', 'mycred')); $this->colors = mycred_get_type_color(); }
/** * Sanititze Settings * @filter 'mycred_save_core_prefs' * @since 0.1 * @version 1.4.1 */ public function sanitize_settings($post) { $new_data = array(); if ($this->mycred_type == 'mycred_default') { if (isset($post['types'])) { $types = array('mycred_default' => mycred_label()); foreach ($post['types'] as $item => $data) { // Make sure it is not marked as deleted if (isset($post['delete_types']) && in_array($item, $post['delete_types'])) { continue; } // Skip if empty if (empty($data['key']) || empty($data['label'])) { continue; } // Add if not in array already if (!array_key_exists($data['key'], $types)) { $key = str_replace(array(' ', '-'), '_', $data['key']); $key = sanitize_key($key); $types[$key] = sanitize_text_field($data['label']); } } mycred_update_option('mycred_types', $types); unset($post['types']); if (isset($post['delete_types'])) { unset($post['delete_types']); } } $new_data['format'] = $this->core->core['format']; if (isset($post['format']['type']) && $post['format']['type'] != '') { $new_data['format']['type'] = absint($post['format']['type']); } if (isset($post['format']['decimals'])) { $new_data['format']['decimals'] = absint($post['format']['decimals']); } } else { $main_settings = mycred_get_option('mycred_pref_core'); $new_data['format'] = $main_settings['format']; if (isset($post['format']['decimals'])) { $new_decimals = absint($post['format']['decimals']); if ($new_decimals <= $main_settings['format']['decimals']) { $new_data['format']['decimals'] = $new_decimals; } } } // Format $new_data['cred_id'] = $this->mycred_type; $new_data['format']['separators']['decimal'] = $this->maybe_whitespace($post['format']['separators']['decimal']); $new_data['format']['separators']['thousand'] = $this->maybe_whitespace($post['format']['separators']['thousand']); // Name $new_data['name'] = array('singular' => sanitize_text_field($post['name']['singular']), 'plural' => sanitize_text_field($post['name']['plural'])); // Look $new_data['before'] = sanitize_text_field($post['before']); $new_data['after'] = sanitize_text_field($post['after']); // Capabilities $new_data['caps'] = array('plugin' => sanitize_text_field($post['caps']['plugin']), 'creds' => sanitize_text_field($post['caps']['creds'])); // Max $new_data['max'] = $this->core->number($post['max']); // Make sure multisites uses capabilities that exists if (in_array($new_data['caps']['creds'], array('create_users', 'delete_themes', 'edit_plugins', 'edit_themes', 'edit_users')) && is_multisite()) { $new_data['caps']['creds'] = 'delete_users'; } // Excludes $new_data['exclude'] = array('plugin_editors' => isset($post['exclude']['plugin_editors']) ? $post['exclude']['plugin_editors'] : 0, 'cred_editors' => isset($post['exclude']['cred_editors']) ? $post['exclude']['cred_editors'] : 0, 'list' => sanitize_text_field($post['exclude']['list'])); // Remove Exclude users balances if ($new_data['exclude']['list'] != '') { $excluded_ids = explode(',', $new_data['exclude']['list']); if (!empty($excluded_ids)) { foreach ((array) $excluded_ids as $user_id) { $user_id = absint(trim($user_id)); if ($user_id == 0) { continue; } mycred_delete_user_meta($user_id, $this->mycred_type); mycred_delete_user_meta($user_id, $this->mycred_type, '_total'); } } } // User deletions $new_data['delete_user'] = isset($post['delete_user']) ? $post['delete_user'] : 0; $action_hook = ''; if (!$this->is_main_type) { $action_hook = $this->mycred_type; } $new_data = apply_filters('mycred_save_core_prefs' . $action_hook, $new_data, $post, $this); return $new_data; }
/** * Sell Meta Box * @since 0.1 * @version 1.2 */ public function metabox($post) { // Make sure add-on has been setup if (!$this->is_installed()) { echo sprintf(__('%s Sell Content needs to be setup before you can use this feature.', 'mycred'), mycred_label()); // Settings Link if ($this->core->can_edit_plugin(get_current_user_id())) { echo ' <a href="' . $this->get_settings_url('sell_content_module') . '" title="' . __('Setup add-on', 'mycred') . '">' . __('Lets do it', 'mycred') . '</a>'; } return; } $admin = false; $post_id = $post->ID; $post_type = $post->post_type; $user_id = get_current_user_id(); $sell_content = $this->sell_content; $sales_data = $this->get_sale_prefs($post_id); // Mark admins if ($this->core->can_edit_plugin($user_id)) { $admin = true; } // Empty $sales_data means disabled same if the status is actually set to "disabled" if (empty($sales_data) || isset($sales_data['status']) && $sales_data['status'] == 'disabled') { $style = 'display:none;'; $status = 'disabled'; } else { $style = 'display:block;'; $status = 'enabled'; } $op = (bool) $sell_content['defaults']['overwrite_price']; $ob = (bool) $sell_content['defaults']['overwrite_buttonlabel']; ?> <style type="text/css"> #mycred_sell_content .inside { margin: 0; padding: 0; } #mycred_sell_content .inside p { padding: 0 12px; } #mycred_sell_content .inside ul { margin: 0; padding: 0 0 12px 0; background-color: #F5F5F5; border-top: 1px solid #ccc; } #mycred_sell_content .inside ul li { padding: 8px 12px 0 12px; margin: 0 0 0 0; } #mycred_sell_content .inside ul li label { font-weight: bold; display: block; } #mycred_sell_content .inside ul li.disabled { color: #ccc; } input[name="myCRED_sell_content[button_label]"] { width: 100%; } </style> <p><label for="mycred-sell-this"><input type="checkbox" name="mycred_sell_this" id="mycred-sell-this"<?php checked($status, 'enabled'); ?> value="enabled" /> <?php printf(__('Enable sale of this %s', 'mycred'), $post_type); ?> </label></p> <div id="mycred-sale-settings" style="<?php echo $style; ?> "> <input type="hidden" name="mycred-sell-this-token" value="<?php echo wp_create_nonce('mycred-sell-this'); ?> " /> <input type="hidden" name="mycred-sell-this-status" value="<?php echo $status; ?> " /> <ul> <li<?php if ($op === false && !$admin) { echo ' class="disabled"'; } ?> > <label for="mycred-buy-prefs-"><?php _e('Price', 'mycred'); ?> </label> <div class="formated"><?php echo $this->core->before; ?> <input type="text" name="myCRED_sell_content[price]" id="mycred-buy-prefs-price" value="<?php echo $sales_data['price']; ?> " <?php if ($op === false && !$admin) { echo 'disabled="disabled" class="disabled"'; } ?> size="12" /> <?php echo $this->core->after; ?> </div> </li> <li<?php if ($ob === false && !$admin) { echo ' class="disabled"'; } ?> > <label for="mycred-buy-prefs-"><?php _e('Button Label', 'mycred'); ?> </label> <input type="text" name="myCRED_sell_content[button_label]" id="mycred-buy-prefs-button" value="<?php echo $sales_data['button_label']; ?> " <?php if ($ob === false && !$admin) { echo 'disabled="disabled" class="disabled"'; } ?> /> </li> <li<?php if ($op === false && !$admin) { echo ' class="disabled"'; } ?> > <label for="mycred-buy-prefs-"><?php _e('Purchase expires after', 'mycred'); ?> </label> <div class="formated"><input type="text" name="myCRED_sell_content[expire]" id="mycred-buy-prefs-expire" value="<?php echo $sales_data['expire']; ?> " <?php if ($op === false && !$admin) { echo 'disabled="disabled" class="disabled"'; } ?> size="12" /> <?php echo $this->exp_title; ?> </div> </li> </ul> </div> <div class="clear"></div> <script type="text/javascript"> jQuery(function($) { $( '#mycred-sell-this' ).click(function(){ $( '#mycred-sale-settings' ).toggle(); }); }); </script> <?php }
/** * Admin Page * @since 0.1 * @version 1.0 */ public function admin_page() { // Security if (!$this->core->can_edit_plugin(get_current_user_id())) { wp_die(__('Access Denied', 'mycred')); } // Available Imports if (empty($this->installed)) { $this->get(); } ?> <div class="wrap list" id="myCRED-wrap"> <div id="icon-myCRED" class="icon32"><br /></div> <h2><?php echo sprintf(__('%s Import', 'mycred'), mycred_label()); ?> </h2> <?php // Errors if (!empty($this->errors)) { echo '<div class="error"><p>' . $this->errors . '</p></div>'; } elseif ($this->import_ok !== false) { echo '<div class="updated"><p>' . $this->import_ok . '</p></div>'; } ?> <p><?php _e('Remember to de-activate this add-on once you are done importing!', 'mycred'); ?> </p> <div class="list-items expandable-li" id="accordion"> <?php if (!empty($this->installed)) { foreach ($this->installed as $id => $data) { $call = $id . '_form'; $this->{$call}($data); } } ?> </div> </div> <?php unset($this); }
/** * myCRED Gateway Settings * @since 1.1 * @version 1.3 */ function gateway_settings_box($settings) { global $mp; $settings = get_option('mp_settings'); $mycred = mycred(); $name = mycred_label(true); $settings['gateways']['mycred'] = shortcode_atts(array('name' => $name . ' ' . $mycred->template_tags_general(__('%_singular% Balance', 'mycred')), 'logo' => $this->method_button_img_url, 'type' => 'mycred_default', 'log_template' => __('Payment for Order: #%order_id%', 'mycred'), 'exchange' => 1, 'profit_share_percent' => 0, 'profit_share_log' => __('Product Sale: %post_title%', 'mycred'), 'instructions' => __('Pay using your account balance.', 'mycred'), 'confirmation' => __('TOTAL amount has been deducted from your account. Your current balance is: %balance_f%', 'mycred'), 'lowfunds' => __('Insufficient funds.', 'mycred'), 'visitors' => __('You must be logged in to pay with %_plural%. Please <a href="%login_url_here%">login</a>.', 'mycred'), 'email' => $settings['email']['new_order_txt']), isset($settings['gateways']['mycred']) ? $settings['gateways']['mycred'] : array()); ?> <div id="mp_mycred_payments" class="postbox mp-pages-msgs"> <h3 class="handle"><span><?php echo $name . ' ' . __('Settings', 'mycred'); ?> </span></h3> <div class="inside"> <span class="description"><?php echo sprintf(__('Let your users pay for items in their shopping cart using their %s Account. Note! This gateway requires your users to be logged in when making a purchase!', 'mycred'), $name); ?> </span> <table class="form-table"> <tr> <th scope="row"><label for="mycred-method-name"><?php _e('Method Name', 'mycred'); ?> </label></th> <td> <span class="description"><?php _e('Enter a public name for this payment method that is displayed to users - No HTML', 'mycred'); ?> </span> <p><input value="<?php echo esc_attr($settings['gateways']['mycred']['name']); ?> " style="width: 100%;" name="mp[gateways][mycred][name]" id="mycred-method-name" type="text" /></p> </td> </tr> <tr> <th scope="row"><label for="mycred-method-logo"><?php _e('Gateway Logo URL', 'mycred'); ?> </label></th> <td> <p><input value="<?php echo esc_attr($settings['gateways']['mycred']['logo']); ?> " style="width: 100%;" name="mp[gateways][mycred][logo]" id="mycred-method-logo" type="text" /></p> </td> </tr> <tr> <th scope="row"><label for="mycred-method-type"><?php _e('Point Type', 'mycred'); ?> </label></th> <td> <?php mycred_types_select_from_dropdown('mp[gateways][mycred][type]', 'mycred-method-type', $settings['gateways']['mycred']['type']); ?> </td> </tr> <tr> <th scope="row"><label for="mycred-log-template"><?php _e('Log Template', 'mycred'); ?> </label></th> <td> <span class="description"><?php echo $mycred->available_template_tags(array('general'), '%order_id%, %order_link%'); ?> </span> <p><input value="<?php echo esc_attr($settings['gateways']['mycred']['log_template']); ?> " style="width: 100%;" name="mp[gateways][mycred][log_template]" id="mycred-log-template" type="text" /></p> </td> </tr> <?php // Exchange rate if ($this->use_exchange()) { $exchange_desc = __('How much is 1 %_singular% worth in %currency%?', 'mycred'); $exchange_desc = $mycred->template_tags_general($exchange_desc); $exchange_desc = str_replace('%currency%', $settings['currency'], $exchange_desc); ?> <tr> <th scope="row"><label for="mycred-exchange-rate"><?php _e('Exchange Rate', 'mycred'); ?> </label></th> <td> <span class="description"><?php echo $exchange_desc; ?> </span> <p><input value="<?php echo esc_attr($settings['gateways']['mycred']['exchange']); ?> " size="8" name="mp[gateways][mycred][exchange]" id="mycred-exchange-rate" type="text" /></p> </td> </tr> <?php } ?> <tr> <td colspan="2"><h4><?php _e('Profit Sharing', 'mycred'); ?> </h4></td> </tr> <tr> <th scope="row"><label for="mycred-profit-sharing"><?php _e('Percentage', 'mycred'); ?> </label></th> <td> <span class="description"><?php _e('Option to share sales with the product owner. Use zero to disable.', 'mycred'); ?> </span> <p><input value="<?php echo esc_attr($settings['gateways']['mycred']['profit_share_percent']); ?> " size="8" name="mp[gateways][mycred][profit_share_percent]" id="mycred-profit-sharing" type="text" /> %</p> </td> </tr> <tr> <th scope="row"><label for="mycred-profit-sharing-log"><?php _e('Log Template', 'mycred'); ?> </label></th> <td> <span class="description"><?php echo $mycred->available_template_tags(array('general', 'post')); ?> </span> <p><input value="<?php echo esc_attr($settings['gateways']['mycred']['profit_share_log']); ?> " style="width: 100%;" name="mp[gateways][mycred][profit_share_log]" id="mycred-profit-sharing-log" type="text" /></p> </td> </tr> <tr> <td colspan="2"><h4><?php _e('Messages', 'mycred'); ?> </h4></td> </tr> <tr> <th scope="row"><label for="mycred-lowfunds"><?php _e('Insufficient Funds', 'mycred'); ?> </label></th> <td> <span class="description"><?php _e('Message to show when the user can not use this gateway.', 'mycred'); ?> </span> <p><input type="text" name="mp[gateways][mycred][lowfunds]" id="mycred-lowfunds" style="width: 100%;" value="<?php echo esc_attr($settings['gateways']['mycred']['lowfunds']); ?> "><br /> <span class="description"><?php echo $mycred->available_template_tags(array('general')); ?> </span></p> </td> </tr> <tr> <th scope="row"><label for="mycred-visitors"><?php _e('Visitors', 'mycred'); ?> </label></th> <td> <span class="description"><?php _e('Message to show to buyers that are not logged in.', 'mycred'); ?> </span> <p><input type="text" name="mp[gateways][mycred][visitors]" id="mycred-visitors" style="width: 100%;" value="<?php echo esc_attr($settings['gateways']['mycred']['visitors']); ?> "><br /> <span class="description"><?php echo $mycred->available_template_tags(array('general')); ?> </span></p> </td> </tr> <tr> <th scope="row"><label for="mycred-instructions"><?php _e('User Instructions', 'mycred'); ?> </label></th> <td> <span class="description"><?php _e('Information to show users before payment.', 'mycred'); ?> </span> <p><?php wp_editor($settings['gateways']['mycred']['instructions'], 'mycred-instructions', array('textarea_name' => 'mp[gateways][mycred][instructions]')); ?> <br /> <span class="description"><?php echo $mycred->available_template_tags(array('general'), '%balance% or %balance_f%'); ?> </span></p> </td> </tr> <tr> <th scope="row"><label for="mycred-confirmation"><?php _e('Confirmation Information', 'mycred'); ?> </label></th> <td> <span class="description"><?php _e('Information to display on the order confirmation page. - HTML allowed', 'mycred'); ?> </span> <p><?php wp_editor($settings['gateways']['mycred']['confirmation'], 'mycred-confirmation', array('textarea_name' => 'mp[gateways][mycred][confirmation]')); ?> <br /> <span class="description"><?php echo $mycred->available_template_tags(array('general'), '%balance% or %balance_f%'); ?> </span></p> </td> </tr> <tr> <th scope="row"><label for="mycred-email"><?php _e('Order Confirmation Email', 'mycred'); ?> </label></th> <td> <span class="description"><?php echo sprintf(__('This is the email text to send to those who have made %s checkouts. It overrides the default order checkout email. These codes will be replaced with order details: CUSTOMERNAME, ORDERID, ORDERINFO, SHIPPINGINFO, PAYMENTINFO, TOTAL, TRACKINGURL. No HTML allowed.', 'mycred'), $name); ?> </span> <p><textarea id="mycred-email" name="mp[gateways][mycred][email]" class="mp_emails_txt"><?php echo esc_textarea($settings['gateways']['mycred']['email']); ?> </textarea></p> <span class="description"><?php echo $mycred->available_template_tags(array('general'), '%balance% or %balance_f%'); ?> </span> </td> </tr> </table> </div> </div> <?php }
/** * Setup page * Outputs the setup page. * @since 0.1 * @version 1.1 */ public function setup_page() { $label = sprintf(__('%s Setup', 'mycred'), mycred_label()); if ($this->step !== false) { $label .= ' <span>' . __('Step', 'mycred') . ' ' . $this->step . ' / 3'; } ?> <div class="wrap setup" id="myCRED-wrap"> <h2><?php echo $label; ?> </span></h2> <?php $this->get_view(); ?> </div> <?php }
/** * Update Settings * @since 1.2 * @version 1.2 */ public function update_settings() { // Apply Whitelabeling $this->label = mycred_label(); // Security if (!wp_verify_nonce($_REQUEST['mycred-gateway-token'], 'mycred-espresso-update')) { return; } if (!$this->core->can_edit_plugin()) { return; } // Prep $new_settings = array(); $post = $_POST['mycred_prefs']; if (!is_array($post) || empty($post)) { return; } // Labels $new_settings['labels']['gateway'] = strip_tags($post['labels']['gateway'], '<strong><em><span>'); $new_settings['labels']['payment'] = strip_tags($post['labels']['payment'], '<strong><em><span>'); $new_settings['labels']['button'] = sanitize_text_field($post['labels']['button']); // Point Type $new_settings['type'] = sanitize_text_field($post['type']); // Exchange Rate $new_settings['rate'] = sanitize_text_field($post['rate']); // Profit Share $new_settings['share'] = abs($post['share']); // Log $new_settings['log'] = sanitize_text_field($post['log']); // Messages $new_settings['messages']['solvent'] = sanitize_text_field(stripslashes($post['messages']['solvent'])); $new_settings['messages']['insolvent'] = sanitize_text_field(stripslashes($post['messages']['insolvent'])); $new_settings['messages']['visitors'] = sanitize_text_field(stripslashes($post['messages']['visitors'])); // Let others play $new_settings = apply_filters('mycred_espresso_save_pref', $new_settings); // Save new settings $current = $this->prefs; $this->prefs = mycred_apply_defaults($current, $new_settings); update_option('mycred_espresso_gateway_prefs', $this->prefs); // Flag update $this->update = true; }
function mycred_admin_menu() { $mycred = mycred(); $name = mycred_label(true); global $mycred_types, $wp_version; $pages = array(); $slug = 'myCRED'; $menu_icon = 'dashicons-star-filled'; if (version_compare($wp_version, '3.8', '<')) { $menu_icon = ''; } foreach ($mycred_types as $type => $title) { $type_slug = 'myCRED'; if ($type != 'mycred_default') { $type_slug = 'myCRED_' . trim($type); } $pages[] = add_menu_page($title, $title, $mycred->edit_creds_cap(), $type_slug, '', $menu_icon); } $about_label = sprintf(__('About %s', 'mycred'), $name); $pages[] = add_dashboard_page($about_label, $about_label, 'moderate_comments', 'mycred', 'mycred_about_page'); $cred_label = __('Awesome People', 'mycred'); $pages[] = add_dashboard_page($cred_label, $cred_label, 'moderate_comments', 'mycred-credit', 'mycred_about_credit_page'); $pages = apply_filters('mycred_admin_pages', $pages, $mycred); foreach ($pages as $page) { add_action('admin_print_styles-' . $page, 'mycred_admin_page_styles'); } // Let others play do_action('mycred_add_menu', $mycred); }
/** * Construct Gateway * @since 1.3 * @version 1.0 */ function mycred_init_wpecom_construct_gateway() { if (!class_exists('wpsc_merchant')) { return; } global $nzshpcrt_gateways, $mycred_wpecom_settings; $mycred_wpecom_settings = shortcode_atts(array('log' => __('Payment for Order: #%order_id%', 'mycred'), 'type' => 'mycred_default', 'share' => 0, 'share_log' => __('Store sale', 'mycred'), 'rate' => 1, 'visitor' => __('You must be logged in to use this gateway', 'mycred'), 'low_funds' => __('Insufficient Funds.', 'mycred'), 'message' => __('Deduct the amount from your balance.', 'mycred')), (array) get_option('mycred_wpecom_settings', '')); // Add gateway $nzshpcrt_gateways[] = array('id' => 'mycred', 'name' => mycred_label(true), 'has_recurring_billing' => false, 'wp_admin_cannot_cancel' => false, 'requirements' => array('php_version' => '5.2.4'), 'form' => 'mycred_wpecom_gateway_settings', 'submit_function' => 'mycred_wpecom_gateway_settings_save', 'payment_type' => 'mycred', 'internalname' => 'mycred'); class myCRED_WP_E_Commerce_Gateway { public $core = ''; public $prefs = array(); public $mycred_type = 'mycred_default'; /** * Construct */ function __construct() { global $mycred_wpecom_settings; $this->prefs = $mycred_wpecom_settings; $type = 'mycred_default'; if (isset($mycred_wpecom_settings['type'])) { $type = $mycred_wpecom_settings['type']; } $this->core = mycred($type); $this->mycred_type = $type; add_action('wpsc_submit_checkout_gateway', array($this, 'process_gateway'), 1, 2); add_filter('wpsc_gateway_checkout_form_mycred', array($this, 'checkout_form')); add_filter('mycred_parse_log_entry_wpecom_payment', array($this, 'parse_template_tags'), 10, 2); } /** * Process Payment * @since 1.3 * @version 1.1 */ function process_gateway($gateway, $purchase_log) { if ($gateway != 'mycred') { return; } // Prep $log_id = $purchase_log->get('id'); // Load Gateway $merchant_instance = new wpsc_merchant_mycred($log_id, false, $this->prefs, $this->core, $this->mycred_type); $merchant_instance->construct_value_array(); // Validate $merchant_instance->validate($purchase_log); // Charge do_action_ref_array('wpsc_pre_submit_gateway', array(&$merchant_instance)); $merchant_instance->submit(); } /** * Checkout Form * @since 1.3 * @version 1.1 */ function checkout_form() { $output = ''; if (!is_user_logged_in()) { $output .= '<tr><td>' . $this->core->template_tags_general($this->prefs['visitor']) . '</td></tr>'; return $output; } $output .= '<tr><td><table width="100%"><thead><th class="cart-item">' . __('Item', 'mycred') . '</th><th class="cart-item-qt"></th><th class="cart-item-cost">' . $this->core->plural() . '</th></thead><tbody>'; $total = 0; while (wpsc_have_cart_items()) { wpsc_the_cart_item(); $price = wpsc_cart_item_price(false); if ($this->prefs['rate'] != 1) { $price = $this->prefs['rate'] * $price; } $total = $total + $price; } $output .= '<tr><td colspan="2">' . __('Total Cost', 'mycred') . '</td><td class="cart-item-cost">' . $this->core->format_creds($total) . '</td></tr>'; $balance = $this->core->get_users_cred(get_current_user_id(), $this->mycred_type); if ($balance < $total) { $highlight = ' style="color:red;"'; } else { $highlight = ''; } $output .= '<tr><td class="cart-item" colspan="2">' . __('Your current balance', 'mycred') . '</td><td class="cart-item-cost"' . $highlight . '>' . $this->core->format_creds($balance) . '</td></tr></tdody></table></tr>'; if (!empty($this->prefs['message'])) { $output .= '<tr><td>' . $this->core->template_tags_general($this->prefs['message']) . '</td></tr>'; } return apply_filters('mycred_wpecom_form', $output); } /** * Parse Custom Template Tags * @since 1.3 * @version 1.0 */ function parse_template_tags($content, $log_entry) { if (!empty($log_entry->data)) { $content = str_replace('%order_id%', $log_entry->data, $content); } else { $content = str_replace('%order_id%', 'missing', $content); } return $content; } } new myCRED_WP_E_Commerce_Gateway(); class wpsc_merchant_mycred extends wpsc_merchant { var $prefs = array(); var $core = ''; var $mycred_type = 'mycred_default'; var $cost = 0; var $transaction_id = ''; /** * Construct */ function __construct($purchase_id = NULL, $is_receiving = false, $prefs = NULL, $mycred = NULL, $type = 'mycred_default') { parent::__construct($purchase_id, $is_receiving); $this->prefs = $prefs; $this->core = $mycred; $this->mycred_type = $type; } /** * Validate * Checks to make sure the current user can use this gateway. * @since 1.3 * @version 1.1 */ function validate($purchase_log) { $error = false; $user_id = get_current_user_id(); // Get cost $cart_total = $this->cart_data['total_price']; if ($this->prefs['rate'] != 1) { $cart_total = $this->prefs['rate'] * $cart_total; } $cart_total = $this->core->number($cart_total); $this->cost = $cart_total; // User is not logged in if (!is_user_logged_in()) { $error = $this->core->template_tags_general($this->prefs['visitor']); } elseif ($this->core->exclude_user($user_id)) { $error = __('You can not use this gateway.', 'mycred'); } else { // Rate $balance = $this->core->get_users_cred($user_id, $this->mycred_type); if ($balance < $this->cost) { $error = $this->core->template_tags_general($this->prefs['low_funds']); } } // Let others decline a store order $decline = apply_filters('mycred_decline_store_purchase', $error, $purchase_log, $this); if ($decline !== false) { wpsc_delete_customer_meta('selected_gateway'); $this->set_error_message($decline); $purchase_log->delete($this->purchase_id); unset($_SESSION['WpscGatewayErrorMessage']); $this->return_to_checkout(); exit; } // Prep for payment $this->user_id = $user_id; $this->transaction_id = 'MYCRED' . $user_id . time(); } /** * Submit * Charges the user for the purchase and if profit sharing is enabled * each product owner. * @since 1.3 * @version 1.3 */ function submit() { // Since the wpsc_pre_submit_gateway action could change these values, we need to check if ($this->cost > 0 && $this->user_id != 0 && !empty($this->transaction_id)) { // Let other play before we start do_action_ref_array('mycred_wpecom_charg', array(&$this)); // Charge $this->core->add_creds('wpecom_payment', $this->user_id, 0 - $this->cost, $this->prefs['log'], '', $this->purchase_id, $this->mycred_type); // Update Order $this->set_transaction_details($this->transaction_id, 3); transaction_results($this->cart_data['session_id'], false); // Payout Share if ($this->prefs['share'] > 0) { // Loop though items foreach ((array) $this->cart_items as $item) { // Get product $product = get_post((int) $item['product_id']); // Continue if product has just been deleted or owner is buyer if ($product === NULL || $product->post_author == $this->user_id) { continue; } // Calculate Cost $price = $item['price']; $quantity = $item['quantity']; $cost = $price * $quantity; // Calculate Share $percentage = apply_filters('mycred_wpecom_profit_share', $this->prefs['share'], $this, $product); if ($percentage == 0) { continue; } $share = $percentage / 100 * $cost; // Payout $this->core->add_creds('store_sale', $product->post_author, $share, $this->prefs['share_log'], $product->ID, array('ref_type' => 'post'), $this->mycred_type); } } // Let others play before we end do_action_ref_array('mycred_wpecom_charged', array(&$this)); // Empty Cart, Redirect & Exit wpsc_empty_cart(); $this->go_to_transaction_results($this->cart_data['session_id']); exit; } elseif (!empty($this->transaction_id)) { $this->set_transaction_details($this->transaction_id, 2); } } } }
/** * myCRED Credit Page * @since 1.3.2 * @version 1.0 */ function mycred_about_credit_page() { $name = mycred_label(); ?> <div class="wrap about-wrap" id="mycred-credit-wrap"> <h1>Awesome People</h1> <?php mycred_about_header($name); ?> <div class="changelog"> <h3>myCRED Users</h3> <div class="feature-section col two-col"> <div> <h4>Bug Finders</h4> <p>Users who have taken the time to report bugs helping me improve this plugin.</p> <ul> <li><a href="http://mycred.me/community/jommy99/">John Moore</a></li> <li><a href="http://mycred.me/community/keisermedia/">Lucas Keiser</a></li> <li><a href="http://mycred.me/community/lionelbernard/">Siargao</a></li> <li><a href="http://mycred.me/community/woekerzee/">woekerzee</a></li> <li><a href="http://mycred.me/community/jmaubert75/">JM AUBERT</a></li> <li><a href="http://mycred.me/community/NUHISON/">David J</a></li> <li><a href="http://mycred.me/community/shmoo/">Shmoo</a></li> </ul> </div> <div class="last-feature"> <h4>Plugin Translators</h4> <p>Users who have helped with translating this plugin.</p> <ul> <li><a href="http://bp-fr.net/">Dan</a> <em>( French )</em></li> <li><a href="http://mycred.me/members/maniv-a/">Mani Akhtar</a> <em>( Persian )</em></li> <li><a href="http://www.merovingi.com/">Gabriel S Merovingi</a> <em>( Swedish )</em></li> <li><a href="http://robertrowshan.com/">Rob Row</a> <em>( Spanish )</em></li> <li>Skladchik <em>( Russian )</em></li> <lo>Guilherme <em>( Portuguese - Brazil )</em></li> </ul> </div> </div> <h3>Find out more</h3> <p>You can always find more information about this plugin on the <strong>my</strong>CRED <a href="http://mycred.me/">website</a>.</p> </div> <?php mycred_about_footer(); ?> </div> <?php }
/** * myCRED Credit Page * @since 1.3.2 * @version 1.6.3 */ function mycred_about_credit_page() { $name = mycred_label(); ?> <div class="wrap about-wrap" id="mycred-credit-wrap"> <h1>Awesome People</h1> <?php mycred_about_header($name); ?> <div class="changelog"> <h3>myCRED Users</h3> <div class="feature-section col two-col"> <div> <h4>Bug Finders</h4> <p>Users who have taken the time to report bugs. A big thank you to all.</p> <ul> <li><a href="http://mycred.me/community/innergy4every1/">innergy4every1</a></li> <li><a href="http://mycred.me/community/kristoff/">Kristoff</a></li> <li><a href="http://mycred.me/community/colson/">colson</a></li> <li><a href="http://mycred.me/community/Martin/">Martin</a></li> <li><a href="http://mycred.me/community/orousal/">Orousal</a></li> <li><a href="http://mycred.me/community/joseph/">Joseph</a></li> <li>Maria Campbell</li> </ul> </div> <div class="last-feature"> <h4>Plugin Translators</h4> <p>Users who have helped with translating this plugin.</p> <ul> <li><a href="http://bp-fr.net/">Dan</a> <em>( French )</em></li> <li><a href="http://mycred.me/members/maniv-a/">Mani Akhtar</a> <em>( Persian )</em></li> <li><a href="http://www.merovingi.com/">Gabriel S Merovingi</a> <em>( Swedish )</em></li> <li><a href="http://robertrowshan.com/">Robert Rowshan</a> <em>( Spanish )</em></li> <li>Skladchik <em>( Russian )</em></li> <li>Guilherme <em>( Portuguese - Brazil )</em></li> <li><a href="http://coolwp.com">suifengtec</a> <em>( Chinese )</em></li> </ul> <p>Remember that translators are rewarded with <strong>my</strong>CRED tokens for their help. Tokens can be used in the myCRED store to pay for premium add-ons.</p> </div> </div> <h3>Find out more</h3> <p>You can always find more information about this plugin on the <strong>my</strong>CRED <a href="http://mycred.me/">website</a>.</p> </div> <?php mycred_about_footer(); ?> </div> <?php }
/** * Construct */ public function __construct() { $name = mycred_label(true); parent::__construct('mycred_widget_wallet', sprintf(__('(%s) Wallet', 'mycred'), $name), array('classname' => 'widget-my-wallet', 'description' => __('Shows the current users balances for each point type.', 'mycred'))); }
/** * Admin Page * @since 0.1 * @version 1.1 */ public function admin_page() { // Security if (!$this->core->can_edit_creds()) { wp_die(__('Access Denied', 'mycred')); } // Get installed $installed = $this->get(true); ?> <div class="wrap" id="myCRED-wrap"> <h2><?php echo sprintf(__('%s Banking', 'mycred'), mycred_label()); ?> </h2> <?php $this->update_notice(); ?> <p><?php echo $this->core->template_tags_general(__('Your banking setup for %plural%.', 'mycred')); ?> </p> <?php if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) { ?> <p><strong><?php _e('WP-Cron deactivation detected!', 'mycred'); ?> </strong></p> <p><?php _e('Warning! This add-on requires WP - Cron to work.', 'mycred'); ?> </p> <?php } ?> <form method="post" action="options.php"> <?php settings_fields($this->settings_name); ?> <!-- Loop though Services --> <div class="list-items expandable-li" id="accordion"> <?php // Installed Services if (!empty($installed)) { foreach ($installed as $key => $data) { ?> <h4><div class="gate-icon <?php if ($this->is_active($key)) { echo 'active'; } else { echo 'inactive'; } ?> "></div><?php echo $this->core->template_tags_general($data['title']); ?> </h4> <div class="body" style="display:none;"> <p><?php echo nl2br($this->core->template_tags_general($data['description'])); ?> </p> <label class="subheader"><?php _e('Enable', 'mycred'); ?> </label> <ol> <li> <input type="checkbox" name="<?php echo $this->option_id; ?> [active][]" id="mycred-bank-service-<?php echo $key; ?> " value="<?php echo $key; ?> "<?php if ($this->is_active($key)) { echo ' checked="checked"'; } ?> /> </li> </ol> <?php echo $this->call('preferences', $data['callback']); ?> </div> <?php } } ?> </div> <?php submit_button(__('Update Changes', 'mycred'), 'primary large', 'submit', false); ?> </form> </div> <?php }
/** * Network Settings Page * @since 0.1 * @version 1.1 */ public function admin_page_settings() { // Security if (!current_user_can('manage_network_options')) { wp_die(__('Access Denied', 'mycred')); } global $mycred_network; $prefs = mycred_get_settings_network(); $name = mycred_label(); ?> <div class="wrap" id="myCRED-wrap"> <div id="icon-myCRED" class="icon32"><br /></div> <h2> <?php echo sprintf(__('%s Network', 'mycred'), $name); ?> </h2> <?php // Inform user that myCRED has not yet been setup $setup = get_blog_option(1, 'mycred_setup_completed', false); if ($setup === false) { echo '<div class="error"><p>' . sprintf(__('Note! %s has not yet been setup.', 'mycred'), $name) . '</p></div>'; } // Settings Updated if (isset($_GET['settings-updated'])) { echo '<div class="updated"><p>' . __('Network Settings Updated', 'mycred') . '</p></div>'; } ?> <p><?php echo sprintf(__('Configure network settings for %s.', 'mycred'), $name); ?> </p> <form method="post" action="<?php echo admin_url('options.php'); ?> " class=""> <?php settings_fields('mycred_network'); ?> <div class="list-items expandable-li" id="accordion"> <h4><div class="icon icon-inactive core"></div><?php _e('Settings', 'mycred'); ?> </h4> <div class="body" style="display:block;"> <label class="subheader"><?php _e('Master Template', 'mycred'); ?> </label> <ol id="myCRED-network-settings-enabling"> <li> <input type="radio" name="mycred_network[master]" id="myCRED-network-overwrite-enabled" <?php checked($prefs['master'], 1); ?> value="1" /> <label for="myCRED-network-"><?php _e('Yes', 'mycred'); ?> </label> </li> <li> <input type="radio" name="mycred_network[master]" id="myCRED-network-overwrite-disabled" <?php checked($prefs['master'], 0); ?> value="0" /> <label for="myCRED-network-"><?php _e('No', 'mycred'); ?> </label> </li> <li> <p class="description"><?php echo sprintf(__("If enabled, %s will use your main site's settings for all other sites in your network.", 'mycred'), $name); ?> </p> </li> </ol> <label class="subheader"><?php _e('Central Logging', 'mycred'); ?> </label> <ol id="myCRED-network-log-enabling"> <li> <input type="radio" name="mycred_network[central]" id="myCRED-network-overwrite-log-enabled" <?php checked($prefs['central'], 1); ?> value="1" /> <label for="myCRED-network-"><?php _e('Yes', 'mycred'); ?> </label> </li> <li> <input type="radio" name="mycred_network[central]" id="myCRED-network-overwrite-log-disabled" <?php checked($prefs['central'], 0); ?> value="0" /> <label for="myCRED-network-"><?php _e('No', 'mycred'); ?> </label> </li> <li> <p class="description"><?php echo sprintf(__("If enabled, %s will log all site actions in your main site's log.", 'mycred'), $name); ?> </p> </li> </ol> <label class="subheader"><?php _e('Site Block', 'mycred'); ?> </label> <ol id="myCRED-network-site-blocks"> <li> <div class="h2"><input type="text" name="mycred_network[block]" id="myCRED-network-block" value="<?php echo $prefs['block']; ?> " class="long" /></div> <span class="description"><?php echo sprintf(__('Comma separated list of blog ids where %s is to be disabled.', 'mycred'), $name); ?> </span> </li> </ol> <?php do_action('mycred_network_prefs', $this); ?> </div> <?php do_action('mycred_after_network_prefs', $this); ?> </div> <p><?php submit_button(__('Save Network Settings', 'mycred'), 'primary large', 'submit', false); ?> </p> </form> <?php do_action('mycred_bottom_network_page', $this); ?> </div> <?php }
/** * Admin Page * @since 0.1 * @version 1.2 */ public function admin_page() { // Security if (!$this->core->can_edit_creds()) { wp_die(__('Access Denied', 'mycred')); } $save = false; if (empty($this->installed) || isset($_GET['reload-addons']) && $_GET['reload-addons'] == 1) { $save = true; } $installed = $this->get($save); ?> <div class="wrap" id="myCRED-wrap"> <h2><?php echo sprintf(__('%s Add-ons', 'mycred'), mycred_label()); ?> </h2> <?php // Messages if (isset($_GET['addon_action'])) { if ($_GET['addon_action'] == 'activate') { echo '<div id="message" class="updated"><p>' . __('Add-on Activated', 'mycred') . '</p></div>'; } elseif ($_GET['addon_action'] == 'deactivate') { echo '<div id="message" class="error"><p>' . __('Add-on Deactivated', 'mycred') . '</p></div>'; } } elseif (isset($_GET['reload-addons']) && $_GET['reload-addons'] == 1) { echo '<div id="message" class="updated"><p>' . __('Add-ons Reloaded', 'mycred') . '</p></div>'; } ?> <p><?php _e('Add-ons can expand your current installation with further features.', 'mycred'); ?> </p> <div class="list-items expandable-li" id="accordion"> <?php // Loop though installed if (!empty($installed)) { foreach ($installed as $key => $data) { ?> <h4><div class="icon icon-<?php if ($this->is_active($key)) { echo 'active'; } else { echo 'inactive'; } echo ' ' . $key; ?> "></div><label><?php _e($this->core->template_tags_general($data['name']), 'mycred'); ?> </label></h4> <div class="body" style="display:none;"> <div class="wrapper"> <div class="description h2"><?php _e($this->core->template_tags_general($data['description']), 'mycred'); ?> </div> <p class="links"><?php echo $this->addon_links($data); ?> </p> <p><?php echo $this->activate_deactivate($key); ?> </p> <div class="clear"> </div> </div> </div> <?php } } ?> </div> <p><a href="<?php echo admin_url('admin.php?page=' . $_GET['page'] . '&reload-addons=1'); ?> " class="button button-secondary"><?php _e('Reload Add-ons', 'mycred'); ?> </a></p> <p style="text-align:right;"><?php echo sprintf(__('You can find more add-ons in our %s.', 'mycred'), sprintf('<a href="http://mycred.me/store/" target="_blank">%s</a>', __('online store', 'mycred'))); ?> </p> </div> <?php }
/** * Edit Profile Screen * @since 1.5 * @version 1.0.2 */ public function edit_profile_screen() { if (!isset($_GET['user_id'])) { return; } $user_id = absint($_GET['user_id']); if (!isset($_GET['ctype'])) { $type = 'mycred_default'; } else { $type = sanitize_text_field($_GET['ctype']); } $mycred = mycred($type); // Security if (!$mycred->can_edit_creds()) { wp_die(__('Access Denied', 'mycred')); } // User is excluded if ($mycred->exclude_user($user_id)) { wp_die(sprintf(__('This user is excluded from using %s', 'mycred'), mycred_label())); } $user = get_userdata($user_id); $balance = $mycred->get_users_balance($user_id); if ($type == 'mycred_default') { $log_slug = 'myCRED'; } else { $log_slug = 'myCRED_' . $type; } $history_url = add_query_arg(array('page' => $log_slug, 'user_id' => $user->ID), admin_url('admin.php')); $exclude_url = add_query_arg(array('action' => 'exclude')); ?> <style type="text/css"> div#edit-balance-page table.table { width: 100%; margin-top: 24px; } div#edit-balance-page table.table th { text-align: left; } div#edit-balance-page table.table td { width: 33%; font-size: 24px; line-height: 48px; } div#edit-balance-page table tr td table tr td { vertical-align: top; } div#edit-balance-page table.form-table { border-top: 1px solid #ccc; } div#edit-balance-page.wrap form#your-profile h3 { margin-top: 3em; } </style> <div class="wrap" id="edit-balance-page"> <h2><?php _e('Edit User', 'mycred'); if (current_user_can('create_users')) { ?> <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'user', 'mycred'); ?> </a> <?php } elseif (is_multisite() && current_user_can('promote_users')) { ?> <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x('Add Existing', 'user', 'mycred'); ?> </a> <?php } ?> </h2> <form id="your-profile" action="" method="post"> <?php echo $this->user_nav($user, $type); ?> <div class="clear clearfix"></div> <table class="table"> <thead> <tr> <th><?php _e('Current Balance', 'mycred'); ?> </th> <th><?php printf(__('Total %s Accumulated', 'mycred'), $mycred->plural()); ?> </th> <th><?php printf(__('Total %s Spent', 'mycred'), $mycred->plural()); ?> </th> </tr> </thead> <tbody> <tr> <td><?php echo $mycred->format_creds($balance); ?> </td> <td><?php echo $mycred->format_creds(mycred_get_users_total($user->ID, $type)); ?> </td> <td><?php echo $mycred->format_creds($this->get_users_total_spent($user->ID, $type)); ?> </td> </tr> </tbody> </table> <a href="<?php echo esc_url($history_url); ?> " class="button button-secondary"><?php _e('View History', 'mycred'); ?> </a> <a href="<?php echo esc_url($exclude_url); ?> " class="button button-primary" id="mycred-exclude-this-user"><?php _e('Exclude User', 'mycred'); ?> </a> <?php do_action('mycred_before_edit_profile', $user, $type); ?> <h3><?php _e('Adjust Balance', 'mycred'); ?> </h3> <?php $this->adjust_users_balance($user); ?> <?php do_action('mycred_edit_profile', $user, $type); ?> </form> <script type="text/javascript"> jQuery(function($) { $( 'a#mycred-exclude-this-user' ).click(function(){ if ( ! confirm( '<?php echo esc_js(esc_attr__('Warning! Excluding this user will result in their balance being deleted along with any entries currently in your log! This can not be undone!', 'mycred')); ?> ' ) ) return false; }); }); </script> </div> <?php }
function mycred_woo_add_product_metabox() { add_meta_box('mycred_woo_sales_setup', mycred_label(), 'mycred_woo_product_metabox', 'product', 'side', 'high'); }
/** * Construct */ function myCRED_Widget_Wallet() { // Basic details about our widget $widget_ops = array('classname' => 'widget-my-wallet', 'description' => __('Shows the current users balances for each point type.', 'mycred')); $this->WP_Widget('mycred_widget_wallet', sprintf(__('(%s) Wallet', 'mycred'), mycred_label(true)), $widget_ops); $this->alt_option_name = 'mycred_widget_wallet'; }
function mycred_get_types() { $types = array(); $available_types = mycred_get_option('mycred_types', array('mycred_default' => mycred_label())); if (count($available_types) > 1) { foreach ($available_types as $type => $label) { if ($type == 'mycred_default') { $_mycred = mycred($type); $label = $_mycred->plural(); } $types[$type] = $label; } } else { $types = $available_types; } return apply_filters('mycred_types', $types); }
/** * Construct */ public function __construct() { $name = mycred_label(true); parent::__construct('mycred_widget_transfer', sprintf(__('(%s) Transfer', 'mycred'), $name), array('classname' => 'widget-my-cred-transfer', 'description' => __('Allow transfers between users.', 'mycred'))); }
if (!class_exists('WP_Importer')) { $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; if (file_exists($class_wp_importer)) { require $class_wp_importer; } } require_once myCRED_INCLUDES_DIR . 'importers/mycred-balances.php'; $importer = new myCRED_Importer_Balances(); $importer->load(); } /** * Register Importer: CubePoints * @since 1.4 * @version 1.0 */ register_importer('mycred_import_cp', sprintf(__('%s CubePoints Import', 'mycred'), mycred_label()), __('Import CubePoints log entries and / or balances.', 'mycred'), 'mycred_importer_cubepoints'); /** * Load Importer: CubePoints * @since 1.4 * @version 1.0 */ function mycred_importer_cubepoints() { require_once ABSPATH . 'wp-admin/includes/import.php'; global $wpdb; // No use continuing if there is no log to import if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s;", $wpdb->prefix . 'cp')) == 0) { echo '<p>' . __('No CubePoints log exists.', 'mycred') . '</p>'; return; } if (!class_exists('WP_Importer')) {
/** * Admin Page * @since 0.1 * @version 1.1 */ public function admin_page() { // Security if (!$this->core->can_edit_creds()) { wp_die(__('Access Denied', 'mycred')); } // Get installed $installed = $this->get(); ?> <div class="wrap" id="myCRED-wrap"> <h2><?php echo sprintf(__('%s Hooks', 'mycred'), mycred_label()); ?> </h2> <?php $this->update_notice(); ?> <p><?php echo $this->core->template_tags_general(__('Hooks are instances where %_plural% are awarded or deducted from a user, depending on their actions around your website.', 'mycred')); ?> </p> <form method="post" action="options.php" name="mycred-hooks-setup-form" novalidate> <?php settings_fields($this->settings_name); ?> <!-- Loop though Hooks --> <div class="list-items expandable-li" id="accordion"> <?php // If we have hooks if (!empty($installed)) { // Loop though them foreach ($installed as $key => $data) { ?> <h4><div class="icon icon-<?php if ($this->is_active($key)) { echo 'active'; } else { echo 'inactive'; } echo ' ' . $key; ?> "></div><label><?php echo $this->core->template_tags_general($data['title']); ?> </label></h4> <div class="body" style="display:none;"> <p><?php echo nl2br($this->core->template_tags_general($data['description'])); ?> </p> <label class="subheader"><?php _e('Enable', 'mycred'); ?> </label> <ol> <li> <input type="checkbox" name="<?php echo $this->option_id; ?> [active][]" id="mycred-hook-<?php echo $key; ?> " value="<?php echo $key; ?> "<?php if ($this->is_active($key)) { echo ' checked="checked"'; } ?> /> </li> </ol> <?php echo $this->call('preferences', $data['callback']); ?> </div> <?php } } ?> </div> <?php submit_button(__('Update Changes', 'mycred'), 'primary large', 'submit', false); ?> </form> </div> <script type="text/javascript"> jQuery(function($) { $( 'select.limit-toggle' ).change(function(){ if ( $(this).find( ':selected' ).val() != 'x' ) $(this).prev().attr( 'type', 'text' ).val( 0 ); else $(this).prev().attr( 'type', 'hidden' ).val( 0 ); }); }); </script> <?php }
function mycred_get_types($name_first = false) { $types = array(); $available_types = mycred_get_option('mycred_types', array('mycred_default' => mycred_label())); if (count($available_types) > 1) { foreach ($available_types as $type => $label) { if ($type == 'mycred_default') { $label = mycred_get_point_type_name(false); } $types[$type] = $label; } } else { if ($name_first) { $available_types['mycred_default'] = mycred_get_point_type_name(false); } $types = $available_types; } return apply_filters('mycred_types', $types); }