/**
  * Do manually array_merge($old_values, $new_values) on slider post save
  * because that feature was removed in https://github.com/ThemeFuse/Unyson/commit/e75ff06a2262e49576fac647e8d3651ab842b7b1
  * int $post_id
  * WP_Post $post
  * array $old_values
  */
 public function _action_slider_post_merge_old_db_option_values($post_id, $post, $old_values)
 {
     if ($post->post_type !== $this->post_type) {
         return;
     }
     fw_set_db_post_option($post_id, null, array_merge($old_values, fw_get_db_post_option($post_id)));
 }
Пример #2
0
 /**
  * @param $revision_id
  */
 public function _action__wp_put_post_revision($revision_id)
 {
     /**
      * Copy options meta from post to revision
      */
     fw_set_db_post_option($revision_id, null, (array) fw_get_db_post_option(wp_is_post_revision($revision_id), null, array()));
 }
Пример #3
0
 /**
  * @param int  $post_id
  * @param WP_Post $post
  */
 public function _action_save_post($post_id, $post)
 {
     if (!fw_is_real_post_save($post_id)) {
         return;
     }
     $options_values = array_merge((array) fw_get_db_post_option($post_id), fw_get_options_values_from_input(fw()->theme->get_post_options($post->post_type)));
     fw_set_db_post_option($post_id, null, $options_values);
     // find options that requested to be saved in separate meta
     foreach (fw_extract_only_options(fw()->theme->get_post_options($post->post_type)) as $option_id => $option) {
         if (isset($option['save-to-separate-meta']) && $option['save-to-separate-meta']) {
             // think of a better key name
             fw_update_post_meta($post_id, 'fw_option_' . $option_id, $options_values[$option_id]);
         }
     }
     do_action('fw_save_post_options', $post_id, $post, $options_values);
 }
 /**
  * Solve the problem with striped backslashes by wordpress when doing add_post_meta
  *
  * @internal
  *
  * @param int $post_id
  * @param string $key
  * @param mixed $value
  **/
 public function _action_import_post_meta($post_id, $key, $value)
 {
     if ($key != FW_Option_Type::get_default_name_prefix() || !isset($value[$this->builder_option_key])) {
         return;
     }
     fw_set_db_post_option($post_id, $this->builder_option_key, $value[$this->builder_option_key]);
 }
Пример #5
0
 /**
  * @param int  $post_id
  * @param WP_Post $post
  */
 public function _action_save_post($post_id, $post)
 {
     if (!fw_is_real_post_save($post_id)) {
         return;
     }
     $old_values = (array) fw_get_db_post_option($post_id);
     $options_values = array_merge($old_values, fw_get_options_values_from_input(fw()->theme->get_post_options($post->post_type)));
     fw_set_db_post_option($post_id, null, $options_values);
     do_action('fw_save_post_options', $post_id, $post, $old_values);
 }