Skip to content

Feature: Media revisions #11

Merged
up1512001 merged 6 commits intomainfrom
chore/media-revisions
Dec 3, 2025
Merged

Feature: Media revisions #11
up1512001 merged 6 commits intomainfrom
chore/media-revisions

Conversation

@up1512001
Copy link
Member

up1512001 and others added 2 commits November 27, 2025 10:39
moving all internal private repo development to public repo
Co-authored-by: AhmarZaidi <ahmarzaidi07@gmail.com>
@up1512001 up1512001 self-assigned this Nov 27, 2025
@up1512001 up1512001 marked this pull request as ready for review November 27, 2025 11:19
Copilot AI review requested due to automatic review settings November 27, 2025 11:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a media revisions system that allows tracking and restoring previous versions of synced media files. The implementation includes backend version management, health checks for connected brand sites before updates, REST API endpoints for version operations, and a React-based UI for version selection and restoration. The changes span PHP backend logic for version tracking and site connectivity validation, JavaScript/React components for the user interface, and CSS styling for the new version management modal.

  • Backend: Version tracking metadata, health check utilities, refactored admin handlers for replace/restore operations
  • Frontend: New VersionModal component, updated browser uploader with connectivity checks, API functions for version management
  • Infrastructure: New REST endpoints, database cleanup updates, snackbar notifications for error handling

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
uninstall.php Added cleanup for onemedia_sync_versions postmeta on plugin uninstall
languages/OneMedia.pot Updated translation file with new strings for version management and error messages
inc/classes/rest/class-media-sharing.php Added sync-attachment-versions endpoint, replaced html_entity_decode with Utils::decode_filename, added revision field to media response
inc/classes/rest/class-basic-options.php Added check-sites-connected endpoint for validating brand site connectivity
inc/classes/plugin-configs/class-constants.php Added ONEMEDIA_SYNC_VERSIONS_POSTMETA_KEY constant
inc/classes/class-utils.php Added version tracking functions, health check for attachment brand sites, filename decoding utility
inc/classes/class-hooks.php Added pre-update hooks to prevent attachment updates when sites are unreachable, refactored to use Utils::get_brand_site_api_key
inc/classes/class-assets.php Added uploadNonce and allowedMimeTypes to localized script data
inc/classes/class-admin.php Refactored media replacement to support version restore, added version history management, caching for sync status
inc/classes/brand-site/class-admin-hooks.php Fixed error message capitalization and response code
assets/src/js/utils.js Added showSnackbarNotice and formatLastUsedDate utility functions
assets/src/js/media-frame.js Added isSyncAttachment function to check sync status from Backbone model, snackbar notice component, AJAX error interceptor
assets/src/css/main.scss Added styles for version button and version modal
assets/src/css/admin.scss Updated snackbar z-index and added selector for snackbar container
assets/src/components/governing-settings/VersionModal.js New component for displaying and selecting media versions to restore
assets/src/components/governing-settings/SiteModal.js Added __nextHasNoMarginBottom prop to TextControl
assets/src/components/constants.js Refactored to consolidate settings exports and move constants to top-level
assets/src/components/api.js Added checkIfAllSitesConnected and fetchSyncAttachmentVersions API functions
assets/src/admin/media-sharing/versionIcon.js New icon component for version button
assets/src/admin/media-sharing/index.js Integrated version modal, added version icon button, health check before operations
assets/src/admin/media-sharing/browser-uploader.js Added health checks before media conversion and replacement operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@up1512001 up1512001 requested a review from justlevine November 27, 2025 17:14
Copy link
Collaborator

@justlevine justlevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to only flag the things I thought we'd be unlikely to catch/invalidate after the upcoming codesharing - or more importantly would make that effort harder -, so if there's things you think are beyond the scope, we can punt.

'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_rest' ),
'restUrl' => esc_url( home_url( '/wp-json/' . Constants::NAMESPACE ) ),
'uploadNonce' => wp_create_nonce( 'onemedia_upload_media' ),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the value of having a separate none from wp_rest ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one is for ajax upload & second is for rest but wp_rest can be used for both which we can do in refactor may be or currently, your call...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's in use and would take time to detangle, we can leave it as is.

Co-authored-by: Dovid Levine <david@axepress.dev>
Copy link
Collaborator

@justlevine justlevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last 3 open comments also seem preexisting to mediasync, deferring to you

@up1512001
Copy link
Member Author

@justlevine we can review them in upcoming code refactoring.

@up1512001 up1512001 merged commit 2178eed into main Dec 3, 2025
5 checks passed
@up1512001 up1512001 deleted the chore/media-revisions branch December 18, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Media Versioning Support in OneMedia Plugin

2 participants

Comments