Created
February 22, 2017 01:20
-
-
Save brandondove/abe7418a645720bf2225dad9ee63b0b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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