Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Internal
File: McStats.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WooCommerce MC Stats package
[2] Fix | Delete
*/
[3] Fix | Delete
[4] Fix | Delete
declare( strict_types = 1 );
[5] Fix | Delete
[6] Fix | Delete
namespace Automattic\WooCommerce\Internal;
[7] Fix | Delete
[8] Fix | Delete
use Automattic\Jetpack\A8c_Mc_Stats;
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Class MC Stats, used to record internal usage stats for Automattic.
[12] Fix | Delete
*
[13] Fix | Delete
* This class is a wrapper around the Jetpack MC Stats package.
[14] Fix | Delete
* See https://github.com/Automattic/jetpack-a8c-mc-stats/tree/trunk for more details.
[15] Fix | Delete
*/
[16] Fix | Delete
class McStats extends A8c_Mc_Stats {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Return the stats from a group in an array ready to be added as parameters in a query string
[20] Fix | Delete
*
[21] Fix | Delete
* Jetpack MC Stats package prefixes group names with "x_jetpack-" so we override this method to prefix group names with "x_woocommerce-".
[22] Fix | Delete
*
[23] Fix | Delete
* @param string $group_name The name of the group to retrieve.
[24] Fix | Delete
* @return array Array with one item, where the key is the prefixed group and the value are all stats concatenated with a comma. If group not found, an empty array will be returned
[25] Fix | Delete
*/
[26] Fix | Delete
public function get_group_query_args( $group_name ) {
[27] Fix | Delete
$stats = $this->get_current_stats();
[28] Fix | Delete
if ( isset( $stats[ $group_name ] ) && ! empty( $stats[ $group_name ] ) ) {
[29] Fix | Delete
return array( "x_woocommerce-{$group_name}" => implode( ',', $stats[ $group_name ] ) );
[30] Fix | Delete
}
[31] Fix | Delete
return array();
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Outputs the tracking pixels for the current stats and empty the stored stats from the object
[36] Fix | Delete
*
[37] Fix | Delete
* @return void
[38] Fix | Delete
*/
[39] Fix | Delete
public function do_stats() {
[40] Fix | Delete
if ( ! \WC_Site_Tracking::is_tracking_enabled() ) {
[41] Fix | Delete
return;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
parent::do_stats();
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Runs stats code for a one-off, server-side.
[49] Fix | Delete
*
[50] Fix | Delete
* @param string $url string The URL to be pinged. Should include `x_woocommerce-{$group}={$stats}` or whatever we want to store.
[51] Fix | Delete
*
[52] Fix | Delete
* @return bool If it worked.
[53] Fix | Delete
*/
[54] Fix | Delete
public function do_server_side_stat( $url ) {
[55] Fix | Delete
if ( ! \WC_Site_Tracking::is_tracking_enabled() ) {
[56] Fix | Delete
return false;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
return parent::do_server_side_stat( $url );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Pings the stats server for the current stats and empty the stored stats from the object
[64] Fix | Delete
*
[65] Fix | Delete
* @return void
[66] Fix | Delete
*/
[67] Fix | Delete
public function do_server_side_stats() {
[68] Fix | Delete
if ( ! \WC_Site_Tracking::is_tracking_enabled() ) {
[69] Fix | Delete
return;
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
parent::do_server_side_stats();
[73] Fix | Delete
}
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function