1 | <?php |
||
13 | class A8c_Mc_Stats { |
||
14 | |||
15 | /** |
||
16 | * Holds the stats to be processed |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | private $stats = array(); |
||
21 | |||
22 | /** |
||
23 | * Indicates whether to use the transparent pixel (b.gif) instead of the regular smiley (g.gif) |
||
24 | * |
||
25 | * @var boolean |
||
26 | */ |
||
27 | public $use_transparent_pixel = true; |
||
28 | |||
29 | /** |
||
30 | * Class Constructor |
||
31 | * |
||
32 | * @param boolean $use_transparent_pixel Use the transparent pixel instead of the smiley. |
||
33 | */ |
||
34 | public function __construct( $use_transparent_pixel = true ) { |
||
37 | |||
38 | /** |
||
39 | * Store a stat for later output. |
||
40 | * |
||
41 | * @param string $group The stat group. |
||
42 | * @param string $name The stat name to bump. |
||
43 | * |
||
44 | * @return boolean true if stat successfully added |
||
45 | */ |
||
46 | public function add( $group, $name ) { |
||
64 | |||
65 | /** |
||
66 | * Gets current stats stored to be processed |
||
67 | * |
||
68 | * @return array $stats |
||
69 | */ |
||
70 | public function get_current_stats() { |
||
73 | |||
74 | /** |
||
75 | * Return the stats from a group in an array ready to be added as parameters in a query string |
||
76 | * |
||
77 | * @param string $group_name The name of the group to retrieve. |
||
78 | * @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 |
||
79 | */ |
||
80 | public function get_group_query_args( $group_name ) { |
||
87 | |||
88 | /** |
||
89 | * Gets a list of trac URLs for every stored URL |
||
90 | * |
||
91 | * @return array An array of URLs |
||
92 | */ |
||
93 | public function get_stats_urls() { |
||
105 | |||
106 | /** |
||
107 | * Outputs the tracking pixels for the current stats and empty the stored stats from the object |
||
108 | * |
||
109 | * @return void |
||
110 | */ |
||
111 | public function do_stats() { |
||
118 | |||
119 | /** |
||
120 | * Pings the stats server for the current stats and empty the stored stats from the object |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public function do_server_side_stats() { |
||
131 | |||
132 | /** |
||
133 | * Runs stats code for a one-off, server-side. |
||
134 | * |
||
135 | * @param string $url string The URL to be pinged. Should include `x_jetpack-{$group}={$stats}` or whatever we want to store. |
||
136 | * |
||
137 | * @return bool If it worked. |
||
138 | */ |
||
139 | public function do_server_side_stat( $url ) { |
||
140 | $response = wp_remote_get( esc_url_raw( $url ) ); |
||
141 | if ( is_wp_error( $response ) ) { |
||
142 | return false; |
||
143 | } |
||
144 | |||
145 | if ( 200 !== wp_remote_retrieve_response_code( $response ) ) { |
||
146 | return false; |
||
147 | } |
||
148 | |||
149 | return true; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Builds the stats url. |
||
154 | * |
||
155 | * @param array $args array|string The arguments to append to the URL. |
||
156 | * |
||
157 | * @return string The URL to be pinged. |
||
158 | */ |
||
159 | public function build_stats_url( $args ) { |
||
181 | |||
182 | } |
||
183 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: