_wp_post_revision_fields [ WordPress Function ]
| Access: |
|
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Determines which fields of posts are to be saved in revisions.
Does two things. If passed a post array, it will return a post array ready to be inserted into the posts table as a post revision. Otherwise, returns an array whose keys are the post fields to be saved for post revisions.
Source
<?php
function _wp_post_revision_fields( $post = null, $autosave = false ) {
static $fields = false;
if ( !$fields ) {
// Allow these to be versioned
$fields = array(
'post_title' => __( 'Title' ),
'post_content' => __( 'Content' ),
'post_excerpt' => __( 'Excerpt' ),
);
// Runs only once
$fields = apply_filters( '_wp_post_revision_fields', $fields );
// WP uses these internally either in versioning or elsewhere - they cannot be versioned
foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect )
unset( $fields[$protect] );
}
if ( !is_array($post) )
return $fields;
$return = array();
foreach ( array_intersect( array_keys( $post ), array_keys( $fields ) ) as $field )
$return[$field] = $post[$field];
$return['post_parent'] = $post['ID'];
$return['post_status'] = 'inherit';
$return['post_type'] = 'revision';
$return['post_name'] = $autosave ? "$post[ID]-autosave" : "$post[ID]-revision";
$return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : '';
$return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
return $return;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- _wp_post_revision_fields Wordpress hook details -- Adam Brown ...
_wp_post_revision_fields. WordPress version history for _wp_post_revision_fields. This database has information for all major versions from WP 1.2.1 through ...
adambrown.info - comment_post Wordpress hook details -- Adam Brown, BYU ...
_wp_post_revision_field_{$field} · _wp_post_revision_fields · _wp_put_post_revision · add_meta_boxes_comment · add_meta_boxes_{$ post_type} ...
adambrown.info - #13382 (_wp_post_revision_fields filter is not very useful ...
The _wp_post_revision_fields filter allows plugins to modify which post fields get ... The _wp_post_revision_fields() is also a variation on the getter/setter pattern ...
core.trac.wordpress.org - _wp_post_revision_fields() WordPress function reference ...
Determines which fields of posts are to be saved in revisions.
queryposts.com