Files
WPS3Media/assets/js/pro/integrations/woocommerce.js
Malin 3248cbb029 feat: add S3-compatible storage provider (MinIO, Ceph, R2, etc.)
Adds a new 'S3-Compatible Storage' provider that works with any
S3-API-compatible object storage service, including MinIO, Ceph,
Cloudflare R2, Backblaze B2, and others.

Changes:
- New provider class: classes/providers/storage/s3-compatible-provider.php
  - Provider key: s3compatible
  - Reads user-configured endpoint URL from settings
  - Uses path-style URL access (required by most S3-compatible services)
  - Supports credentials via AS3CF_S3COMPAT_ACCESS_KEY_ID /
    AS3CF_S3COMPAT_SECRET_ACCESS_KEY wp-config.php constants
  - Disables AWS-specific features (Block Public Access, Object Ownership)
- New provider SVG icons (s3compatible.svg, -link.svg, -round.svg)
- Registered provider in main plugin class with endpoint setting support
- Updated StorageProviderSubPage to show endpoint URL input for S3-compatible
- Built pro settings bundle with rollup (Svelte 4.2.19)
- Added package.json and updated rollup.config.mjs for pro-only builds
2026-03-03 12:30:18 +01:00

77 lines
2.0 KiB
JavaScript

(function( $, _ ) {
var fileFrame;
var attachment;
var fileNameInput;
var fileUrlInput;
var fileNamePlaceholder;
var fileUrlPlaceholder;
/**
* Render custom media uploader
*
* @param row Object
*
* @return void
*/
function renderMediaUploader( row ) {
// Find the correct file name and url inputs
fileNameInput = row.find( 'td.file_name input.input_text' );
fileUrlInput = row.find( 'td.file_url input.input_text' );
// Use existing file frame instance or create one
if ( undefined !== fileFrame ) {
fileFrame.open();
return;
}
fileFrame = wp.media.frames.file_frame = wp.media( {
title: as3cf_woo.strings.media_modal_title,
button: {
text: as3cf_woo.strings.media_modal_button
},
states: [
new wp.media.controller.Library( {
title: as3cf_woo.strings.media_modal_title,
filterable: 'all',
multiple: false
} )
]
} );
// Handle file selection
fileFrame.on( 'select', function() {
attachment = fileFrame.state().get( 'selection' ).first().toJSON();
fileNamePlaceholder = fileNameInput.attr( 'placeholder' );
fileUrlPlaceholder = fileUrlInput.attr( 'placeholder' );
fileNameInput.val( attachment.title ).attr( 'placeholder', fileNamePlaceholder ).trigger( 'change' );
fileUrlInput.val( attachment.url ).attr( 'placeholder', fileUrlPlaceholder ).trigger( 'change' );
} );
// Ensure files are uploaded to the woocommerce_uploads directory
fileFrame.on( 'ready', function() {
fileFrame.uploader.options.uploader.params = {
type: 'downloadable_product'
};
} );
fileFrame.open();
}
// Replace WooCommerce upload file click handler
$( document ).ready( function() {
$( document ).off( 'click', '.upload_file_button' );
$( document.body ).off( 'click', '.upload_file_button' ); // WooCommerce 2.4+
$( document ).on( 'click', '.upload_file_button', function( e ) {
var row = $( this ).closest( 'tr' );
e.preventDefault();
renderMediaUploader( row );
} );
} );
})( jQuery, _ );