post_preview example

if ( ! wp_delete_post( $post_id, true ) ) {
                wp_die( __( 'Error in deleting the item.' ) );
            }
        }

        wp_redirect( add_query_arg( 'deleted', 1, $sendback ) );
        exit;

    case 'preview':
        check_admin_referer( 'update-post_' . $post_id );

        $url = post_preview();

        wp_redirect( $url );
        exit;

    case 'toggle-custom-fields':
        check_admin_referer( 'toggle-custom-fields', 'toggle-custom-fields-nonce' );

        $current_user_id = get_current_user_id();
        if ( $current_user_id ) {
            $enable_custom_fields = (bool) get_user_meta( $current_user_id, 'enable_custom_fields', true );
            update_user_meta( $current_user_id, 'enable_custom_fields', ! $enable_custom_fields );
        }
Home | Imprint | This part of the site doesn't use cookies.