public function save_editor($post_id, $posted, $revision = self::REVISION_PUBLISH)
{
// Change the global post to current library post, so widgets can use `get_the_ID` and other post data
if (isset($GLOBALS['post'])) {
$global_post = $GLOBALS['post'];
}
$GLOBALS['post'] = get_post($post_id);
$editor_data = $this->_get_editor_data($posted);
// We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
$json_value = wp_slash(wp_json_encode($editor_data));
if (self::REVISION_PUBLISH === $revision) {
$this->remove_draft($post_id);
update_post_meta($post_id, '_elementor_data', $json_value);
$this->_save_plain_text($post_id);
} else {
update_post_meta($post_id, '_elementor_draft_data', $json_value);
}
update_post_meta($post_id, '_elementor_version', self::DB_VERSION);
// Restore global post
if (isset($global_post)) {
$GLOBALS['post'] = $global_post;
} else {
unset($GLOBALS['post']);
}
}