$form_extra = ''; if ('auto-draft' == $post->post_status) { if ('edit' == $action) { $post->post_title = ''; } $autosave = false; $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; } else { $autosave = nxt_get_post_autosave($post_ID); } $form_action = 'editpost'; $nonce_action = 'update-' . $post_type . '_' . $post_ID; $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />"; // Detect if there exists an autosave newer than the post and if that autosave is different than the post if ($autosave && mysql2date('U', $autosave->post_modified_gmt, false) > mysql2date('U', $post->post_modified_gmt, false)) { foreach (_nxt_post_revision_fields() as $autosave_field => $_autosave_field) { if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post->{$autosave_field})) { $notice = sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID)); break; } } unset($autosave_field, $_autosave_field); } $post_type_object = get_post_type_object($post_type); // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). require_once './includes/meta-boxes.php'; add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core'); if (current_theme_supports('post-formats') && post_type_supports($post_type, 'post-formats')) { add_meta_box('formatdiv', _x('Format', 'post format'), 'post_format_meta_box', null, 'side', 'core'); } // all taxonomies
/** * Creates autosave data for the specified post from $_POST data. * * @package NXTClass * @subpackage Post_Revisions * @since 2.6.0 * * @uses _nxt_translate_postdata() * @uses _nxt_post_revision_fields() * * @return unknown */ function nxt_create_post_autosave($post_id) { $translated = _nxt_translate_postdata(true); if (is_nxt_error($translated)) { return $translated; } // Only store one autosave. If there is already an autosave, overwrite it. if ($old_autosave = nxt_get_post_autosave($post_id)) { $new_autosave = _nxt_post_revision_fields($_POST, true); $new_autosave['ID'] = $old_autosave->ID; $new_autosave['post_author'] = get_current_user_id(); return nxt_update_post($new_autosave); } // _nxt_put_post_revision() expects unescaped. $_POST = stripslashes_deep($_POST); // Otherwise create the new autosave as a special post revision return _nxt_put_post_revision($_POST, true); }
/** * Restores a post to the specified revision. * * Can restore a past revision using all fields of the post revision, or only selected fields. * * @package NXTClass * @subpackage Post_Revisions * @since 2.6.0 * * @uses nxt_get_post_revision() * @uses nxt_update_post() * @uses do_action() Calls 'nxt_restore_post_revision' on post ID and revision ID if nxt_update_post() * is successful. * * @param int|object $revision_id Revision ID or revision object. * @param array $fields Optional. What fields to restore from. Defaults to all. * @return mixed Null if error, false if no fields to restore, (int) post ID if success. */ function nxt_restore_post_revision($revision_id, $fields = null) { if (!($revision = nxt_get_post_revision($revision_id, ARRAY_A))) { return $revision; } if (!is_array($fields)) { $fields = array_keys(_nxt_post_revision_fields()); } $update = array(); foreach (array_intersect(array_keys($revision), $fields) as $field) { $update[$field] = $revision[$field]; } if (!$update) { return false; } $update['ID'] = $revision['post_parent']; $update = add_magic_quotes($update); //since data is from db $post_id = nxt_update_post($update); if (is_nxt_error($post_id)) { return $post_id; } if ($post_id) { do_action('nxt_restore_post_revision', $post_id, $revision['ID']); } return $post_id; }
<th scope="col" class="th-full"> <span class="alignleft"><?php printf(__('Older: %s'), nxt_post_revision_title($left_revision)); ?> </span> <span class="alignright"><?php printf(__('Newer: %s'), nxt_post_revision_title($right_revision)); ?> </span> </th> </tr> <?php } // use get_post_to_edit filters? $identical = true; foreach (_nxt_post_revision_fields() as $field => $field_title) { if ('diff' == $action) { $left_content = apply_filters("_nxt_post_revision_field_{$field}", $left_revision->{$field}, $field); $right_content = apply_filters("_nxt_post_revision_field_{$field}", $right_revision->{$field}, $field); if (!($content = nxt_text_diff($left_content, $right_content))) { continue; } // There is no difference between left and right $identical = false; } else { add_filter("_nxt_post_revision_field_{$field}", 'htmlspecialchars'); $content = apply_filters("_nxt_post_revision_field_{$field}", $revision->{$field}, $field); } ?> <tr id="revision-field-<?php