In a plugin I've created a custom post type that stores xml representing models in the respective posts' content.
I've also created a custom meta box that allows the user to edit the xml with a graphic modeler. The changed xml gets stored in a hidden field's value.
When the user clicks Save Draft or Publish I want to save this value as the post's content. By using the save_post
action the content gets saved, however I get redirected to a dead page with ERR_CONNECTION_RESET
after a very long loading time when clicking on Save Draft.
This is my save_post
action:
class MetaBoxes
{
.
.
public function saveModel($postId, $post, $update)
{
if (get_post($postId)->post_type != $this->post_type)
{
return;
}
if (array_key_exists(self::INPUT_ID, $_POST))
{
wp_update_post([
'ID' => $postId,
'post_content' => urldecode($_POST[self::INPUT_ID])
]);
}
}
.
.
}
I know there are security issues in the current state. Let's ignore them until the main functionality is fixed.
Thanks in advance!