/** * Create the default post data for the save() method. * * @param array $post_data Post data. * @param string $post_type Post type. * @param int $blog_id Blog ID. * * @return array */ private function create_post_to_send(array $post_data, $post_type, $blog_id) { $title = $this->get_remote_post_title($post_data); $content = $this->get_remote_post_content($post_data); if ($this->is_empty_remote_post($title, $content, $post_type)) { return array(); } $new = array('post_type' => $post_type, 'post_title' => $title, 'post_content' => $content, 'post_parent' => $this->basic_data->get_post_parent($blog_id)); if (!empty($post_data['remote_post_id'])) { $new['ID'] = $post_data['remote_post_id']; /** * Filter post data before it is saved to database. * * @param array $new_post * @param array $save_context */ $new = apply_filters('mlp_pre_save_post', $new, $this->save_context); return $new; } // new post $new['post_status'] = 'draft'; /** * Filter post data before it is insert to database. * * @param array $new_post * @param array $save_context */ $new = apply_filters('mlp_pre_insert_post', $new, $this->save_context); return $new; }
/** * Create the default post data for the save() method. * * @param array $post_data Post data. * @param string $post_type Post type. * @param int $blog_id Blog ID. * * @return array */ private function create_post_to_send(array $post_data, $post_type, $blog_id) { $title = $this->get_remote_post_title($post_data); $name = $this->get_remote_post_name($post_data); $content = $this->get_remote_post_content($post_data); $excerpt = $this->get_remote_post_excerpt($post_data); if ($this->is_empty_remote_post($title, $content, $post_type)) { return array(); } $new_post_data = array('post_type' => $post_type, 'post_title' => $title, 'post_name' => $name, 'post_content' => $content, 'post_excerpt' => $excerpt, 'post_parent' => $this->basic_data->get_post_parent($blog_id)); if (!empty($post_data['remote_post_id'])) { $new_post_data['ID'] = $post_data['remote_post_id']; /** * Filter the post data before saving the post. * * @param array $post_data Post data. * @param array $save_context Context of the to-be-saved post. * * @return array */ $new_post_data = apply_filters('mlp_pre_save_post', $new_post_data, $this->save_context); return $new_post_data; } // new post $new_post_data['post_status'] = 'draft'; // add post_author if override is available if (isset($this->post_request_data['post_author_override'])) { $new_post_data['post_author'] = $this->post_request_data['post_author_override']; } /** * Filter the new post data before inserting the post into the database. * * @param array $post_data Post data. * @param array $save_context Context of the to-be-saved post. * * @return array */ $new_post_data = apply_filters('mlp_pre_insert_post', $new_post_data, $this->save_context); return $new_post_data; }
/** * Create the default post data for the save() method. * * @param array $post_data * @param string $post_type * @param int $blog_id * @return array */ private function create_post_to_send(array $post_data, $post_type, $blog_id) { $title = $this->get_remote_post_title($post_data); $content = $this->get_remote_post_content($post_data); if ($this->is_empty_remote_post($title, $content, $post_type)) { return array(); } $new = array('post_type' => $post_type, 'post_title' => $title, 'post_content' => $content, 'post_parent' => $this->basic_data->get_post_parent($blog_id)); if (!empty($post_data['remote_post_id'])) { $new['ID'] = $post_data['remote_post_id']; // deprecated notice for filter "mlp_pre_update_post" if (has_filter('mlp_pre_update_post')) { _doing_it_wrong('mlp_pre_update_post', 'mlp_pre_update_post is deprecated and will be removed in MultilingualPress 2.2, please use mlp_pre_save_post instead.', '2.1'); } /** * Filter post data before it is saved to the database. * * @param array $new_post * @deprecated * @see mlp_pre_save_post */ $new = apply_filters('mlp_pre_update_post', $new); /** * Filter post data before it is saved to database. * @param array $new_post * TODO: Adding 2. param context! See 'mlp_pre_save_post' in Mlp_Translatable_Post_Data.php */ $new = apply_filters('mlp_pre_save_post', $new); return $new; } // new post $new['post_status'] = 'draft'; /** * Filter post data before it is insert to database. * @param array $new_post * TODO: Adding 2. param context! See 'mlp_pre_insert_post' in Mlp_Translatable_Post_Data.php */ return apply_filters('mlp_pre_insert_post', $new); }