Example #1
0
 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>');
     }
     $categories = get_the_category($post_id);
     $category_slug = isset($categories[0]) ? $categories[0]->slug : '';
     $new_post_content = $_POST['content'];
     $new_post_content = p2_list_creator($new_post_content);
     /* Add the quote citation to the content if it exists */
     if (!empty($_POST['citation']) && 'quote' == $category_slug) {
         $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);
     if (!$post) {
         die('-1');
     }
     if ('quote' == $category_slug) {
         $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') . ' ', ', ', ' &nbsp;')));
 }
Example #2
0
function tags_with_count( $format = 'list', $before = '', $sep = '', $after = '' ) {
	global $post;
	echo get_tags_with_count( $post, $format, $before, $sep, $after );
}