Skip to content

Commit

Permalink
Sharing: do not record stats if the stats module is disabled. (#10120)
Browse files Browse the repository at this point in the history
Fixes #9678

When the Stats module is disabled, do not use any tracking pixel on pages using sharing buttons.
  • Loading branch information
jeherve authored and zinigor committed Sep 17, 2018
1 parent 97a669d commit ff5e53e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/sharedaddy/sharing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ function sharing_add_footer() {

wp_enqueue_script( 'sharing-js' );
$sharing_js_options = array(
'lang' => get_base_recaptcha_lang_code(),
'lang' => get_base_recaptcha_lang_code(),
/** This filter is documented in modules/sharedaddy/sharing-service.php */
'counts' => apply_filters( 'jetpack_sharing_counts', true ),
'counts' => apply_filters( 'jetpack_sharing_counts', true ),
'is_stats_active' => Jetpack::is_module_active( 'stats' ),
);
wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options );
}
Expand Down
4 changes: 3 additions & 1 deletion modules/sharedaddy/sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ if ( sharing_js_options && sharing_js_options.counts ) {
jQuery.getScript( service_request );
}

WPCOMSharing.bump_sharing_count_stat( service );
if ( sharing_js_options.is_stats_active ) {
WPCOMSharing.bump_sharing_count_stat( service );
}
}

WPCOMSharing.done_urls[ id ] = true;
Expand Down

0 comments on commit ff5e53e

Please sign in to comment.