static function save_post() { check_ajax_referer('ajaxnonce', '_inline_edit'); if (!is_user_logged_in()) { die('<p>' . __('Error: not logged in.', 'p2') . '</p>'); } $post_id = $_POST['post_ID']; $post_id = substr($post_id, strpos($post_id, '-') + 1); if (!current_user_can('edit_post', $post_id)) { die('<p>' . __('Error: not allowed to edit post.', 'p2') . '</p>'); } $post_format = p2_get_post_format($post_id); $new_post_content = $_POST['content']; // Add the quote citation to the content if it exists if (!empty($_POST['citation']) && 'quote' == $post_format) { $new_post_content = '<p>' . $new_post_content . '</p><cite>' . $_POST['citation'] . '</cite>'; } $new_tags = $_POST['tags']; $new_post_title = isset($_POST['title']) ? $_POST['title'] : ''; if (!empty($new_post_title)) { $post_title = $new_post_title; } else { $post_title = p2_title_from_content($new_post_content); } $post = wp_update_post(array('post_title' => $post_title, 'post_content' => $new_post_content, 'post_modified' => current_time('mysql'), 'post_modified_gmt' => current_time('mysql', 1), 'ID' => $post_id)); $tags = wp_set_post_tags($post_id, $new_tags); $post = get_post($post); $GLOBALS['post'] = $post; if (!$post) { die('-1'); } if ('quote' == $post_format) { $content = apply_filters('p2_get_quote_content', $post->post_content); } else { $content = apply_filters('the_content', $post->post_content); } echo json_encode(array('title' => $post->post_title, 'content' => $content, 'tags' => get_tags_with_count($post, '', __('<br />Tags:', 'p2') . ' ', ', ', ' '))); }
<?php /* * Content */ ?> <div id="content-<?php the_ID(); ?> " class="postcontent"> <?php /* * Check the post format and display content accordingly. * The value should be a valid post format or one of the back compat categories. */ switch (p2_get_post_format($post->ID)) { case 'status': case 'link': the_content(__('(More ...)', 'p2')); break; case 'quote': p2_quote_content(); break; case 'post': case 'standard': default: p2_title(); the_content(__('(More ...)', 'p2')); break; } ?>