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


PHP MS_Factory::get_transient方法代码示例

本文整理汇总了PHP中MS_Factory::get_transient方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Factory::get_transient方法的具体用法?PHP MS_Factory::get_transient怎么用?PHP MS_Factory::get_transient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MS_Factory的用法示例。


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

示例1: get_application

 /**
  * Get user's coupon application.
  *
  * @since  1.0.0
  *
  * @param int $user_id The user id.
  * @param int $membership_id The membership id.
  * @return MS_Addon_Coupon_Model The coupon model object.
  */
 public static function get_application($user_id, $membership_id)
 {
     $key = self::get_transient_name($user_id, $membership_id);
     $transient = MS_Factory::get_transient($key);
     $coupon = null;
     if (is_array($transient) && !empty($transient['id'])) {
         $the_id = intval($transient['id']);
         $coupon = MS_Factory::load('MS_Addon_Coupon_Model', $the_id);
         $coupon->coupon_message = $transient['message'];
     } else {
         $coupon = MS_Factory::load('MS_Addon_Coupon_Model');
     }
     return apply_filters('ms_addon_coupon_model_get_application', $coupon, $user_id, $membership_id);
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:23,代码来源:class-ms-addon-coupon-model.php

示例2: clean_db

 /**
  * Search for orphaned relationships and remove them.
  *
  * We write a custom SQL query for this, as solving it with a meta-query
  * structure is very performance intense and requires at least two queries
  * and a loop...
  *
  * For additional performance we will only do this check once every hour.
  *
  * Note: We cannot use the hook 'delete_user' to do this, because in
  * Multisite users are deleted via the Main network admin; however, there
  * we do not have access to the site data; especially if Plugin is not
  * network enabled...
  *
  * @todo Change this to use WP-Cron instead of own implementation...
  *
  * @since  1.0.0
  * @internal
  */
 public static function clean_db()
 {
     $timestamp = absint(MS_Factory::get_transient('ms_member_clean_db'));
     $elapsed = time() - $timestamp;
     if ($elapsed > 3600) {
         // Last check is longer than 1 hour ago. Check again.
         MS_Factory::set_transient('ms_member_clean_db', time(), 3600);
     } else {
         // Last check was within past hour. Do nothing yet...
         return;
     }
     global $wpdb;
     // Find all Relationships that have no post-author.
     $sql = "\n\t\tSELECT p.ID\n\t\tFROM {$wpdb->posts} p\n\t\tWHERE p.post_type=%s\n\t\tAND NOT EXISTS (\n\t\t\tSELECT 1\n\t\t\tFROM {$wpdb->users} u\n\t\t\tWHERE u.ID = p.post_author\n\t\t);\n\t\t";
     $sql = $wpdb->prepare($sql, MS_Model_Relationship::get_post_type());
     // Delete these Relationships!
     $items = $wpdb->get_results($sql);
     foreach ($items as $item) {
         $junk = MS_Factory::load('MS_Model_Relationship', $item->ID);
         $junk->delete();
     }
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:41,代码来源:class-ms-model-member.php

示例3: verify_token

 /**
  * Verfies the admin token in the $_GET collection
  *
  * $_GET['ms_token'] must match the current ms_token
  * $_POST['confirm'] must have value 'yes'
  *
  * @since  1.0.0
  * @internal
  *
  * @param  string $action Like a nonce, this is the action to execute.
  * @return bool
  */
 private static function verify_token($action)
 {
     if (!self::valid_user()) {
         return false;
     }
     if (empty($_GET['ms_token'])) {
         return false;
     }
     $get_token = $_GET['ms_token'];
     if (empty($_POST['confirm'])) {
         return false;
     }
     if ('yes' != $_POST['confirm']) {
         return false;
     }
     $one_time_key = MS_Factory::get_transient('ms_one_time_key-' . $action);
     MS_Factory::delete_transient('ms_one_time_key-' . $action);
     if (empty($one_time_key)) {
         return false;
     }
     // We verify the current and the previous beat
     $plain_token_1 = $action . '-' . date('B') . ':' . get_current_user_id() . '-' . $one_time_key;
     $plain_token_2 = $action . '-' . (date('B') - 1) . ':' . get_current_user_id() . '-' . $one_time_key;
     if (wp_verify_nonce($get_token, $plain_token_1)) {
         return true;
     }
     if (wp_verify_nonce($get_token, $plain_token_2)) {
         return true;
     }
     return false;
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:43,代码来源:class-ms-model-upgrade.php

示例4: create_or_update_coupon

 /**
  * Creates or updates the coupon specified by the function parameter.
  *
  * @since  1.0.0
  * @internal
  *
  * @param array $coupon_data The object containing all details for Stripe.
  */
 public function create_or_update_coupon($coupon_data)
 {
     $item_id = $coupon_data['id'];
     $all_items = MS_Factory::get_transient('ms_stripeplan_plans');
     $all_items = lib2()->array->get($all_items);
     if (!isset($all_items[$item_id]) || !is_a($all_items[$item_id], 'M2_Stripe_Coupon')) {
         try {
             $item = M2_Stripe_Coupon::retrieve($item_id);
         } catch (Exception $e) {
             // If the coupon does not exist then stripe will throw an Exception.
             $item = false;
         }
         $all_items[$item_id] = $item;
     } else {
         $item = $all_items[$item_id];
     }
     /*
      * Stripe can only update the coupon-name, so we have to delete and
      * recreate the coupon manually.
      */
     if ($item && is_a($item, 'M2_Stripe_Coupon')) {
         $item->delete();
         $all_items[$item_id] = false;
     }
     $item = M2_Stripe_Coupon::create($coupon_data);
     $all_items[$item_id] = $item;
     MS_Factory::set_transient('ms_stripeplan_coupons', $all_items, HOUR_IN_SECONDS);
 }
开发者ID:jsandlin85,项目名称:SkylineSports,代码行数:36,代码来源:class-ms-gateway-stripe-api.php

示例5: update_stripe_data_coupon

 /**
  * Creates or updates a single coupon on Stripe.
  *
  * This function is called when the gateway is activated and after a
  * coupon was saved to database.
  *
  * @since  1.0.0
  */
 public function update_stripe_data_coupon($coupon)
 {
     if (!$this->active) {
         return false;
     }
     $this->_api->set_gateway($this);
     $settings = MS_Plugin::instance()->settings;
     $duration = 'once';
     $percent_off = null;
     $amount_off = null;
     if (MS_Addon_Coupon_Model::TYPE_VALUE == $coupon->discount_type) {
         $amount_off = absint($coupon->discount * 100);
     } else {
         $percent_off = $coupon->discount;
     }
     $coupon_data = array('id' => self::get_the_id($coupon->id, 'coupon'), 'duration' => $duration, 'amount_off' => $amount_off, 'percent_off' => $percent_off, 'currency' => $settings->currency);
     // Check if the plan needs to be updated.
     $serialized_data = json_encode($coupon_data);
     $temp_key = substr('ms-stripe-' . $coupon_data['id'], 0, 45);
     $temp_data = MS_Factory::get_transient($temp_key);
     if ($temp_data != $serialized_data) {
         MS_Factory::set_transient($temp_key, $serialized_data, HOUR_IN_SECONDS);
         $this->_api->create_or_update_coupon($coupon_data);
     }
 }
开发者ID:jsandlin85,项目名称:SkylineSports,代码行数:33,代码来源:class-ms-gateway-stripeplan.php

示例6: get_application

 /**
  * Get user's invitation application.
  *
  * @since  1.0.0
  *
  * @param int $user_id The user id.
  * @param int $membership_id The membership id.
  * @return MS_Addon_Invitation_Model The invitation model object.
  */
 public static function get_application($user_id, $membership_id)
 {
     $key = self::get_transient_name($user_id, $membership_id);
     $transient = MS_Factory::get_transient($key);
     $invitation = null;
     if (is_array($transient) && !empty($transient['id'])) {
         $the_id = intval($transient['id']);
         $invitation = MS_Factory::load('MS_Addon_Invitation_Model', $the_id);
         $invitation->invitation_message = $transient['message'];
     } else {
         $invitation = MS_Factory::load('MS_Addon_Invitation_Model');
     }
     if ($invitation->is_valid()) {
         $invitation->invitation_message = __('Invitation code is correct.', 'membership2');
     }
     return apply_filters('ms_addon_invitation_model_get_application', $invitation, $user_id, $membership_id);
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:26,代码来源:class-ms-addon-invitation-model.php


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