\__( 'Title', 'duplicate-post' ),
'post_content' => \__( 'Content', 'duplicate-post' ),
'post_excerpt' => \__( 'Excerpt', 'duplicate-post' ),
];
$args = [
'show_split_view' => true,
'title_left' => \__( 'Removed', 'duplicate-post' ),
'title_right' => \__( 'Added', 'duplicate-post' ),
];
if ( \version_compare( $wp_version, '5.7' ) < 0 ) {
unset( $args['title_left'] );
unset( $args['title_right'] );
}
$post_array = \get_post( $this->post, \ARRAY_A );
/** This filter is documented in wp-admin/includes/revision.php */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reason: using WP core hook.
$fields = \apply_filters( '_wp_post_revision_fields', $fields, $post_array );
foreach ( $fields as $field => $name ) {
/** This filter is documented in wp-admin/includes/revision.php */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reason: using WP core hook.
$content_from = \apply_filters( "_wp_post_revision_field_{$field}", $this->original->$field, $field, $this->original, 'from' );
/** This filter is documented in wp-admin/includes/revision.php */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reason: using WP core hook.
$content_to = \apply_filters( "_wp_post_revision_field_{$field}", $this->post->$field, $field, $this->post, 'to' );
$diff = \wp_text_diff( $content_from, $content_to, $args );
if ( ! $diff && $field === 'post_title' ) {
// It's a better user experience to still show the Title, even if it didn't change.
$diff = '
';
$diff .= '' . \esc_html( $this->original->post_title ) . ' | | ' . \esc_html( $this->post->post_title ) . ' | ';
$diff .= '
';
$diff .= '
';
}
if ( $diff ) {
?>