Filter hook '_wp_post_revision_field_{$field}'

in WP Core File wp-admin/includes/revision.php at line 93

View Source

_wp_post_revision_field_{$field}

Filter Hook
Description
Contextually filter a post revision field. The dynamic portion of the hook name, `$field`, corresponds to a name of a field of the revision object. Possible hook names include: - `_wp_post_revision_field_post_title` - `_wp_post_revision_field_post_content` - `_wp_post_revision_field_post_excerpt`

Hook Information

File Location wp-admin/includes/revision.php View on GitHub
Hook Type Filter
Line Number 93

Hook Parameters

Type Name Description
string $revision_field The current revision field to compare to or from.
string $field The current revision field.
WP_Post $compare_from The revision post object to compare to or from.
string $context The context of whether the current revision is the old or the new one. Either 'to' or 'from'.

Usage Examples

Basic Usage
<?php
// Hook into _wp_post_revision_field_{$field}
add_filter('_wp_post_revision_field_{$field}', 'my_custom_filter', 10, 4);

function my_custom_filter($revision_field, $field, $compare_from, $context) {
    // Your custom filtering logic here
    return $revision_field;
}

Source Code Context

wp-admin/includes/revision.php:93 - How this hook is used in WordPress core
<?php
  88  		 *                                or the new one. Either 'to' or 'from'.
  89  		 */
  90  		$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_{$field}", $compare_from->$field, $field, $compare_from, 'from' ) : '';
  91  
  92  		/** This filter is documented in wp-admin/includes/revision.php */
  93  		$content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );
  94  
  95  		$args = array(
  96  			'show_split_view' => true,
  97  			'title_left'      => __( 'Removed' ),
  98  			'title_right'     => __( 'Added' ),

PHP Documentation

<?php
/**
		 * Contextually filter a post revision field.
		 *
		 * The dynamic portion of the hook name, `$field`, corresponds to a name of a
		 * field of the revision object.
		 *
		 * Possible hook names include:
		 *
		 *  - `_wp_post_revision_field_post_title`
		 *  - `_wp_post_revision_field_post_content`
		 *  - `_wp_post_revision_field_post_excerpt`
		 *
		 * @since 3.6.0
		 *
		 * @param string  $revision_field The current revision field to compare to or from.
		 * @param string  $field          The current revision field.
		 * @param WP_Post $compare_from   The revision post object to compare to or from.
		 * @param string  $context        The context of whether the current revision is the old
		 *                                or the new one. Either 'to' or 'from'.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-admin/includes/revision.php
Related Hooks

Related hooks will be displayed here in future updates.