wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
edit_post [ WordPress Function ]
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
Update an existing post with values provided in $_POST.
Source
<?php
function edit_post( $post_data = null ) {
if ( empty($post_data) )
$post_data = &$_POST;
// Clear out any data in internal vars.
unset( $post_data['filter'] );
$post_ID = (int) $post_data['post_ID'];
$post = get_post( $post_ID );
$post_data['post_type'] = $post->post_type;
$post_data['post_mime_type'] = $post->post_mime_type;
$ptype = get_post_type_object($post_data['post_type']);
if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
if ( 'page' == $post_data['post_type'] )
wp_die( __('You are not allowed to edit this page.' ));
else
wp_die( __('You are not allowed to edit this post.' ));
}
// Autosave shouldn't save too soon after a real save
if ( 'autosave' == $post_data['action'] ) {
$post =& get_post( $post_ID );
$now = time();
$then = strtotime($post->post_date_gmt . ' +0000');
$delta = AUTOSAVE_INTERVAL / 2;
if ( ($now - $then) < $delta )
return $post_ID;
}
$post_data = _wp_translate_postdata( true, $post_data );
if ( is_wp_error($post_data) )
wp_die( $post_data->get_error_message() );
if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] )
$post_data['post_status'] = 'draft';
if ( isset($post_data['visibility']) ) {
switch ( $post_data['visibility'] ) {
case 'public' :
$post_data['post_password'] = '';
break;
case 'password' :
unset( $post_data['sticky'] );
break;
case 'private' :
$post_data['post_status'] = 'private';
$post_data['post_password'] = '';
unset( $post_data['sticky'] );
break;
}
}
// Post Formats
if ( isset( $post_data['post_format'] ) ) {
if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) )
set_post_format( $post_ID, $post_data['post_format'] );
elseif ( '0' == $post_data['post_format'] )
set_post_format( $post_ID, false );
}
// Meta Stuff
if ( isset($post_data['meta']) && $post_data['meta'] ) {
foreach ( $post_data['meta'] as $key => $value ) {
if ( !$meta = get_post_meta_by_id( $key ) )
continue;
if ( $meta->post_id != $post_ID )
continue;
if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
continue;
update_meta( $key, $value['key'], $value['value'] );
}
}
if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
foreach ( $post_data['deletemeta'] as $key => $value ) {
if ( !$meta = get_post_meta_by_id( $key ) )
continue;
if ( $meta->post_id != $post_ID )
continue;
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
continue;
delete_meta( $key );
}
}
add_meta( $post_ID );
update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
wp_update_post( $post_data );
// Now that we have an ID we can fix any attachment anchor hrefs
_fix_attachment_links( $post_ID );
wp_set_post_lock( $post_ID );
if ( current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( ! empty( $post_data['sticky'] ) )
stick_post( $post_ID );
else
unstick_post( $post_ID );
}
return $post_ID;
}
?>
Beispiele [ wp-snippets.com ]
Top Google Suchergebnisse
- edit_post Wordpress hook details -- Adam Brown, BYU Political ...
WordPress hook directory edit_post. Description. Runs when a post or page is updated/edited, including when a comment is added or updated (which causes ...
adambrown.info - edit_post | Mark on WordPress
Jan 28, 2007 ... The issue occurs because the plugins assume that every time edit_post is triggered, their inserted form field will be included in $_POST .
markjaquith.wordpress.com - WordPress › Support » Tags — edit_post
Password (forgot?) Register · WordPress › Support » edit_post ...
wordpress.org - Function_Reference/edit_post" - WordPress Codex
Description. Update an existing post with values provided in $_POST. If you passed the post data in an argument, that argument is treated as an array of data ...
codex.wordpress.org
Nutzerduskussionen [ wordpress.org ]
- snails07 on "Changing post_meta based on other posts post_meta"
- Fire Truck on "Changing post_meta based on other posts post_meta"
- snails07 on "Changing post_meta based on other posts post_meta"
- Fire Truck on "Changing post_meta based on other posts post_meta"
- zimmi88 on "Changing post_meta based on other posts post_meta"
- snails07 on "Changing post_meta based on other posts post_meta"
- jtarleton on "edit_post hook"
- ancawonka on "How do I edit the "message" that's displayed on the "edit post" screen?"
- vikingjs on "Allow users to edit own comments in other's posts"
- vikingjs on "Subscriber edit own comments but not create posts?"