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


PHP MS_Factory::serialize_model方法代码示例

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


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

示例1: save

 /**
  * Save content in wp_option table.
  *
  * Update WP cache and instance singleton.
  *
  * @since  1.0.0
  */
 public function save()
 {
     $this->before_save();
     $option_key = $this->option_key();
     $settings = MS_Factory::serialize_model($this);
     MS_Factory::update_option($option_key, $settings);
     $this->instance = $this;
     $this->after_save();
     wp_cache_set($option_key, $this, 'MS_Model_Option');
 }
开发者ID:EdoMagen,项目名称:project-s-v2,代码行数:17,代码来源:class-ms-model-option.php

示例2: save

 /**
  * Save content in wp_option table.
  *
  * Update WP cache and instance singleton.
  *
  * @since  1.0.0
  */
 public function save()
 {
     $this->before_save();
     $option_key = $this->option_key();
     $settings = array();
     $data = MS_Factory::serialize_model($this);
     foreach ($data as $field => $val) {
         $settings[$field] = $this->{$field};
     }
     MS_Factory::set_transient($option_key, $settings, DAY_IN_SECONDS);
     $this->after_save();
     wp_cache_set($option_key, $this, 'MS_Model_Transient');
 }
开发者ID:klgrimley,项目名称:mzf,代码行数:20,代码来源:class-ms-model-transient.php

示例3: save

 /**
  * Save member.
  *
  * Create a new user is id is empty.
  * Save member fields to wp_user and wp_usermeta tables.
  * Set cache for further use in MS_Factory::load.
  * The usermeta are prefixed with 'ms_'.
  *
  * @since  1.0.0
  * @api
  *
  * @return MS_Model_Member The saved member object.
  */
 public function save()
 {
     $class = get_class($this);
     /**
      * Tell WordPress core that we do NOT want to trigger the
      * Password-Reset email while updating the user now.
      * New since WordPress 4.3.0
      *
      * @since  1.0.2.2
      */
     add_filter('send_password_change_email', '__return_false');
     if (empty($this->id)) {
         $this->create_new_user();
     }
     if (isset($this->username)) {
         $wp_user = new stdClass();
         $wp_user->ID = $this->id;
         $wp_user->nickname = $this->username;
         $wp_user->user_nicename = $this->username;
         $wp_user->first_name = $this->first_name;
         $wp_user->last_name = $this->last_name;
         $wp_user->user_email = $this->email;
         if (!empty($this->password) && $this->password == $this->password2) {
             $wp_user->user_pass = $this->password;
         }
         wp_update_user(get_object_vars($wp_user));
     }
     // Serialize our plugin meta data
     $data = MS_Factory::serialize_model($this);
     // Then update all meta fields that are inside the collection
     foreach ($data as $field => $val) {
         update_user_meta($this->id, 'ms_' . $field, $val);
     }
     wp_cache_set($this->id, $this, $class);
     // Remove our "mute-password-reset-email" trigger again.
     remove_filter('send_password_change_email', '__return_false');
     return apply_filters('ms_model_member_save', $this);
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:51,代码来源:class-ms-model-member.php

示例4: save

 /**
  * Save member.
  *
  * Create a new user is id is empty.
  * Save member fields to wp_user and wp_usermeta tables.
  * Set cache for further use in MS_Factory::load.
  * The usermeta are prefixed with 'ms_'.
  *
  * @since  1.0.0
  * @api
  *
  * @return MS_Model_Member The saved member object.
  */
 public function save()
 {
     $class = get_class($this);
     if (empty($this->id)) {
         $this->create_new_user();
     }
     if (isset($this->username)) {
         $wp_user = new stdClass();
         $wp_user->ID = $this->id;
         $wp_user->nickname = $this->username;
         $wp_user->user_nicename = $this->username;
         $wp_user->first_name = $this->first_name;
         $wp_user->last_name = $this->last_name;
         if (!empty($this->password) && $this->password == $this->password2) {
             $wp_user->user_pass = $this->password;
         }
         wp_update_user(get_object_vars($wp_user));
     }
     // Serialize our plugin meta data
     $data = MS_Factory::serialize_model($this);
     // Then update all meta fields that are inside the collection
     foreach ($data as $field => $val) {
         update_user_meta($this->id, 'ms_' . $field, $val);
     }
     wp_cache_set($this->id, $this, $class);
     return apply_filters('ms_model_member_save', $this);
 }
开发者ID:klgrimley,项目名称:mzf,代码行数:40,代码来源:class-ms-model-member.php

示例5: save

 /**
  * Save content in wp tables (wp_post and wp_postmeta).
  *
  * Update WP cache.
  *
  * @since  1.0.0
  */
 public function save()
 {
     MS_Factory::select_blog();
     $this->before_save();
     $this->post_modified = gmdate('Y-m-d H:i:s');
     $class = get_class($this);
     /*
      * Serialize data that is later saved to the postmeta table.
      *
      * While data is serialized it can also modify the model data before
      * writing it to the posts table.
      */
     $data = MS_Factory::serialize_model($this);
     $post = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_author' => $this->user_id, 'post_content' => $this->description, 'post_excerpt' => $this->description, 'post_name' => sanitize_text_field($this->name), 'post_status' => 'private', 'post_title' => sanitize_title(!empty($this->title) ? $this->title : $this->name), 'post_type' => $this->get_post_type(), 'post_modified' => $this->post_modified);
     /**
      * Give child classes an easy way to modify the post and meta data right
      * before it is saved.
      *
      * @since 1.0.1.0
      */
     $post = $this->save_post_data($post);
     $data = $this->save_meta_data($data);
     if (empty($this->id)) {
         $this->id = wp_insert_post($post);
     } else {
         $post['ID'] = $this->id;
         wp_update_post($post);
     }
     // We first remove any metadata of our custom post type that is not
     // contained in the serialized data collection.
     $this->clean_metadata(array_keys($data));
     // Then we update all meta fields that are inside the collection
     foreach ($data as $field => $val) {
         update_post_meta($this->id, $field, $val);
     }
     wp_cache_set($this->id, $this, $class);
     $this->after_save();
     MS_Factory::revert_blog();
     global $wp_current_filter;
     if (!in_array('ms_saved_' . $class, $wp_current_filter)) {
         /**
          * Action triggered after a custom post type model was saved to
          * database.
          *
          * @since  1.0.0
          */
         do_action('ms_saved_' . $class, $this);
     }
 }
开发者ID:EdoMagen,项目名称:project-s-v2,代码行数:56,代码来源:class-ms-model-customposttype.php


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