diff --git a/admin/post-types/shop_coupon.php b/admin/post-types/shop_coupon.php
index 1c9e53c0c7c..7f351de1253 100644
--- a/admin/post-types/shop_coupon.php
+++ b/admin/post-types/shop_coupon.php
@@ -162,7 +162,7 @@ function woocommerce_restrict_manage_coupons() {
add_inline_js( "
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js( "
jQuery('select#dropdown_shop_coupon_type, select[name=m]').css('width', '150px').chosen();
" );
}
diff --git a/admin/post-types/shop_order.php b/admin/post-types/shop_order.php
index 802d57e48c1..c8427312d39 100644
--- a/admin/post-types/shop_order.php
+++ b/admin/post-types/shop_order.php
@@ -310,7 +310,7 @@ function woocommerce_restrict_manage_orders() {
add_inline_js( "
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js( "
jQuery('select#dropdown_shop_order_status, select[name=m]').css('width', '150px').chosen();
diff --git a/admin/post-types/writepanels/writepanel-order_data.php b/admin/post-types/writepanels/writepanel-order_data.php
index a36ee8a979c..a696a04480d 100644
--- a/admin/post-types/writepanels/writepanel-order_data.php
+++ b/admin/post-types/writepanels/writepanel-order_data.php
@@ -101,7 +101,7 @@ function woocommerce_order_data_meta_box($post) {
add_inline_js( "
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js( "
jQuery('select.ajax_chosen_select_customer').ajaxChosen({
method: 'GET',
url: '" . admin_url('admin-ajax.php') . "',
diff --git a/admin/post-types/writepanels/writepanel-order_downloads.php b/admin/post-types/writepanels/writepanel-order_downloads.php
index 0d532279cf7..9c4d0fd5351 100644
--- a/admin/post-types/writepanels/writepanel-order_downloads.php
+++ b/admin/post-types/writepanels/writepanel-order_downloads.php
@@ -184,7 +184,7 @@ function woocommerce_order_downloads_meta_box() {
});
add_inline_js( $javascript );
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js( $javascript );
}
diff --git a/admin/post-types/writepanels/writepanel-product-type-variable.php b/admin/post-types/writepanels/writepanel-product-type-variable.php
index 326a185f1b5..89479f09cd7 100755
--- a/admin/post-types/writepanels/writepanel-product-type-variable.php
+++ b/admin/post-types/writepanels/writepanel-product-type-variable.php
@@ -616,7 +616,7 @@ function variable_product_type_options() {
});
add_inline_js( $javascript );
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js( $javascript );
}
add_action('woocommerce_product_write_panels', 'variable_product_type_options');
diff --git a/classes/abstracts/abstract-wc-email.php b/classes/abstracts/abstract-wc-email.php
index abf86b122b5..df35d92c13e 100644
--- a/classes/abstracts/abstract-wc-email.php
+++ b/classes/abstracts/abstract-wc-email.php
@@ -631,7 +631,7 @@ abstract class WC_Email extends WC_Settings_API {
?>
add_inline_js("
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js("
jQuery('select.email_type').change(function(){
var val = jQuery( this ).val();
diff --git a/classes/gateways/paypal/class-wc-gateway-paypal.php b/classes/gateways/paypal/class-wc-gateway-paypal.php
index c69c394ee25..85898bc2fe6 100644
--- a/classes/gateways/paypal/class-wc-gateway-paypal.php
+++ b/classes/gateways/paypal/class-wc-gateway-paypal.php
@@ -422,7 +422,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
$paypal_args_array[] = '';
}
- $woocommerce->add_inline_js( '
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js( '
$.blockUI({
message: "' . esc_js( __( 'Thank you for your order. We are now redirecting you to PayPal to make payment.', 'woocommerce' ) ) . '",
baseZ: 99999,
diff --git a/classes/helpers/class-wc-inline-javascript-helper.php b/classes/helpers/class-wc-inline-javascript-helper.php
new file mode 100644
index 00000000000..6ae586c771e
--- /dev/null
+++ b/classes/helpers/class-wc-inline-javascript-helper.php
@@ -0,0 +1,43 @@
+_inline_js .= "\n" . $code . "\n";
+ }
+
+ /**
+ * Output any queued inline JS.
+ *
+ * @access public
+ * @return void
+ */
+ public function output_inline_js() {
+ if ( $this->_inline_js ) {
+
+ echo "\n\n";
+
+ $this->_inline_js = '';
+ }
+ }
+}
\ No newline at end of file
diff --git a/classes/integrations/google-analytics/class-wc-google-analytics.php b/classes/integrations/google-analytics/class-wc-google-analytics.php
index 36241e9db97..9ff9e24081d 100644
--- a/classes/integrations/google-analytics/class-wc-google-analytics.php
+++ b/classes/integrations/google-analytics/class-wc-google-analytics.php
@@ -311,7 +311,7 @@ class WC_Google_Analytics extends WC_Integration {
$parameters = apply_filters( 'woocommerce_ga_event_tracking_parameters', $parameters );
- $woocommerce->add_inline_js("
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js("
$('" . $selector . "').click(function() {
" . sprintf( "_gaq.push(['_trackEvent', %s, %s, %s]);", $parameters['category'], $parameters['action'], $parameters['label'] ) . "
});
diff --git a/classes/widgets/class-wc-widget-layered-nav.php b/classes/widgets/class-wc-widget-layered-nav.php
index 104df846b70..4e409451a0c 100644
--- a/classes/widgets/class-wc-widget-layered-nav.php
+++ b/classes/widgets/class-wc-widget-layered-nav.php
@@ -169,7 +169,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
echo '';
- $woocommerce->add_inline_js("
+ $woocommerce->get_helper( 'inline-javascript' )->add_inline_js("
jQuery('#dropdown_layered_nav_$taxonomy_filter').change(function(){
diff --git a/woocommerce.php b/woocommerce.php
index f2c8d118b66..31a5d7a6a3c 100644
--- a/woocommerce.php
+++ b/woocommerce.php
@@ -1489,44 +1489,6 @@ class Woocommerce {
return $classes;
}
- /** Inline JavaScript Helper **********************************************/
-
- /**
- * Add some JavaScript inline to be output in the footer.
- *
- * @access public
- * @param string $code
- * @return void
- */
- public function add_inline_js( $code ) {
- $this->_inline_js .= "\n" . $code . "\n";
- }
-
- /**
- * Output any queued inline JS.
- *
- * @access public
- * @return void
- */
- public function output_inline_js() {
- if ( $this->_inline_js ) {
-
- echo "\n\n";
-
- $this->_inline_js = '';
- }
- }
-
/** Deprecated functions *********************************************************/
/**
@@ -1580,6 +1542,32 @@ class Woocommerce {
$helper->clear_product_transients( $post_id );
}
+ /**
+ * Add some JavaScript inline to be output in the footer.
+ *
+ * @deprecated 2.1.0 Access via the helpers
+ * @access public
+ * @param string $code
+ * @return void
+ */
+ public function add_inline_js( $code ) {
+ _deprecated_function( 'Woocommerce->add_inline_js', '2.1', 'WC_Inline_Javascript_Helper->add_inline_js' );
+ $helper = $this->get_helper( 'inline-javascript' );
+ $helper->add_inline_js( $code );
+ }
+
+ /**
+ * Output any queued inline JS.
+ *
+ * @deprecated 2.1.0 Access via the helpers
+ * @access public
+ * @return void
+ */
+ public function output_inline_js() {
+ _deprecated_function( 'Woocommerce->output_inline_js', '2.1', 'WC_Inline_Javascript_Helper->output_inline_js' );
+ $helper = $this->get_helper( 'inline-javascript' );
+ $helper->output_inline_js();
+ }
}
/**