Skip to content

Commit

Permalink
Introduces woocommerce_queued_js filter, closes woocommerce#10553
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Mar 14, 2016
1 parent 1b54c00 commit 4e1a3d7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions includes/wc-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,20 @@ function wc_print_js() {
global $wc_queued_js;

if ( ! empty( $wc_queued_js ) ) {

echo "<!-- WooCommerce JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) {";

// Sanitize
// Sanitize.
$wc_queued_js = wp_check_invalid_utf8( $wc_queued_js );
$wc_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wc_queued_js );
$wc_queued_js = str_replace( "\r", '', $wc_queued_js );

echo $wc_queued_js . "});\n</script>\n";
$js = "<!-- WooCommerce JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) { $wc_queued_js });\n</script>\n";

/**
* woocommerce_queued_js filter.
*
* @since 2.6.0
* @param string $js JavaScript code.
*/
echo apply_filters( 'woocommerce_queued_js', $js );

unset( $wc_queued_js );
}
Expand Down

0 comments on commit 4e1a3d7

Please sign in to comment.