wp_write_post [ WordPress-Funktionen ]
wp_write_post ( Keine Parameter )
| Gibt zurück: |
|
| Definiert in: |
|
| Codex |
Creates a new post from the "Write Post" form using $_POST information.
Quellcode
function wp_write_post() {
global $user_ID;
if ( isset($_POST['post_type']) )
$ptype = get_post_type_object($_POST['post_type']);
else
$ptype = get_post_type_object('post');
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
if ( 'page' == $ptype->name )
return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
else
return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
}
$_POST['post_mime_type'] = '';
// Clear out any data in internal vars.
unset( $_POST['filter'] );
// Edit don't write if we have a post id.
if ( isset( $_POST['post_ID'] ) )
return edit_post();
$translated = _wp_translate_postdata( false );
if ( is_wp_error($translated) )
return $translated;
if ( isset($_POST['visibility']) ) {
switch ( $_POST['visibility'] ) {
case 'public' :
$_POST['post_password'] = '';
break;
case 'password' :
unset( $_POST['sticky'] );
break;
case 'private' :
$_POST['post_status'] = 'private';
$_POST['post_password'] = '';
unset( $_POST['sticky'] );
break;
}
}
// Create the post.
$post_ID = wp_insert_post( $_POST );
if ( is_wp_error( $post_ID ) )
return $post_ID;
if ( empty($post_ID) )
return 0;
add_meta( $post_ID );
add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
// Now that we have an ID we can fix any attachment anchor hrefs
_fix_attachment_links( $post_ID );
wp_set_post_lock( $post_ID );
return $post_ID;
}Beispiele [ wp-snippets.com ]
Top Google Suchergebnisse
- wp_write_post (WordPress Function) - WPSeek.com
Creates a new post from the "Write Post" form using $_POST information. WordPress lookup for wp_write_post, a WordPress Function.
wpseek.com - #12498 (wp_write_post() isn't custom post type friendly ...
With customs post types shouldn't wp_write_post() check user permissions for editing all available post types and not just 'post' or 'page'? Eg currently: if ( isset( ...
core.trac.wordpress.org - PHPXRef 0.7 : WordPress : Function Reference: wp_write_post()
Function and Method Cross Reference. wp_write_post(). Defined at: /wp-admin/ includes/post.php -> line 514. Referenced 1 times: /wp-admin/includes/post.php ...
phpxref.ftwr.co.uk - PHPXRef 0.7 : WordPress : Detail view of post.php
wp_write_post() X-Ref. Creates a new post from the "Write Post" form using ... write_post() X-Ref. Calls wp_write_post() and handles the errors. return: unknown ...
phpxref.ftwr.co.uk
