PluginProbe
NodeInfo(2) / 2.2.0
NodeInfo(2) v2.2.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 2.0.0 2.1.0 2.1.1 2.2.0 2.3.0 2.3.1 3.0.0 3.1.0
nodeinfo / includes / functions.php

functions.php in NodeInfo(2) 2.2.0, at includes/functions.php

33 lines 592 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function nodeinfo_get_active_users( $duration = '1 month ago' ) {
3 // get all distinct authors that have published a post in the last 30 days
4 $posts = get_posts(
5 array(
6 'post_type' => 'post',
7 'post_status' => 'publish',
8 'orderby' => 'post_count',
9 'order' => 'DESC',
10 'posts_per_page' => 4,
11 'date_query' => array(
12 array(
13 'after' => $duration,
14 ),
15 ),
16 )
17 );
18
19 if ( ! $posts ) {
20 return 0;
21 }
22
23 // get all distinct ID from $posts
24 return count(
25 array_unique(
26 wp_list_pluck(
27 $posts,
28 'post_author'
29 )
30 )
31 );
32 }
33