public function new_post_title() { return (string) $this->data[self::KEY_NEW_POST_TITLE]; }
/** * Connects the current post with a new remote one. * * @return bool|WP_Error Whether or not the relationship was updated successfully, or an error object. */ private function connect_new_post() { $source_post = $this->context->source_post(); if (!$source_post) { return false; } $remote_site_id = $this->context->remote_site_id(); $save_context = ['source_blog' => $this->context->source_site_id(), 'source_post' => $source_post, 'real_post_type' => $this->get_real_post_type($source_post), 'real_post_id' => empty($_POST['post_ID']) ? $this->context->source_post_id() : (int) $_POST['post_ID']]; /** This action is documented in inc/advanced-translator/Mlp_Advanced_Translator_Data.php */ do_action('mlp_before_post_synchronization', $save_context); switch_to_blog($remote_site_id); $new_post_id = wp_insert_post(['post_type' => $source_post->post_type, 'post_status' => 'draft', 'post_title' => $this->context->new_post_title()], true); restore_current_blog(); $save_context['target_blog_id'] = $remote_site_id; /** This action is documented in inc/advanced-translator/Mlp_Advanced_Translator_Data.php */ do_action('mlp_after_post_synchronization', $save_context); if (is_wp_error($new_post_id)) { $this->last_error = $new_post_id; return false; } $this->context = RelationshipContext::from_existing($this->context, [RelationshipContext::KEY_NEW_POST_ID => $new_post_id]); return $this->connect_existing_post(); }