예제 #1
0
 /**
  * Construct
  */
 function __construct($args = array(), $hook_prefs = NULL, $type = 'mycred_default')
 {
     if (!empty($args)) {
         foreach ($args as $key => $value) {
             $this->{$key} = $value;
         }
     }
     // Grab myCRED Settings
     $this->core = mycred($type);
     if (!empty($type)) {
         $this->core->cred_id = sanitize_text_field($type);
         $this->mycred_type = $this->core->cred_id;
     }
     if ($this->mycred_type != 'mycred_default') {
         $this->is_main_type = false;
     }
     // Grab settings
     if ($hook_prefs !== NULL) {
         // Assign prefs if set
         if (isset($hook_prefs[$this->id])) {
             $this->prefs = $hook_prefs[$this->id];
         }
         // Defaults must be set
         if (!isset($this->defaults)) {
             $this->defaults = array();
         }
     }
     // Apply default settings if needed
     if (!empty($this->defaults)) {
         $this->prefs = mycred_apply_defaults($this->defaults, $this->prefs);
     }
 }
 /**
  * Construct
  */
 function __construct($args = array(), $gateway_prefs = NULL)
 {
     // Make sure gateway prefs is set
     if ($gateway_prefs === NULL) {
         return;
     }
     // Current User ID
     $this->current_user_id = get_current_user_id();
     // Arguments
     if (!empty($args)) {
         foreach ($args as $key => $value) {
             $this->{$key} = $value;
         }
     }
     // Preferences
     if (is_array($gateway_prefs) && isset($gateway_prefs[$this->id])) {
         $this->prefs = mycred_apply_defaults($this->defaults, $gateway_prefs[$this->id]);
     } elseif (is_object($gateway_prefs) && isset($gateway_prefs->gateway_prefs[$this->id])) {
         $this->prefs = mycred_apply_defaults($this->defaults, $gateway_prefs->gateway_prefs[$this->id]);
     } else {
         $this->prefs = $this->defaults;
     }
     // Load myCRED
     if (isset($gateway_prefs->core)) {
         $mycred = $gateway_prefs->core;
     } else {
         $mycred = mycred();
     }
     if (isset($mycred->buy_creds['type'])) {
         $this->mycred_type = $mycred->buy_creds['type'];
     } else {
         $this->mycred_type = $mycred->cred_id;
     }
     if ($this->mycred_type != 'mycred_default') {
         $this->core = new myCRED_Settings($this->mycred_type);
     } else {
         $this->core = $mycred;
     }
     // Sandbox Mode
     if (isset($this->prefs['sandbox'])) {
         $this->sandbox_mode = (bool) $this->prefs['sandbox'];
     }
     if (isset($this->defaults['gateway_logo_url'])) {
         $this->gateway_logo_url = $this->defaults['gateway_logo_url'];
     }
     // Decode Log Entries
     add_filter('mycred_prep_template_tags', array($this, 'decode_log_entries'), 10, 2);
     add_filter('mycred_parse_log_entry_buy_creds_with_' . $this->id, array($this, 'log_entry'), 10, 2);
 }
