Monday, 20 May 2013

Save front-end editor content to database

Save front-end editor content to database

I'm trying to implement the wordpress editor into the frontend as outlined here - http://soderlind.no/front-end-editor-in-wordpress-3-3/
I have got the editor working using the code below but can't work out how I would save the content changes back to the database? Does anybody know how to do this please?
(I have already tried the Front-end Editor plugin and it does not do what I want).
//code below
    function ps_add_post_editor($content) {
    global $post;
    $settings = array(
        'wpautop' => true,
        'media_buttons' => false,
        'tinymce' => array(
            'theme_advanced_buttons1' => 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen',
            'theme_advanced_buttons2' => '',
            'theme_advanced_buttons3' => '',
            'theme_advanced_buttons4' => ''
        ),
        'quicktags' => array(
            'buttons' => 'b,i,ul,ol,li,link,close'
        )
    );
    if(!is_feed()) { // more conditional tags at http://codex.wordpress.org/Conditional_Tags
        $content .= '' . ps_get_wp_editor($post->post_content, 'textarea-' . $post->ID , $settings) . '';
    }
    return $content;
}
// from http://wordpress.stackexchange.com/questions/36567/wp-editor-on-front-end-javascripts-not-included/41426#41426
function ps_get_wp_editor($content,$textarea,$settings) {
    ob_start();
    wp_editor($content, $textarea, $settings);
    $edior_html_code = ob_get_contents();
    ob_end_clean();
    return $edior_html_code;
}
add_filter('the_content', 'ps_add_post_editor');

No comments:

Post a Comment