Am thinking something like this in your functions.php. Please check closing brackets as the editor here isn’t optimised for code.
remove_action( 'wp_enqueue_scripts', 'tptn_enqueue_scripts' );
function tptn_enqueue_scripts_always() {
global $post, $ajax_tptn_tracker;
$id = is_singular() ? absint( $post->ID ) : 0;
$blog_id = get_current_blog_id();
$activate_counter = ! empty( $trackers['overall'] ) ? 1 : 0; // It's 1 if we're updating the overall count.
$activate_counter = $activate_counter + ( ! empty( $trackers['daily'] ) ? 10 : 0 ); // It's 10 if we're updating the daily count.
$top_ten_debug = absint( tptn_get_option( 'debug_mode' ) );
if ( 'query_based' === tptn_get_option( 'tracker_type' ) ) {
$home_url = home_url( '/' );
} else {
$home_url = admin_url( 'admin-ajax.php' );
}
/**
* Filter the URL of the tracker.
*
* Other tracker types can override the URL processed by the jQuery.post request
* The corresponding tracker can use the below variables or append their own to $ajax_tptn_tracker
*
* @since 2.0
*/
$home_url = apply_filters( 'tptn_add_counter_script_url', $home_url );
// Strip any query strings since we don't need them.
$home_url = strtok( $home_url, '?' );
$ajax_tptn_tracker = array(
'ajax_url' => $home_url,
'top_ten_id' => $id,
'top_ten_blog_id' => $blog_id,
'activate_counter' => $activate_counter,
'top_ten_debug' => $top_ten_debug,
'tptn_rnd' => wp_rand( 1, time() ),
);
/**
* Filter the localize script arguments for the Top 10 tracker.
*
* @since 2.4.0
*/
$ajax_tptn_tracker = apply_filters( 'tptn_tracker_script_args', $ajax_tptn_tracker );
wp_enqueue_script( 'tptn_tracker', plugins_url( 'includes/js/top-10-tracker.min.js', TOP_TEN_PLUGIN_FILE ), array( 'jquery' ), '1.0', true );
wp_localize_script( 'tptn_tracker', 'ajax_tptn_tracker', $ajax_tptn_tracker );
}
add_action( 'wp_enqueue_scripts', 'tptn_enqueue_scripts_always' );