Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Group Blog


peterverkooijen
Participant

@peterverkooijen

Is this the function (from p2/inc/ajax.php) that handles data from the P2 post form?:

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>');
}

$new_post_content = $_POST['content'];

// preserve custom "big" titles
$post = get_post( $post_id );

if ( !$post ) die('-1');

$clean_title = str_replace( '…', '', $post->post_title );

if( strpos($post->post_content, $clean_title ) !== 0 ) {
$post_title = $post->post_title;
} else {
$post_title = prologue_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
));

$post = get_post( $post );

echo apply_filters( 'the_content', $post->post_content );
}

How does this function know which blog to store the data in?!

I guess my problem has to do this:

check_ajax_referer( 'ajaxnonce', '_inline_edit' );

What does that do?

There is also a function new_post() that has this:

if( 'POST' != $_SERVER['REQUEST_METHOD'] || empty( $_POST['action'] ) || $_POST['action'] != 'new_post' ) {
die('-1');
}

That has to do with matching referrers etc, right?

Any pointers and ideas appreciated…

Skip to toolbar