-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Woo
committed
Apr 23, 2024
1 parent
3533182
commit 954d7ff
Showing
68 changed files
with
23,104 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
jQuery( function( $ ) { | ||
|
||
'use strict'; | ||
|
||
/* global confirm, wc_product_documents_admin_params */ | ||
|
||
// Open/close | ||
$( '#wc-product-documents-data .wc-metaboxes-wrapper' ) | ||
.on( 'click', '.expand_all', function() { | ||
$( this ).closest('.wc-metaboxes-wrapper').find( '.wc-metabox > .wc-metabox-content' ).show(); | ||
return false; | ||
} ) | ||
.on( 'click', '.close_all', function(){ | ||
$( this ).closest( '.wc-metaboxes-wrapper' ).find( '.wc-metabox > .wc-metabox-content' ).hide(); | ||
return false; | ||
} ); | ||
|
||
|
||
$( '#wc-product-documents-data' ) | ||
// add a new document section | ||
.on( 'click', '.add-new-product-documents-section', function() { | ||
|
||
var index = -1; | ||
|
||
// find the largest current section index (if any) | ||
$( '.wc-product-documents-sections .wc-product-documents-section .product-documents-section-index' ).each( function() { | ||
var value = parseInt( $( this ).val(), 10 ); | ||
index = ( value > index ) ? value : index; | ||
} ); | ||
|
||
index++; | ||
|
||
var html = wc_product_documents_admin_params.new_section.replace( /{index}/g, index ); | ||
|
||
$( '.wc-product-documents-sections' ).append( html ); | ||
updateDocumentSectionRowIndexes(); | ||
setDefaultDocumentSection(); | ||
|
||
return false; | ||
} ) | ||
// remove a document section | ||
.on( 'click', '.remove-wc-product-documents-section', function() { | ||
|
||
var answer = confirm( wc_product_documents_admin_params.confirm_remove_section_text ); | ||
|
||
if ( answer ) { | ||
var section = $( this ).closest( '.wc-product-documents-section' ); | ||
$( section ).remove(); | ||
|
||
updateDocumentSectionRowIndexes(); | ||
setDefaultDocumentSection(); | ||
} | ||
|
||
return false; | ||
} ); | ||
|
||
|
||
// Make the document sections sortable | ||
$( '.wc-product-documents-sections' ).sortable( { | ||
items: '.wc-product-documents-section', | ||
cursor: 'move', | ||
axis: 'y', | ||
handle: 'h3', | ||
scrollSensitivity: 40, | ||
helper: function( e, ui ) { | ||
return ui; | ||
}, | ||
start: function( event, ui ) { | ||
ui.item.css( 'border-style', 'dashed' ); | ||
}, | ||
stop: function( event, ui ) { | ||
ui.item.removeAttr( 'style' ); | ||
updateDocumentSectionRowIndexes(); | ||
} | ||
} ); | ||
|
||
|
||
// update the product tab indexes, based on the current section ordering | ||
function updateDocumentSectionRowIndexes() { | ||
$( '.wc-product-documents-sections .wc-product-documents-section' ).each( | ||
function( index, el ) { | ||
$( '.product-documents-section-position', el ).val( parseInt( $( el ).index( '.wc-product-documents-sections .wc-product-documents-section' ), 10 ) ); | ||
} | ||
); | ||
} | ||
|
||
|
||
// ensure a default is set | ||
function setDefaultDocumentSection() { | ||
var $radios = $( 'input:radio[name=product_documents_default_section]' ); | ||
|
||
if ( $radios.is( ':checked' ) === false ) { | ||
$radios.filter( '[value=0]' ).prop( 'checked', true ); | ||
} | ||
} | ||
|
||
|
||
/* Documents Handling */ | ||
|
||
|
||
$( '#wc-product-documents-data' ) | ||
// add a new document row | ||
.on( 'click', '.wc-product-documents-add-document', function() { | ||
|
||
var $parentSection = $( this ).closest( '.wc-product-documents-section' ); | ||
var index = $( '.product-documents-section-index', $parentSection ).val(); | ||
|
||
var subIndex = -1; | ||
|
||
// find the largest current section index (if any) | ||
$( '.wc-product-document .wc-product-document-sub-index', $parentSection ).each( function() { | ||
var value = parseInt( $( this ).val(), 10 ); | ||
subIndex = ( value > subIndex ) ? value : subIndex; | ||
} ); | ||
|
||
subIndex++; | ||
|
||
var html = wc_product_documents_admin_params.new_document.replace( /{index}/g, index ).replace( /{sub_index}/g, subIndex ); | ||
|
||
$( this ).closest( '.wc-product-documents' ).append( html ); | ||
updateDocumentRowIndexes( $parentSection ); | ||
setAttachFileHandler(); | ||
|
||
return false; | ||
} ) | ||
// remove a document | ||
.on( 'click', '.wc-product-documents-remove-document', function() { | ||
|
||
var answer = confirm( wc_product_documents_admin_params.confirm_remove_document_text ); | ||
|
||
if ( answer ) { | ||
var $parentSection = $( this ).closest( '.wc-product-documents-section' ); | ||
var $documentRow = $( this ).closest( '.wc-product-document' ); | ||
$documentRow.remove(); | ||
|
||
updateDocumentRowIndexes( $parentSection ); | ||
} | ||
|
||
return false; | ||
} ); | ||
|
||
|
||
// product document ordering | ||
$( 'table.wc-product-documents tbody' ).sortable( { | ||
items : 'tr', | ||
cursor : 'move', | ||
axis : 'y', | ||
handle : 'td', | ||
scrollSensitivity : 40, | ||
helper: function( e, ui ) { | ||
return ui; | ||
}, | ||
start: function( event, ui ) { | ||
ui.item.css( 'background-color','#f6f6f6' ); | ||
}, | ||
stop: function( event, ui ) { | ||
ui.item.removeAttr( 'style' ); | ||
updateDocumentRowIndexes(); | ||
} | ||
} ); | ||
|
||
|
||
// update the product document table row positions, based on the current ordering | ||
function updateDocumentRowIndexes( $section ) { | ||
$( '.wc-product-documents .wc-product-document', $section ).each( | ||
function( index, el ) { | ||
$( '.wc-product-document-position', el ).val( parseInt( $( el ).index( '.wc-product-documents .wc-product-document' ), 10 ) ); | ||
} | ||
); | ||
} | ||
|
||
|
||
/* File Upload */ | ||
|
||
var file_frame; | ||
var $currentDocumentRow; | ||
|
||
/** | ||
* Add handlers to the "Select a File" inputs, to launch the media browser | ||
*/ | ||
function setAttachFileHandler() { | ||
|
||
$( '#wc-product-documents-data .wc-product-documents-set-file' ).on( 'click', function( event ) { | ||
|
||
event.preventDefault(); | ||
|
||
// save the element that was clicked on so we can set the image | ||
$currentDocumentRow = $( event.target ).closest( 'tr' ); | ||
|
||
// If the media frame already exists, reopen it. | ||
if ( file_frame ) { | ||
file_frame.open(); | ||
return; | ||
} | ||
|
||
// Create the media frame. | ||
file_frame = wp.media.frames.file_frame = wp.media( { | ||
title: wc_product_documents_admin_params.select_file_text, | ||
button: { | ||
text: wc_product_documents_admin_params.set_file_text | ||
}, | ||
multiple: false | ||
} ); | ||
|
||
// When an image is selected, run a callback. | ||
file_frame.on( 'select', function() { | ||
// We set multiple to false so only get one image from the uploader | ||
var attachment = file_frame.state().get( 'selection' ).first().toJSON(); | ||
|
||
// Set the file id/display the file url | ||
$( 'input.wc-product-document-file-location', $currentDocumentRow ).val( attachment.url ); | ||
}); | ||
|
||
// Finally, open the modal | ||
file_frame.open(); | ||
}); | ||
} | ||
|
||
// Initialize | ||
setAttachFileHandler(); | ||
|
||
} ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
*** WooCommerce Product Documents Changelog *** | ||
|
||
2024.02.05 - version 1.15.1 | ||
* Fix - Prevent shortcodes from outputting data for products that should not be accessible to the current user | ||
|
||
2023.06.29 - version 1.15.0 | ||
* Misc - Add compatibility for WooCommerce High Performance Order Storage (HPOS) | ||
|
||
2022.11.30 - version 1.14.0 | ||
* Misc - Require PHP 7.4 and WordPress 5.6 | ||
|
||
2022.08.16 - version 1.13.1 | ||
* Fix - Replace deprecated `is_ajax()` function calls with `wp_doing_ajax()` | ||
* Misc - Require WooCommerce 3.9.4 or newer | ||
|
||
2020.12.07 - version 1.13.0 | ||
* Misc - Add compatibility for WooCommerce 4.7 | ||
* Misc - Require PHP 7.0 or newer | ||
|
||
2020.09.30 - version 1.12.1 | ||
* Misc - Remove the SkyVerge help menu item as part of the plugin assets | ||
|
||
2020.08.17 - version 1.12.0 | ||
* Misc - Add SkyVerge help menu for support on WooCommerce.com connected sites | ||
|
||
2020.05.04 - version 1.11.3 | ||
* Misc - Add support for WooCommerce 4.1 | ||
|
||
2020.03.04 - version 1.11.2 | ||
* Misc - Add support for WooCommerce 4.0 | ||
|
||
2020.01.02 - version 1.11.1 | ||
* Misc - Add support for WooCommerce 3.9 | ||
|
||
2019.10.30 - version 1.11.0 | ||
* Misc - Add support for WooCommerce 3.8 | ||
* Localization - Add Italian translation | ||
|
||
2019.08.14 - version 1.10.0 | ||
* Misc - Add support for WooCommerce 3.7 | ||
* Misc - Remove support for WooCommerce 2.6 | ||
* Misc - Require PHP 5.6+ | ||
|
||
2019.06.27 - version 1.9.2 | ||
* Fix - Do not add escape quotes in document name and label each time the product is saved | ||
|
||
2019.04.24 - version 1.9.1 | ||
* Misc - Add support for WooCommerce 3.6 | ||
* Misc - Require PHP 5.4+ | ||
|
||
2019.02.12 - version 1.9.0 | ||
* Fix - When using a single or double quote in a Product Documents Title field, make sure the text is unescaped for display purposes | ||
* Misc - Drop support for PHP v5.2: PHP v5.3 is now the minimum supported version | ||
* Misc - Update SkyVerge plugin framework to version 5.3 | ||
|
||
2018.10.23 - version 1.8.3 | ||
* Misc - Add support for WooCommerce 3.5 | ||
|
||
2018.07.11 - version 1.8.2 | ||
* Fix - Replace use of jQuery `$.live()` function with `$.on()` | ||
|
||
2018.05.23 - version 1.8.1 | ||
* Misc - Add support for WooCommerce 3.4 | ||
|
||
2018.01.23 - version 1.8.0 | ||
* Misc - Add support for WooCommerce 3.3 | ||
* Misc - Remove support for WooCommerce 2.5 | ||
|
||
2017.10.04 - version 1.7.1 | ||
* Fix - Ensure document sections always have a default set | ||
|
||
2017.03.28 - version 1.7.0 | ||
* Misc - Added support for WooCommerce 3.0 | ||
* Misc - Removed support for WooCommerce 2.4 | ||
|
||
2016.06.02 - version 1.6.0 | ||
* Misc - Added support for WooCommerce 2.6 | ||
* Misc - Removed support for WooCommerce 2.3 | ||
|
||
2016.01.14 - version 1.5.0 | ||
* Misc - Added support for WooCommerce 2.5 | ||
* Misc - Removed support for WooCommerce 2.2 | ||
|
||
2015.07.28 - version 1.4.0 | ||
* Misc - WooCommerce 2.4 Compatibility | ||
|
||
2015.05.21 - version 1.3.1 | ||
* Fix - Settings are now properly installed when the plugin is first activated | ||
|
||
2015.02.09 - version 1.3.0 | ||
* Misc - WooCommerce 2.3 Compatibility | ||
|
||
2014.10.21 - version 1.2.0 | ||
* Feature - New [woocommerce_product_documents_list] shortcode to list all products and their associated documents | ||
|
||
2014.09.07 - version 1.1.3 | ||
* Misc - WooCommerce 2.2 Compatibility | ||
|
||
2014.08.19 - version 1.1.2 | ||
* Fix - Fix a bug with [woocommerce_product_documents] shortcode on non-product pages | ||
|
||
2014.02.24 - version 1.1.1 | ||
* Fix - WooCommerce 2.1 Compatibility fix | ||
|
||
2014.01.20 - version 1.1 | ||
* Misc - WooCommerce 2.1 Compatibility | ||
* Misc - Uses SkyVerge Plugin Framework | ||
* Localization - Text domain changed from `wc-product-documents` to `woocommerce-product-documents` | ||
|
||
2013.12.13 - version 1.0.1 | ||
* Tweak - Added wc_product_documents_link_target filter to control how document links are opened | ||
|
||
2013.08.21 - version 1.0 | ||
* Initial Release |
Oops, something went wrong.