Post Pay Counter already displays payment information nicely in the stats table by default, and allows it to be included in public pages through its flexible shortcode. However, there are custom cases where you might need to extract individual bits/figures from the stats table, raw as they are.
This is easily achieved through the high-level functions exposed by the plugin. The main player here is the function
PPC_generate_stats::produce_stats. The following example snippet will extract the total adsense revenue for the given
PPC_general_functions::get_default_stats_time_range( PPC_general_functions::get_settings('general') ); $start_time = $ppc_global_settings['stats_tstart']; $end_time = $ppc_global_settings['stats_tend']; $author_ID = 1; $stats = PPC_generate_stats::produce_stats($start_time, $end_time, array( $author_ID )); $raw_stats = $stats['raw_stats']; $total_adsense = $raw_stats[$author_ID]['total']['ppc_payment']['due_payment']['adsense_revenues'];
It will work with the default time range, but it can be changed by feeding UNIX timestamps as values of
Such a call of
produce_stats will generate stats only for the given author, and is thus efficient. Taking away the third argument is possible, and will result in posts from any authors to be queried (and is more performant than making multiple calls with different author parameters). It is technically possible to query posts for a set of authors (in fact, notice the array-like third parameter), but there is no UI that exposes that feature in the stats page.
will result in exposing the data structure and show all possible choices of payment criteria and information that can be extracted.