124 | \__( 'Title', 'duplicate-post' ),
127 | 'post_content' => \__( 'Content', 'duplicate-post' ),
128 | 'post_excerpt' => \__( 'Excerpt', 'duplicate-post' ),
129 | ];
130 |
131 | $args = [
132 | 'show_split_view' => true,
133 | 'title_left' => \__( 'Removed', 'duplicate-post' ),
134 | 'title_right' => \__( 'Added', 'duplicate-post' ),
135 | ];
136 |
137 | if ( \version_compare( $wp_version, '5.7' ) < 0 ) {
138 | unset( $args['title_left'] );
139 | unset( $args['title_right'] );
140 | }
141 |
142 | $post_array = \get_post( $this->post, \ARRAY_A );
143 |
144 | /** This filter is documented in wp-admin/includes/revision.php */
145 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reason: using WP core hook.
146 | $fields = \apply_filters( '_wp_post_revision_fields', $fields, $post_array );
147 |
148 | foreach ( $fields as $field => $name ) {
149 | /** This filter is documented in wp-admin/includes/revision.php */
150 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reason: using WP core hook.
151 | $content_from = \apply_filters( "_wp_post_revision_field_{$field}", $this->original->$field, $field, $this->original, 'from' );
152 |
153 | /** This filter is documented in wp-admin/includes/revision.php */
154 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reason: using WP core hook.
155 | $content_to = \apply_filters( "_wp_post_revision_field_{$field}", $this->post->$field, $field, $this->post, 'to' );
156 |
157 | $diff = \wp_text_diff( $content_from, $content_to, $args );
158 |
159 | if ( ! $diff && $field === 'post_title' ) {
160 | // It's a better user experience to still show the Title, even if it didn't change.
161 | $diff = '
';
162 | $diff .= '' . \esc_html( $this->original->post_title ) . ' | | ' . \esc_html( $this->post->post_title ) . ' | ';
163 | $diff .= '
';
164 | $diff .= '
';
165 | }
166 |
167 | if ( $diff ) {
168 | ?>
169 |
170 |
175 |
176 |