/** * Autosave the revisioned meta fields. * * Iterates thru the revisioned meta fields and checks each to see if they are set, * and have a changed value. If so, the meta value is saved and attached to the autosave. * * @param Post object $new_autosave The new post being autosaved. */ public function _wp_autosave_post_revisioned_meta_fields($new_autosave) { /** * The post data arrives as either $_POST['data']['wp_autosave'] or the $_POST * itself. This sets $posted_data to the correct variable. */ $posted_data = isset($_POST['data']) ? $_POST['data']['wp_autosave'] : $_POST; /** * Go thru the revisioned meta keys and save them as part of the autosave, if * the meta key is part of the posted data, the meta value is not blank and * the the meta value has changes from the last autosaved value. */ foreach ($this->_wp_post_revision_meta_keys() as $meta_key) { if (isset($posted_data[$meta_key]) && '' !== $posted_data[$meta_key] && get_post_meta($new_autosave['ID'], $meta_key, true) != wp_unslash($posted_data[$meta_key])) { /* * Use the underlying delete_metadata() and add_metadata() functions * vs delete_post_meta() and add_post_meta() to make sure we're working * with the actual revision meta. */ delete_metadata('post', $new_autosave['ID'], $meta_key); /** * One last check to ensure meta value not empty(). */ if (!empty($posted_data[$meta_key])) { /** * Add the revisions meta data to the autosave. */ $encoded = PT_PageBuilder_Helper::encode_pb_metadata($posted_data[$meta_key]); add_metadata('post', $new_autosave['ID'], $meta_key, $encoded); } } } }
private function get_sections($encode = false) { if (empty($this->_sections) && isset($_POST['pt_pb_section'])) { $this->_sections = $this->prepare_sections($_POST['pt_pb_section']); } if ($encode) { return PT_PageBuilder_Helper::encode_pb_metadata($this->_sections); } return $this->_sections; }