-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment requirements
53 lines (32 loc) · 1.81 KB
/
Assignment requirements
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Here is the assignment we'd suggest: a widget (in the form of a plugin) which shows stats about the site it is installed on (e.g. number of posts, users, etc.) as well as stats for all the other sites on a multisite network, pulled using the REST API. Ideally, the stats should update once a minute.
For the widget we had in mind a frontend widget that you could place into a sidebar, similar in concept to the Archives widget. As for what the widget contains, it would be at least stats on the number of generic posts published and the number of users, but it could also include pages and other post types. That's up to you. Adding support for non-posts would be just expanding whatever solution is developed for gathering stats for all generic posts across a network. And yes, a custom REST API endpoint for stats would be the right approach!
A front end widget
Similar to Archives widget
Counts the posts and users on a multisite network
Stats:
# of generic posts published
# of users
# of pages
# of other post types
Output via a custom endpoint
Chron to update every hour (can't be every minute with WP cron. We would need to add a true cron which is dependent on the host)
Widget
Counts the posts and users on each site of a multisite network
get_current_blog_id();
switch_to_blog
get_sites();
count_users()
//cached
get_user_count();
wp site create --slug=aa
wp user generate -count=33 --url=aa.restapi.dev
wp post generate --count=22 --url=l7.restapi.dev
$response = wp_remote_get('http://1.restapi.dev/wp-json/wp/v2/users')
OR
$response = wp_remote_get('http://1.restapi.dev/wp-json/wp/v2/posts')
$total = wp_remote_retrieve_header( $response,'x-wp-total' );
Debug
wp_remote_retrieve_headers( $response );
WP CLI shell testing
ensure that the direct path check is disabled.
MULTISITE_STATS\get_network_stats();