PluginProbe
Assistant – Every Day Productivity Apps / 1.2.2
Assistant – Every Day Productivity Apps v1.2.2
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
← All changes | backend/src/Controllers/LabelsController.php +20 -0 0.4.21.2.2 View file →
@@ -42,8 +42,21 @@
42 42 },
43 43 ],
44 44 ]
45 45 );
46 +
47 + $this->route(
48 + '/labels/count',
49 + [
50 + [
51 + 'methods' => WP_REST_Server::READABLE,
52 + 'callback' => [ $this, 'label_counts' ],
53 + 'permission_callback' => function () {
54 + return current_user_can( 'edit_others_posts' );
55 + },
56 + ],
57 + ]
58 + );
46 59 }
47 60
48 61 /**
49 62 * Returns all labels.
@@ -64,6 +77,13 @@
64 77 $response[] = call_user_func( $this->transformer, $term );
65 78 }
66 79
67 80 return rest_ensure_response( $response );
81 + }
82 +
83 + /**
84 + * Returns an array of counts by label ID.
85 + */
86 + public function label_counts( $request ) {
87 + return rest_ensure_response( $this->labels->count() );
68 88 }
69 89 }