inc/post-meta.php
/**
     * When a post saved/updated in the database, this methods updates the meta box params in the db as well.
     */
When a post saved/updated in the database, this methods updates the meta box params in the db as well.
When a post saved / updated in the database this methods updates the meta box params in the db as well .
function save_post()
    {
        add_action('save_post', function()
            {
                if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
                global $post;
                if ($_POST && !wp_verify_nonce($_POST['jw_nonce'], plugin_basename(__FILE__))) {
                    return;
                }
                if (isset($_SESSION['taxonomy_data'])) {
                    foreach ($_SESSION['taxonomy_data'] as $form_name) {
                        if (!empty($_FILES[$form_name]) ) {
                            if ( !empty($_FILES[$form_name]['tmp_name']) ) {
                                $upload = wp_upload_bits($_FILES[$form_name]['name'], null, file_get_contents($_FILES[$form_name]['tmp_name']));
                                if (isset($upload['error']) && $upload['error'] != 0) {
                                    wp_die('There was an error uploading your file. The error is: ' . $upload['error']);
                                } else {
                                    update_post_meta($post->ID, $form_name, $upload['url']);
                                }
                            }
                       } else {
                            if (!isset($_POST[$form_name])) $_POST[$form_name] = '';
                            if (isset($post->ID) ) {
                                update_post_meta($post->ID, $form_name, $_POST[$form_name]);
                            }
                        }
                    }
                    $_SESSION['taxonomy_data'] = array();
                }
            });
    }
function save_post ( ) { add_action ( 'save_post' , function ( ) { if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return ; global $ post ; if ( $ _POST && ! wp_verify_nonce ( $ _POST [ 'jw_nonce' ] , plugin_basename ( __FILE__ ) ) ) { return ; } if ( isset ( $ _SESSION [ 'taxonomy_data' ] ) ) { foreach ( $ _SESSION [ 'taxonomy_data' ] as $ form_name ) { if ( ! empty ( $ _FILES [ $ form_name ] ) ) { if ( ! empty ( $ _FILES [ $ form_name ] [ 'tmp_name' ] ) ) { $ upload = wp_upload_bits ( $ _FILES [ $ form_name ] [ 'name' ] , null , file_get_contents ( $ _FILES [ $ form_name ] [ 'tmp_name' ] ) ) ; if ( isset ( $ upload [ 'error' ] ) && $ upload [ 'error' ] != 0 ) { wp_die ( 'There was an error uploading your file. The error is: ' . $ upload [ 'error' ] ) ; } else { update_post_meta ( $ post -> ID , $ form_name , $ upload [ 'url' ] ) ; } } } else { if ( ! isset ( $ _POST [ $ form_name ] ) ) $ _POST [ $ form_name ] = '' ; if ( isset ( $ post -> ID ) ) { update_post_meta ( $ post -> ID , $ form_name , $ _POST [ $ form_name ] ) ; } } } $ _SESSION [ 'taxonomy_data' ] = array ( ) ; } } ) ; }
When a post saved/updated in the database, this methods updates the meta box params in the db as well.
When a post saved / updated in the database this methods updates the meta box params in the db as well .
// Only do the following if we physically submit the form, // and now when autosave occurs. // Get all the form fields that were saved in the session, // and update their values in the db. // Make better. Have to do this, because I can't figure // out a better way to deal with checkboxes. If deselected, // they won't be represented here, but I still need to // update the value to false to blank in the table. Hmm...