Test functions based on PF stats for collecting data
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
<pre><?php | |
function pf_test_author_leaderboard(){ | |
$c = 0; | |
$the_query = new WP_Query( | |
array( | |
'post_type' => 'post', | |
'nopaging' => true, | |
'no_found_rows' => true, | |
'cache_results' => false, | |
'posts_per_page' => -1, | |
'date_query' => array( | |
array( | |
'year' => 2015, | |
'month' => 8, | |
), | |
), | |
'meta_key' => pressforward_stats()->meta_key, | |
) | |
); | |
$array = array(); | |
if ( $the_query->have_posts() ) : | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
$item_link = get_post_meta(get_the_ID(), 'item_link', true); | |
$url_parts = parse_url($item_link); | |
if (!empty($array[$url_parts['host']])){ | |
$array[$url_parts['host']] = $array[$url_parts['host']]+1; | |
} else { | |
$array[$url_parts['host']] = 1; | |
} | |
endwhile; | |
var_dump($array); die(); | |
wp_reset_postdata(); | |
$s = pressforward_stats()->shortcodes->the_shortcode( 'pf_wordcount_last_thirty', array( 'word_count' => $wc, 'count' => $c, 'days' => '30' ) ); | |
else : | |
$s = pressforward_stats()->shortcodes->the_shortcode( 'read_nothing', array( 'days' => '30' ) ); | |
endif; | |
return $s; | |
} | |
var_dump(pf_test_author_leaderboard()); |
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 | |
function pf_test_author_leaderboard(){ | |
$c = 0; | |
$the_query = new WP_Query( | |
array( | |
'post_type' => 'post', | |
'nopaging' => true, | |
'no_found_rows' => true, | |
'cache_results' => false, | |
'posts_per_page' => -1, | |
'date_query' => array( | |
array( | |
'year' => 2015, | |
'month' => 8, | |
), | |
), | |
'meta_key' => pressforward_stats()->meta_key, | |
) | |
); | |
$authors = array(); | |
if ( $the_query->have_posts() ) : | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
$content = get_post_field( 'post_content', get_the_ID() ); | |
$word_count = str_word_count( strip_tags( $content ) ); | |
$wc = $wc+$word_count; | |
$c++; | |
endwhile; | |
wp_reset_postdata(); | |
$s = pressforward_stats()->shortcodes->the_shortcode( 'pf_wordcount_last_thirty', array( 'word_count' => $wc, 'count' => $c, 'days' => '30' ) ); | |
else : | |
$s = pressforward_stats()->shortcodes->the_shortcode( 'read_nothing', array( 'days' => '30' ) ); | |
endif; | |
return $s; | |
} | |
var_dump(pf_test_author_leaderboard()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment