Action and Filter Hook Reference
'; + echo 'This is simply a list of action and filter hooks found within WooCommerce files. View the source to see supported params and usage.
+' . implode( ', ', $index ) . '
+' . $heading . '
' . $heading . '
Hook | Type | File(s) | '; if ( 0 === $( table_selector ).find( '.column-handle' ).length ) { - $( table_selector ).find( 'tr:not(.inline-edit-row)' ).append( ' | ' ); + $( table_selector ).find( 'tr:not(.inline-edit-row)' ).append( column_handle ); term_id_selector = '.check-column input'; } $( table_selector ).find( '.column-handle' ).show(); + $.wc_add_missing_sort_handles = function() { + var all_table_rows = $( table_selector ).find('tbody > tr'); + var rows_with_handle = $( table_selector ).find('tbody > tr > td.column-handle').parent(); + if ( all_table_rows.length !== rows_with_handle.length ) { + all_table_rows.each(function(index, elem){ + if ( ! rows_with_handle.is( elem ) ) { + $( elem ).append( column_handle ); + } + }); + } + $( table_selector ).find( '.column-handle' ).show(); + }; + $( document ).ajaxComplete( function( event, request, options ) { - if ( request && 4 === request.readyState && 200 === request.status && options.data && 0 <= options.data.indexOf( '_inline_edit' ) ) { - $( table_selector ).find( '.column-handle' ).show(); + if ( request && 4 === request.readyState && 200 === request.status && options.data && ( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) ) ) { + $.wc_add_missing_sort_handles(); $( document.body ).trigger( 'init_tooltips' ); } } ); diff --git a/assets/js/admin/term-ordering.min.js b/assets/js/admin/term-ordering.min.js index 21c3f39d20d..0c30a8df2bc 100644 --- a/assets/js/admin/term-ordering.min.js +++ b/assets/js/admin/term-ordering.min.js @@ -1 +1 @@ -jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append(' | '),n=".check-column input"),e(t).find(".column-handle").show(),e(document).ajaxComplete(function(n,i,d){i&&4===i.readyState&&200===i.status&&d.data&&0<=d.data.indexOf("_inline_edit")&&(e(t).find(".column-handle").show(),e(document.body).trigger("init_tooltips"))}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var o,a,l=d.item.find(n).val(),r=d.item.find(".parent").html(),c=d.item.prev().find(n).val(),m=d.item.next().find(n).val();c!==undefined&&(o=d.item.prev().find(".parent").html())!==r&&(c=undefined),m!==undefined&&(a=d.item.next().find(".parent").html())!==r&&(m=undefined),c===undefined&&m===undefined||m===undefined&&a===c||m!==undefined&&o===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append(''),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})}); \ No newline at end of file +jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append(' | '),n=".check-column input"),e(t).find(".column-handle").show(),e.wc_add_missing_sort_handles=function(){var n=e(t).find("tbody > tr"),i=e(t).find("tbody > tr > td.column-handle").parent();n.length!==i.length&&n.each(function(t,n){i.is(n)||e(n).append(' | ')}),e(t).find(".column-handle").show()},e(document).ajaxComplete(function(t,n,i){n&&4===n.readyState&&200===n.status&&i.data&&(0<=i.data.indexOf("_inline_edit")||0<=i.data.indexOf("add-tag"))&&(e.wc_add_missing_sort_handles(),e(document.body).trigger("init_tooltips"))}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var a,o,l=d.item.find(n).val(),c=d.item.find(".parent").html(),r=d.item.prev().find(n).val(),m=d.item.next().find(n).val();r!==undefined&&(a=d.item.prev().find(".parent").html())!==c&&(r=undefined),m!==undefined&&(o=d.item.next().find(".parent").html())!==c&&(m=undefined),r===undefined&&m===undefined||m===undefined&&o===r||m!==undefined&&a===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append(''),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})}); \ No newline at end of file diff --git a/assets/js/admin/wc-setup.js b/assets/js/admin/wc-setup.js index 87416e53469..cf4d7d36bbe 100644 --- a/assets/js/admin/wc-setup.js +++ b/assets/js/admin/wc-setup.js @@ -47,6 +47,8 @@ jQuery( function( $ ) { $( '.store-state-container' ).hide(); $state_select.empty().val( '' ).change().prop( 'required', false ); } + + $( '#currency_code' ).val( wc_setup_currencies[ country ] ).change(); } ); $( '#store_country' ).change(); @@ -108,9 +110,11 @@ jQuery( function( $ ) { $( '.wc-wizard-services' ).on( 'change', '.wc-wizard-shipping-method-enable', function() { var checked = $( this ).is( ':checked' ); + var selectedMethod = $( '.wc-wizard-shipping-method-select .method' ).val(); $( this ) .closest( '.wc-wizard-service-item' ) + .find( '.' + selectedMethod ) .find( '.shipping-method-required-field' ) .prop( 'required', checked ); } ); @@ -172,8 +176,50 @@ jQuery( function( $ ) { } } ).find( 'input#stripe_create_account, input#ppec_paypal_reroute_requests' ).change(); - $( 'select#store_country' ).on( 'change', function() { - var countryCode = $( this ).val(); - $( 'select#currency_code' ).val( wc_setup_currencies[ countryCode ] ).change(); - } ); + function addPlugins( bySlug, $el, hover ) { + var plugins = $el.data( 'plugins' ); + for ( var i in Array.isArray( plugins ) ? plugins : [] ) { + var slug = plugins[ i ].slug; + bySlug[ slug ] = bySlug[ slug ] || + $( '' ) + .append( '' + plugins[ i ].name + '' ); + + bySlug[ slug ].find( 'a' ) + .on( 'mouseenter mouseleave', ( function( $hover, event ) { + $hover.toggleClass( 'plugin-install-source', 'mouseenter' === event.type ); + } ).bind( null, hover ? $el.closest( hover ) : $el ) ); + } + } + + function updatePluginInfo() { + var pluginLinkBySlug = {}; + + $( '.wc-wizard-service-enable input:checked' ).each( function() { + addPlugins( pluginLinkBySlug, $( this ), '.wc-wizard-service-item' ); + + var $container = $( this ).closest( '.wc-wizard-service-item' ); + $container.find( 'input.payment-checkbox-input:checked' ).each( function() { + addPlugins( pluginLinkBySlug, $( this ), '.wc-wizard-service-settings' ); + } ); + $container.find( '.wc-wizard-shipping-method-select .method' ).each( function() { + var $this = $( this ); + if ( 'live_rates' === $this.val() ) { + addPlugins( pluginLinkBySlug, $this, '.wc-wizard-service-item' ); + } + } ); + } ); + + $( '.recommended-item input:checked' ).each( function() { + addPlugins( pluginLinkBySlug, $( this ), '.recommended-item' ); + } ); + + var $list = $( 'span.plugin-install-info-list' ).empty(); + for ( var slug in pluginLinkBySlug ) { + $list.append( pluginLinkBySlug[ slug ] ); + } + $( 'span.plugin-install-info' ).toggle( $list.children().length > 0 ); + } + + updatePluginInfo(); + $( '.wc-setup-content' ).on( 'change', '[data-plugins]', updatePluginInfo ); } ); diff --git a/assets/js/admin/wc-setup.min.js b/assets/js/admin/wc-setup.min.js index ca359dd80dc..355de166648 100644 --- a/assets/js/admin/wc-setup.min.js +++ b/assets/js/admin/wc-setup.min.js @@ -1 +1 @@ -jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function s(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return s();setTimeout(t,3e3)}).fail(function(){s()})}e(".button-next").on("click",function(){var s=e(this).parents("form").get(0);return("function"!=typeof s.checkValidity||s.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").removeClass("hide")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").addClass("hide"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){if(e(i.target).is("input"))i.stopPropagation();else{var s=e(this).find('input[type="checkbox"]');s.prop("checked",!s.prop("checked")).change()}}),e(".wc-wizard-services-list-toggle").on("click",function(){e(this).closest(".wc-wizard-services-list-toggle").toggleClass("closed"),e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var s=e(this).closest(".wc-wizard-service-description"),t=i.target.value,c=s.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+t).removeClass("hide");var r=s.find(".shipping-method-settings");r.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),r.find("."+t).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}).find(".wc-wizard-shipping-method-select .method").change(),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked");e(this).closest(".wc-wizard-service-item").find(".shipping-method-required-field").prop("required",i)}),e(".activate-jetpack").on("click",".button-primary",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()}),e(".wc-wizard-services").on("change","input#stripe_create_account, input#ppec_paypal_reroute_requests",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!0),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").show()):(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!1),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").hide())}).find("input#stripe_create_account, input#ppec_paypal_reroute_requests").change(),e("select#store_country_state").on("change",function(){var i=this.value.split(":")[0];e("select#currency_code").val(wc_setup_currencies[i]).change()})}); \ No newline at end of file +jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function t(){e("form.activate-jetpack").submit()}function s(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return t();setTimeout(s,3e3)}).fail(function(){t()})}function c(i,t,s){var c=t.data("plugins");for(var n in Array.isArray(c)?c:[]){var a=c[n].slug;i[a]=i[a]||e('').append(''+c[n].name+""),i[a].find("a").on("mouseenter mouseleave",function(e,i){e.toggleClass("plugin-install-source","mouseenter"===i.type)}.bind(null,s?t.closest(s):t))}}function n(){var i={};e(".wc-wizard-service-enable input:checked").each(function(){c(i,e(this),".wc-wizard-service-item");var t=e(this).closest(".wc-wizard-service-item");t.find("input.payment-checkbox-input:checked").each(function(){c(i,e(this),".wc-wizard-service-settings")}),t.find(".wc-wizard-shipping-method-select .method").each(function(){var t=e(this);"live_rates"===t.val()&&c(i,t,".wc-wizard-service-item")})}),e(".recommended-item input:checked").each(function(){c(i,e(this),".recommended-item")});var t=e("span.plugin-install-info-list").empty();for(var s in i)t.append(i[s]);e("span.plugin-install-info").toggle(t.children().length>0)}e(".button-next").on("click",function(){var t=e(this).parents("form").get(0);return("function"!=typeof t.checkValidity||t.checkValidity())&&i(),!0}),e("#store_country").on("change",function(){if(null!==wc_setup_params.states){var i=e(this).val(),t=e("#store_state");if(e.isEmptyObject(wc_setup_params.states[i]))e(".store-state-container").hide(),t.empty().val("").change().prop("required",!1);else{var s=wc_setup_params.states[i];t.empty(),e.each(s,function(i){t.append(e('"))}),e(".store-state-container").show(),t.selectWoo().val(wc_base_state).change().prop("required",!0)}e("#currency_code").val(wc_setup_currencies[i]).change()}}),e("#store_country").change(),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").removeClass("hide")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").addClass("hide"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){if(e(i.target).is("input"))i.stopPropagation();else{var t=e(this).find('input[type="checkbox"]');t.prop("checked",!t.prop("checked")).change()}}),e(".wc-wizard-services-list-toggle").on("click",function(){e(this).closest(".wc-wizard-services-list-toggle").toggleClass("closed"),e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var t=e(this).closest(".wc-wizard-service-description"),s=i.target.value,c=t.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+s).removeClass("hide");var n=t.find(".shipping-method-settings");n.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),n.find("."+s).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}).find(".wc-wizard-shipping-method-select .method").change(),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked"),t=e(".wc-wizard-shipping-method-select .method").val();e(this).closest(".wc-wizard-service-item").find("."+t).find(".shipping-method-required-field").prop("required",i)}),e(".activate-jetpack").on("click",".button-primary",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),s()}),e(".wc-wizard-services").on("change","input#stripe_create_account, input#ppec_paypal_reroute_requests",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!0),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").show()):(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!1),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").hide())}).find("input#stripe_create_account, input#ppec_paypal_reroute_requests").change(),n(),e(".wc-setup-content").on("change","[data-plugins]",n)}); \ No newline at end of file diff --git a/assets/js/admin/woocommerce_admin.js b/assets/js/admin/woocommerce_admin.js index 4b8fc509cd6..e0947d75198 100644 --- a/assets/js/admin/woocommerce_admin.js +++ b/assets/js/admin/woocommerce_admin.js @@ -297,4 +297,42 @@ jQuery( function ( $ ) { // Attribute term table $( 'table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' ); + + + // Toggle gateway on/off. + $( '.wc_gateways' ).on( 'click', '.wc-payment-gateway-method-toggle-enabled', function() { + var $link = $( this ), + $row = $link.closest( 'tr' ), + $toggle = $link.find( '.woocommerce-input-toggle' ); + + var data = { + action: 'woocommerce_toggle_gateway_enabled', + security: woocommerce_admin.nonces.gateway_toggle, + gateway_id: $row.data( 'gateway_id' ) + }; + + $toggle.addClass( 'woocommerce-input-toggle--loading' ); + + $.ajax( { + url: woocommerce_admin.ajax_url, + data: data, + dataType : 'json', + type : 'POST', + success: function( response ) { + if ( true === response.data ) { + $toggle.removeClass( 'woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled' ); + $toggle.addClass( 'woocommerce-input-toggle--enabled' ); + $toggle.removeClass( 'woocommerce-input-toggle--loading' ); + } else if ( false === response.data ) { + $toggle.removeClass( 'woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled' ); + $toggle.addClass( 'woocommerce-input-toggle--disabled' ); + $toggle.removeClass( 'woocommerce-input-toggle--loading' ); + } else if ( 'needs_setup' === response.data ) { + window.location.href = $link.attr( 'href' ); + } + } + } ); + + return false; + }); }); diff --git a/assets/js/admin/woocommerce_admin.min.js b/assets/js/admin/woocommerce_admin.min.js index a9e08289e59..e003e0b61b4 100644 --- a/assets/js/admin/woocommerce_admin.min.js +++ b/assets/js/admin/woocommerce_admin.min.js @@ -1 +1 @@ -jQuery(function(e){if("undefined"!=typeof woocommerce_admin){var t=e(".edit-php.post-type-product"),i=t.find(".page-title-action:first");0===t.find(".woocommerce-BlankState").length?(woocommerce_admin.urls.export_products&&i.after(''+woocommerce_admin.strings.export_products+""),woocommerce_admin.urls.import_products&&i.after(''+woocommerce_admin.strings.import_products+"")):i.hide(),e(".woocommerce-progress-form-wrapper .button-next").on("click",function(){return e(".wc-progress-form-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),!0}),e(document.body).on("wc_add_error_tip",function(t,i,o){var n=i.position();0===i.parent().find(".wc_error_tip").length&&(i.after(' |
---|---|---|
- get_tooltip_html( $data ); // WPCS: XSS ok. ?> - + |