예제 #3
0
 function mycred_get_exchange_rates($point_type = '')
 {
     $types = mycred_get_types();
     $default = array();
     foreach ($types as $type => $label) {
         if ($type == $point_type) {
             continue;
         }
         $default[$type] = 0;
     }
     $settings = mycred_get_option('mycred_pref_exchange_' . $point_type, $default);
     $settings = mycred_apply_defaults($default, $settings);
     return $settings;
 }
 /**
  * Set Settings
  * @since 0.1
  * @version 1.2
  */
 function set_settings()
 {
     $module = $this->module_name;
     // Reqest not to register any settings
     if ($this->register === false) {
         // If settings does not exist apply defaults
         if (!isset($this->core->{$module})) {
             $this->{$module} = $this->default_prefs;
         } else {
             $this->{$module} = $this->core->{$module};
         }
         // Apply defaults in case new settings have been applied
         if (!empty($defaults)) {
             $this->{$module} = mycred_apply_defaults($this->default_prefs, $this->{$module});
         }
     } else {
         // Option IDs must be provided
         if (!empty($this->option_id)) {
             // Array = more then one
             if (is_array($this->option_id)) {
                 // General settings needs not to be loaded
                 $pattern = 'mycred_pref_core';
                 //$matches = array_filter( $this->option_id, function( $a ) use ( $pattern ) { return preg_grep( $a, $pattern ); } );
                 //if ( ! empty( $matches ) )
                 $this->{$module} = $this->core;
                 // Loop and grab
                 foreach ($this->option_id as $option_id => $option_name) {
                     $settings = mycred_get_option($option_name, false);
                     if ($settings === false && array_key_exists($option_id, $defaults)) {
                         $this->{$module}[$option_name] = $this->default_prefs[$option_id];
                     } else {
                         $this->{$module}[$option_name] = $settings;
                     }
                     // Apply defaults in case new settings have been applied
                     if (array_key_exists($option_id, $defaults)) {
                         $this->{$module}[$option_name] = mycred_apply_defaults($this->default_prefs[$option_id], $this->{$module}[$option_name]);
                     }
                 }
             } else {
                 // General settings needs not to be loaded
                 if (str_replace('mycred_pref_core', '', $this->option_id) == '') {
                     $this->{$module} = $this->core;
                 } else {
                     $this->{$module} = mycred_get_option($this->option_id, false);
                     if ($this->{$module} === false && !empty($this->default_prefs)) {
                         $this->{$module} = $this->default_prefs;
                     }
                     // Apply defaults in case new settings have been applied
                     if (!empty($this->default_prefs)) {
                         $this->{$module} = mycred_apply_defaults($this->default_prefs, $this->{$module});
                     }
                 }
             }
             if (is_array($this->{$module})) {
                 foreach ($this->{$module} as $key => $value) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
 }
 /**
  * Get Email Settings
  * @since 1.1
  * @version 1.1
  */
 public function get_email_settings($post_id)
 {
     $settings = get_post_meta($post_id, 'mycred_email_settings', true);
     if ($settings == '') {
         $settings = array();
     }
     // Defaults
     $default = array('recipient' => 'user', 'senders_name' => $this->emailnotices['from']['name'], 'senders_email' => $this->emailnotices['from']['email'], 'reply_to' => $this->emailnotices['from']['reply_to'], 'label' => '');
     $settings = mycred_apply_defaults($default, $settings);
     return apply_filters('mycred_email_notice_settings', $settings, $post_id);
 }
예제 #6
0
 /**
  * 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_update_users_transfer_history($user_id, $history, $type = 'mycred_default', $key = NULL)
 {
     if ($key === NULL) {
         $key = 'mycred_transactions';
     }
     if ($type != 'mycred_default' && $type != '') {
         $key .= '_' . $type;
     }
     // Get current history
     $current = mycred_get_users_transfer_history($user_id, $type, $key);
     // Reset
     if ($history === true) {
         $new_history = array('frame' => '', 'amount' => 0);
     } else {
         $new_history = mycred_apply_defaults($current, $history);
     }
     mycred_update_user_meta($user_id, $key, '', $new_history);
 }
 /**
  * Update Getway Settings
  * @since 1.3
  * @version 1.2
  */
 function update()
 {
     parent::update();
     if (!isset($_POST['mycred_gateway']) || !is_array($_POST['mycred_gateway'])) {
         return;
     }
     // Prep
     $data = $_POST['mycred_gateway'];
     $new_settings = array();
     // Setup
     $new_settings['setup'] = $data['setup'];
     $new_settings['type'] = sanitize_text_field($data['type']);
     $new_settings['refund'] = abs($data['refund']);
     $new_settings['share'] = abs($data['share']);
     // Logs
     $new_settings['log']['purchase'] = trim(stripslashes($data['log']['purchase']));
     $new_settings['log']['refund'] = trim(stripslashes($data['log']['refund']));
     if ($new_settings['setup'] == 'multi') {
         $new_settings['rate'] = sanitize_text_field($data['rate']);
     } else {
         $new_settings['rate'] = $this->prefs['rate'];
     }
     // Override Pricing Options
     if ($new_settings['setup'] == 'single') {
         update_option('dbem_bookings_currency_decimal_point', $this->core->format['separators']['decimal']);
         update_option('dbem_bookings_currency_thousands_sep', $this->core->format['separators']['thousand']);
         update_option('dbem_bookings_currency', 'XMY');
         if (empty($this->core->before) && !empty($this->core->after)) {
             $format = '@ #';
         } elseif (!empty($this->core->before) && empty($this->core->after)) {
             $format = '# @';
         }
         update_option('dbem_bookings_currency_format', $format);
     }
     // Labels
     $new_settings['labels']['link'] = sanitize_text_field(stripslashes($data['labels']['link']));
     $new_settings['labels']['header'] = sanitize_text_field(stripslashes($data['labels']['header']));
     $new_settings['labels']['button'] = sanitize_text_field(stripslashes($data['labels']['button']));
     $new_settings['labels']['checkout'] = sanitize_text_field(stripslashes($data['labels']['checkout']));
     // Messages
     $new_settings['messages']['success'] = sanitize_text_field(stripslashes($data['messages']['success']));
     $new_settings['messages']['error'] = sanitize_text_field(stripslashes($data['messages']['error']));
     // Save Settings
     $current = $this->prefs;
     $this->prefs = mycred_apply_defaults($current, $new_settings);
     update_option('mycred_eventsmanager_gateway_prefs', $this->prefs);
     // Let others play
     do_action('mycred_em_save_settings', $this);
     //default action is to return true
     return true;
 }
        /**
         * Add to General Settings
         * @since 1.4
         * @version 1.0
         */
        public function after_general_settings()
        {
            if (!isset($this->coupons)) {
                $prefs = $this->default_prefs;
            } else {
                $prefs = mycred_apply_defaults($this->default_prefs, $this->coupons);
            }
            ?>

<h4><div class="icon icon-active"></div><?php 
            _e('Coupons', 'mycred');
            ?>
</h4>
<div class="body" style="display:none;">
	<label class="subheader" for="<?php 
            echo $this->field_id('log');
            ?>
"><?php 
            _e('Log Template', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('log');
            ?>
" id="<?php 
            echo $this->field_id('log');
            ?>
" value="<?php 
            echo $prefs['log'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Log entry for successful coupon redemption. Use %coupon% to show the coupon code.', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('invalid');
            ?>
"><?php 
            _e('Invalid Coupon Message', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('invalid');
            ?>
" id="<?php 
            echo $this->field_id('invalid');
            ?>
" value="<?php 
            echo $prefs['invalid'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when users try to use a coupon that does not exists.', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('expired');
            ?>
"><?php 
            _e('Expired Coupon Message', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('expired');
            ?>
" id="<?php 
            echo $this->field_id('expired');
            ?>
" value="<?php 
            echo $prefs['expired'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when users try to use that has expired.', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('user_limit');
            ?>
"><?php 
            _e('User Limit Message', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('user_limit');
            ?>
" id="<?php 
            echo $this->field_id('user_limit');
            ?>
" value="<?php 
            echo $prefs['user_limit'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when the user limit has been reached for the coupon.', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('min');
            ?>
"><?php 
            _e('Minimum Balance Message', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('min');
            ?>
" id="<?php 
            echo $this->field_id('min');
            ?>
" value="<?php 
            echo $prefs['min'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when a user does not meet the minimum balance requirement. (if used)', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('max');
            ?>
"><?php 
            _e('Maximum Balance Message', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('max');
            ?>
" id="<?php 
            echo $this->field_id('max');
            ?>
" value="<?php 
            echo $prefs['max'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when a user does not meet the maximum balance requirement. (if used)', 'mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('success');
            ?>
"><?php 
            _e('Success Message', 'mycred');
            ?>
</label>
	<ol id="myCRED-coupon-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('success');
            ?>
" id="<?php 
            echo $this->field_id('success');
            ?>
" value="<?php 
            echo $prefs['success'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when a coupon was successfully deposited to a users account.', 'mycred');
            ?>
</span>
		</li>
	</ol>
</div>
<?php 
        }
예제 #10
0
파일: mycred-log.php 프로젝트: nfer/mycred
 /**
  * Construct
  */
 public function __construct($args = array(), $array = false)
 {
     if (empty($args)) {
         return false;
     }
     global $wpdb;
     $select = $where = $sortby = $limits = '';
     $prep = $wheres = array();
     // Load General Settings
     if (isset($args['ctype'])) {
         $type = $args['ctype'];
     } else {
         $type = 'mycred_default';
     }
     $this->core = mycred($type);
     if ($this->core->format['decimals'] > 0) {
         $format = '%f';
     } else {
         $format = '%d';
     }
     // Prep Defaults
     $defaults = array('user_id' => NULL, 'ctype' => 'mycred_default', 'number' => 25, 'time' => NULL, 'ref' => NULL, 'ref_id' => NULL, 'amount' => NULL, 's' => NULL, 'data' => NULL, 'orderby' => 'time', 'offset' => '', 'order' => 'DESC', 'ids' => false, 'cache' => '', 'paged' => $this->get_pagenum());
     $this->args = mycred_apply_defaults($defaults, $args);
     // Difference between default and given args
     $this->diff = array_diff_assoc($this->args, $defaults);
     if (isset($this->diff['number'])) {
         unset($this->diff['number']);
     }
     $data = false;
     if ($this->args['cache'] != '') {
         $cache_id = substr($this->args['cache'], 0, 23);
         if (is_multisite()) {
             $data = get_site_transient('mycred_log_query_' . $cache_id);
         } else {
             $data = get_transient('mycred_log_query_' . $cache_id);
         }
     }
     if ($data === false) {
         // Type
         $wheres[] = 'ctype = %s';
         $prep[] = $this->args['ctype'];
         // User ID
         if ($this->args['user_id'] !== NULL && $this->args['user_id'] != '') {
             $wheres[] = 'user_id = %d';
             $prep[] = abs($this->args['user_id']);
         }
         // Reference
         if ($this->args['ref'] !== NULL && $this->args['ref'] != '') {
             $refs = explode(',', $this->args['ref']);
             $ref_count = count($refs);
             if ($ref_count > 1) {
                 $ref_count = $ref_count - 1;
                 $wheres[] = 'ref IN (%s' . str_repeat(',%s', $ref_count) . ')';
                 foreach ($refs as $ref) {
                     $prep[] = sanitize_text_field($ref);
                 }
             } else {
                 $wheres[] = 'ref = %s';
                 $prep[] = sanitize_text_field($refs[0]);
             }
         }
         // Reference ID
         if ($this->args['ref_id'] !== NULL && $this->args['ref_id'] != '') {
             $ref_ids = explode(',', $this->args['ref_id']);
             if (count($ref_ids) > 1) {
                 $ref_id_count = count($ref_ids) - 1;
                 $wheres[] = 'ref_id IN (%d' . str_repeat(',%d', $ref_id_count) . ')';
                 foreach ($ref_ids as $ref_id) {
                     $prep[] = (int) sanitize_text_field($ref_id);
                 }
             } else {
                 $wheres[] = 'ref_id = %d';
                 $prep[] = (int) sanitize_text_field($ref_ids[0]);
             }
         }
         // Amount
         if ($this->args['amount'] !== NULL && $this->args['amount'] != '') {
             // Advanced query
             if (is_array($this->args['amount'])) {
                 // Range
                 if (isset($this->args['amount']['start']) && isset($this->args['amount']['end'])) {
                     $wheres[] = 'creds BETWEEN ' . $format . ' AND ' . $format;
                     $prep[] = $this->core->number(sanitize_text_field($this->args['amount']['start']));
                     $prep[] = $this->core->number(sanitize_text_field($this->args['amount']['end']));
                 } elseif (isset($this->args['amount']['num']) && isset($this->args['amount']['compare'])) {
                     $compare = urldecode($this->args['amount']['compare']);
                     $wheres[] = 'creds ' . trim($compare) . ' ' . $format;
                     $prep[] = $this->core->number(sanitize_text_field($this->args['amount']['num']));
                 }
             } else {
                 $amounts = explode(',', $this->args['amount']);
                 $amount_count = count($amounts);
                 if ($amount_count > 1) {
                     $amount_count = $amount_count - 1;
                     $wheres[] = 'amount IN (' . $format . str_repeat(',' . $format, $ref_id_count) . ')';
                     foreach ($amount_count as $amount) {
                         $prep[] = $this->core->number(sanitize_text_field($amount));
                     }
                 } else {
                     $wheres[] = 'creds = ' . $format;
                     $prep[] = $this->core->number(sanitize_text_field($amounts[0]));
                 }
             }
         }
         // Time
         if ($this->args['time'] !== NULL && $this->args['time'] != '') {
             $now = date_i18n('U');
             $today = strtotime(date_i18n('Y/m/d') . ' midnight');
             $todays_date = date_i18n('d');
             // Show todays entries
             if ($this->args['time'] == 'today') {
                 $wheres[] = "time BETWEEN {$today} AND {$now}";
             } elseif ($this->args['time'] == 'yesterday') {
                 $yesterday = strtotime('-1 day midnight');
                 $wheres[] = "time BETWEEN {$yesterday} AND {$today}";
             } elseif ($this->args['time'] == 'thisweek') {
                 $weekday = date_i18n('w');
                 // New week started today so show only todays
                 if (get_option('start_of_week') == $weekday) {
                     $wheres[] = "time BETWEEN {$today} AND {$now}";
                 } else {
                     $week_start = strtotime('-' . ($weekday + 1) . ' days midnight');
                     $wheres[] = "time BETWEEN {$week_start} AND {$now}";
                 }
             } elseif ($this->args['time'] == 'thismonth') {
                 $start_of_month = strtotime(date_i18n('Y/m/01') . ' midnight');
                 $wheres[] = "time BETWEEN {$start_of_month} AND {$now}";
             } else {
                 $times = explode(',', $this->args['time']);
                 if (count($times) == 2) {
                     $from = sanitize_key($times[0]);
                     $to = sanitize_key($times[1]);
                     $wheres[] = "time BETWEEN {$from} AND {$to}";
                 }
             }
         }
         // Entry Search
         if ($this->args['s'] !== NULL && $this->args['s'] != '') {
             $search_query = sanitize_text_field($this->args['s']);
             if (is_int($search_query)) {
                 $search_query = (string) $search_query;
             }
             $wheres[] = "entry LIKE %s";
             $prep[] = "%{$search_query}%";
         }
         // Data
         if ($this->args['data'] !== NULL && $this->args['data'] != '') {
             $data_query = sanitize_text_field($this->args['data']);
             if (is_int($data_query)) {
                 $data_query = (string) $data_query;
             }
             $wheres[] = "data LIKE %s";
             $prep[] = $data_query;
         }
         // Order by
         if ($this->args['orderby'] != '') {
             // Make sure $sortby is valid
             $sortbys = array('id', 'ref', 'ref_id', 'user_id', 'creds', 'ctype', 'entry', 'data', 'time');
             $allowed = apply_filters('mycred_allowed_sortby', $sortbys);
             if (in_array($this->args['orderby'], $allowed)) {
                 $sortby = "ORDER BY " . $this->args['orderby'] . " " . $this->args['order'];
             }
         }
         // Number of results
         $number = $this->args['number'];
         if ($number < -1) {
             $number = abs($number);
         } elseif ($number == 0 || $number == -1) {
             $number = NULL;
         }
         // Limits
         if ($number !== NULL) {
             $page = 1;
             if ($this->args['paged'] !== NULL) {
                 $page = absint($this->args['paged']);
                 if (!$page) {
                     $page = 1;
                 }
             }
             if ($this->args['offset'] != '') {
                 $pgstrt = ($page - 1) * $number . ', ';
             } else {
                 $offset = absint($this->args['offset']);
                 $pgstrt = $offset . ', ';
             }
             $limits = 'LIMIT ' . $pgstrt . $number;
         } else {
             $limits = '';
         }
         // Prep return
         if ($this->args['ids'] === true) {
             $select = 'id';
         } else {
             $select = '*';
         }
         $found_rows = '';
         if ($limits != '') {
             $found_rows = 'SQL_CALC_FOUND_ROWS';
         }
         // Filter
         $select = apply_filters('mycred_query_log_select', $select, $this->args, $this->core);
         $sortby = apply_filters('mycred_query_log_sortby', $sortby, $this->args, $this->core);
         $limits = apply_filters('mycred_query_log_limits', $limits, $this->args, $this->core);
         $wheres = apply_filters('mycred_query_log_wheres', $wheres, $this->args, $this->core);
         $prep = apply_filters('mycred_query_log_prep', $prep, $this->args, $this->core);
         $where = 'WHERE ' . implode(' AND ', $wheres);
         // Run
         $this->request = $wpdb->prepare("SELECT {$found_rows} {$select} FROM {$this->core->log_table} {$where} {$sortby} {$limits}", $prep);
         $this->prep = $prep;
         $this->results = $wpdb->get_results($this->request, $array ? ARRAY_A : OBJECT);
         if ($limits != '') {
             $this->num_rows = $wpdb->get_var('SELECT FOUND_ROWS()');
         } else {
             $this->num_rows = count($this->results);
         }
         if ($limits != '') {
             $this->max_num_pages = ceil($this->num_rows / $number);
         }
         if ($this->args['cache'] != '') {
             if (is_multisite()) {
                 set_site_transient('mycred_log_query_' . $cache_id, $this->results, DAY_IN_SECONDS * 1);
             } else {
                 set_transient('mycred_log_query_' . $cache_id, $this->results, DAY_IN_SECONDS * 1);
             }
         }
         $this->total_rows = $wpdb->get_var("SELECT COUNT( * ) FROM {$this->core->log_table}");
     } else {
         $this->request = 'transient';
         $this->results = $data;
         $this->prep = '';
         $this->num_rows = count($data);
     }
     $this->headers = $this->table_headers();
 }
예제 #11
0
 /**
  * Get Sales Data from Log Data
  * @since 1.4
  * @version 1.0
  */
 public function get_sales_data_from_log_data($log_data = '')
 {
     $defaults = array('', '', '', '', '', '', '');
     $log_data = maybe_unserialize($log_data);
     $found_data = array();
     if (is_array($log_data) && array_key_exists('sales_data', $log_data)) {
         if (is_array($log_data['sales_data'])) {
             $found_data = $log_data['sales_data'];
         } else {
             $found_data = explode('|', $log_data['sales_data']);
         }
     } elseif (!empty($log_data) && !is_array($log_data)) {
         $try = explode('|', $log_data);
         if (count($try == 7)) {
             $found_data = $log_data;
         }
     }
     return mycred_apply_defaults($defaults, $found_data);
 }
예제 #12
0
        /**
         * Add to General Settings
         * @since 1.4
         * @version 1.0
         */
        public function after_general_settings($mycred)
        {
            if (!isset($this->wplms)) {
                $prefs = $this->default_prefs;
            } else {
                $prefs = mycred_apply_defaults($this->default_prefs, $this->wplms);
            }
            ?>

<h4><div class="icon icon-active"></div><?php 
            _e('WPLMS', 'wplms-mycred');
            ?>
</h4>
<div class="body" style="display:none;">
	<label class="subheader" for="<?php 
            echo $this->field_id('log');
            ?>
"><?php 
            _e('Log Template', 'wplms-mycred');
            ?>
</label>
	<ol id="myCRED-wplms-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('log');
            ?>
" id="<?php 
            echo $this->field_id('log');
            ?>
" value="<?php 
            echo $prefs['log'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Log entry for successful WPLMS Points criteria redemption.', 'wplms-mycred');
            ?>
</span>
		</li>
	</ol>
	<label class="subheader" for="<?php 
            echo $this->field_id('success');
            ?>
"><?php 
            _e('Success Message', 'wplms-mycred');
            ?>
</label>
	<ol id="myCRED-wplms-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('success');
            ?>
" id="<?php 
            echo $this->field_id('success');
            ?>
" value="<?php 
            echo $prefs['success'];
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Message to show when a user has successfully earned WPLMS Points.', 'wplms-mycred');
            ?>
</span>
		</li>
	</ol>
	<!--label class="subheader" for="<?php 
            echo $this->field_id('referral');
            ?>
"><?php 
            _e('Referrals', 'wplms-mycred');
            ?>
</label>
	<ol id="myCRED-wplms-log">
		<li>
			<div class="h2"><input type="text" name="<?php 
            echo $this->field_name('referral');
            ?>
" id="<?php 
            echo $this->field_id('referral');
            ?>
" value="<?php 
            echo is_numeric($prefs['referral']) ? $prefs['referral'] : '0';
            ?>
" class="long" /></div>
			<span class="description"><?php 
            _e('Enter referral points when a user refers a new user.', 'wplms-mycred');
            ?>
</span>
		</li>
	</ol-->
</div>
<?php 
        }