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


PHP mycred_apply_defaults函数代码示例

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


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

示例1: __construct

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

示例2: __construct

 /**
  * 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);
 }
开发者ID:sebastianringel,项目名称:stammtisch,代码行数:52,代码来源:mycred-abstract-payment-gateway.php

示例3: mycred_get_exchange_rates

 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;
 }
开发者ID:suifengtec,项目名称:mycred,代码行数:14,代码来源:mycred-functions.php

示例4: set_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;
                 }
             }
         }
     }
 }
开发者ID:sebastianringel,项目名称:stammtisch,代码行数:66,代码来源:mycred-abstract-module.php

示例5: get_email_settings

 /**
  * 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);
 }
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:16,代码来源:myCRED-addon-email-notices.php

示例6: update_settings

 /**
  * 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;
 }
开发者ID:nfer,项目名称:mycred,代码行数:47,代码来源:mycred-eventespresso3.php

示例7: mycred_update_users_transfer_history

 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);
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:18,代码来源:mycred-transfer-functions.php

示例8: update

 /**
  * 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;
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:56,代码来源:mycred-eventsmanager-pro.php

示例9: after_general_settings

        /**
         * 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');
            ?>
//.........这里部分代码省略.........
开发者ID:sebastianringel,项目名称:stammtisch,代码行数:101,代码来源:myCRED-addon-coupons.php

示例10: __construct

 /**
  * 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));
//.........这里部分代码省略.........
开发者ID:nfer,项目名称:mycred,代码行数:101,代码来源:mycred-log.php

示例11: get_sales_data_from_log_data

 /**
  * 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);
 }
开发者ID:suifengtec,项目名称:mycred,代码行数:24,代码来源:myCRED-addon-buy-creds.php

示例12: after_general_settings

        /**
         * 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 
        }
开发者ID:songlequang,项目名称:myclass,代码行数:97,代码来源:myCRED-addon-wplms.php


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