Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandondove/abe7418a645720bf2225dad9ee63b0b8 to your computer and use it in GitHub Desktop.
Save brandondove/abe7418a645720bf2225dad9ee63b0b8 to your computer and use it in GitHub Desktop.
<?php
/**
* Sets the value of a column called "clicks" in the AdSanity post list in the WordPress Dashboard.
*/
function example_adsanity_ads_posts_columns_clicks_value( $value = '' ) {
// Today's clicks
$clicks = get_post_meta(
get_the_ID(),
sprintf( '_clicks-%s', mktime( 0,0,0, date( 'n' ), date( 'j' ), date( 'Y' ) ) ),
true
);
if ( false === $clicks ) {
$clicks = 0;
}
return intval( $clicks );
}
add_filter( 'adsanity_ads_posts_columns_clicks_value', 'example_adsanity_ads_posts_columns_clicks_value' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment