Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Comment on lines
+402
to
+461
| public function enqueue_revisions_assets( $hook_suffix ) { | ||
| // Check if we're on the revision screen or document edit screen. | ||
| if ( 'revision.php' !== $hook_suffix && 'post.php' !== $hook_suffix ) { | ||
| return; | ||
| } | ||
|
|
||
| // On post.php, only load for our post type. | ||
| if ( 'post.php' === $hook_suffix ) { | ||
| $screen = get_current_screen(); | ||
| if ( ! $screen || 'documentate_document' !== $screen->post_type ) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| // For revision.php, check if it's a revision of our post type. | ||
| if ( 'revision.php' === $hook_suffix ) { | ||
| $revision_id = isset( $_GET['revision'] ) ? intval( $_GET['revision'] ) : 0; | ||
| if ( $revision_id > 0 ) { | ||
| $revision = wp_get_post_revision( $revision_id ); | ||
| if ( $revision ) { | ||
| $parent = get_post( $revision->post_parent ); | ||
| if ( ! $parent || 'documentate_document' !== $parent->post_type ) { | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Enqueue CSS (dashicons dependency for icons). | ||
| wp_enqueue_style( | ||
| 'documentate-revisions', | ||
| plugin_dir_url( __FILE__ ) . 'css/documentate-revisions.css', | ||
| array( 'dashicons' ), | ||
| $this->version | ||
| ); | ||
|
|
||
| // Enqueue JavaScript. | ||
| wp_enqueue_script( | ||
| 'documentate-revisions', | ||
| plugin_dir_url( __FILE__ ) . 'js/documentate-revisions.js', | ||
| array(), | ||
| $this->version, | ||
| true | ||
| ); | ||
|
|
||
| // Get field labels for the current document type. | ||
| $field_labels = $this->get_revision_field_labels(); | ||
|
|
||
| // Pass data to JavaScript. | ||
| wp_localize_script( | ||
| 'documentate-revisions', | ||
| 'documentateRevisions', | ||
| array( | ||
| 'fieldLabels' => $field_labels, | ||
| 'strings' => array( | ||
| 'fieldContent' => __( 'Contenido del campo ↓', 'documentate' ), | ||
| ), | ||
| ) | ||
| ); | ||
| } |
Check warning
Code scanning / PHPMD
Code Size Rules: CyclomaticComplexity Warning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new enhancement for the WordPress revisions comparison screen in the Documentate plugin. The main goal is to improve the readability of revision diffs for custom document types by replacing raw HTML comment markers with styled, human-readable field section headers and separators. The implementation includes new PHP logic for asset loading and label mapping, a dedicated CSS file for visual styling, and a JavaScript module for dynamic content transformation.
Revision Diff View Enhancement
enqueue_revisions_assetsmethod toclass-documentate-admin.php, which conditionally loads new CSS and JavaScript assets for the revision and document edit screens, and passes field label data to the frontend. Also includes helper methods to retrieve field labels from the document type schema.Frontend Styling and Functionality
documentate-revisions.cssto provide visually distinct section headers, separators, and improved diff highlighting for added/removed content, with support for dark mode, high contrast, and responsive layouts.documentate-revisions.js, which scans revision diff tables for custom field markers, replaces them with styled headers and separators, and updates dynamically as users interact with the revision slider or page controls.