Skip to content

Commit

Permalink
Hide the tracker notice once clicked to avoid double clicks.
Browse files Browse the repository at this point in the history
  • Loading branch information
kloon committed Feb 12, 2015
1 parent a80d069 commit 1ac68ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions assets/js/admin/woocommerce_notices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* WooCommerce Notices JS
*/
jQuery( function ( $ ) {

$('.woocommerce-tracker .button-primary').on('click',function() {
$('.woocommerce-tracker' ).slideUp();
});

});
4 changes: 4 additions & 0 deletions includes/admin/class-wc-admin-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function admin_scripts() {
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable' ), WC_VERSION );
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/admin/jquery.qrcode.min.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'woocommerce_admin_notices', WC()->plugin_url() . '/assets/js/admin/woocommerce_notices' . $suffix . '.js', array( 'jquery' ), WC_VERSION );

// Chosen is @deprecated (2.3) in favour of select2, but is registered for backwards compat
wp_register_script( 'ajax-chosen', WC()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'chosen' ), WC_VERSION );
Expand Down Expand Up @@ -122,6 +123,9 @@ public function admin_scripts() {
'mon_decimal_point' => wc_get_price_decimal_separator()
) );

// WooCommerce admin notices script should be included on all pages as notices show on any admin page.
wp_enqueue_script( 'woocommerce_admin_notices' );

// WooCommerce admin pages
if ( in_array( $screen->id, wc_get_screen_ids() ) ) {

Expand Down
4 changes: 2 additions & 2 deletions includes/admin/views/html-notice-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
exit;
}
?>
<div id="message" class="updated woocommerce-message wc-connect">
<div id="message" class="updated woocommerce-message woocommerce-tracker">
<p><?php printf( __( 'Want to help make WooCommerce even more awesome? Allow WooThemes to collect non-sensitive diagnostic data and usage information, and get %s discount on your next WooThemes purchase. %sFind out more%s.', 'woocommerce' ), '20%', '<a href="http://www.woothemes.com/woocommerce/usage-tracking/" target="_blank">', '</a>' ); ?></p>
<p class="submit">
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc_tracker_optin', 'true' ), 'wc_tracker_optin', 'wc_tracker_nonce' ) ); ?>" class="button-primary"><?php _e( 'Allow', 'woocommerce' ); ?></a>
<a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc_tracker_optin', 'true' ), 'wc_tracker_optin', 'wc_tracker_nonce' ) ); ?>"><?php _e( 'Allow', 'woocommerce' ); ?></a>
<a class="skip button" href="<?php echo esc_url( add_query_arg( 'wc-hide-notice', 'tracking' ) ); ?>"><?php _e( 'No, do not bother me again', 'woocommerce' ); ?></a>
</p>
</div>

0 comments on commit 1ac68ad

Please sign in to comment.