post_preview [ WordPress Function ]
post_preview ( No parameters )
| Uses: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: _set_preview, is_preview, _show_post_preview, stream_preview_image, post_permalink
Save draft or manually autosave for showing preview.
Source
<?php
function post_preview() {
$post_ID = (int) $_POST['post_ID'];
$status = get_post_status( $post_ID );
if ( 'auto-draft' == $status )
wp_die( __('Preview not available. Please save as a draft first.') );
if ( isset($_POST['catslist']) )
$_POST['post_category'] = explode(",", $_POST['catslist']);
if ( isset($_POST['tags_input']) )
$_POST['tags_input'] = explode(",", $_POST['tags_input']);
if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
unset($_POST['post_category']);
$_POST['ID'] = $post_ID;
$post = get_post($post_ID);
if ( 'page' == $post->post_type ) {
if ( !current_user_can('edit_page', $post_ID) )
wp_die(__('You are not allowed to edit this page.'));
} else {
if ( !current_user_can('edit_post', $post_ID) )
wp_die(__('You are not allowed to edit this post.'));
}
if ( 'draft' == $post->post_status ) {
$id = edit_post();
} else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
$id = wp_create_post_autosave( $post->ID );
if ( ! is_wp_error($id) )
$id = $post->ID;
}
if ( is_wp_error($id) )
wp_die( $id->get_error_message() );
if ( $_POST['post_status'] == 'draft' ) {
$url = add_query_arg( 'preview', 'true', get_permalink($id) );
} else {
$nonce = wp_create_nonce('post_preview_' . $id);
$url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) );
}
return $url;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- #19378 (post_preview() does not apply the preview_post_link filter ...
The post_preview() function (line # 1367 in wp-admin/includes/post.php) does not apply the preview_post_link filter and it probably should. The code to ...
core.trac.wordpress.org - post_preview() WordPress function reference, arguments and ...
Save draft or manually autosave for showing preview.
queryposts.com - PHPXRef 0.7 : WordPress : Function Reference: post_preview()
Function and Method Cross Reference. post_preview(). Defined at: /wp-admin/ includes/post.php -> line 1279. Referenced 1 times: /wp-admin/post.php -> line ...
phpxref.ftwr.co.uk - post_preview (WordPress Function) - WPSeek.com
WordPress lookup for post_preview, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com
Gebruikersdiscussies [ wordpress.org ]
- kaykoral on "Turning off Post Preview? Or reverting back to the one in 1.5."
- spencerp on "Turning off Post Preview? Or reverting back to the one in 1.5."
- kaykoral on "Turning off Post Preview? Or reverting back to the one in 1.5."
- spencerp on "Turning off Post Preview? Or reverting back to the one in 1.5."
- IIIIIIIV on "Turning off Post Preview? Or reverting back to the one in 1.5."
- spencerp on "Turning off Post Preview? Or reverting back to the one in 1.5."
- IIIIIIIV on "Turning off Post Preview? Or reverting back to the one in 1.5."
- kaykoral on "Turning off Post Preview? Or reverting back to the one in 1.5."
- Mark (podz) on "Turning off Post Preview? Or reverting back to the one in 1.5."
- Mark (podz) on "Turning off Post Preview? Or reverting back to the one in 1.5."