Tribe__Events__Aggregator__Record__Activity::count( string $slug = null, string $action = null )
Fetches a registered Activity counter
Contents
Parameters
- $slug
-
(string) (Optional) (optional) The Slug of the Activity
Default value: null
- $action
-
(string) (Optional) (optional) Which action
Default value: null
Return
(int)
Source
File: src/Tribe/Aggregator/Record/Activity.php
public function count( $slug = null, $action = null ) {
$actions = $this->get( $slug );
if ( empty( $actions ) ) {
return 0;
}
// Sum all of the Actions
if ( is_null( $action ) ) {
// recursively convert to associative array
$actions = json_decode( json_encode( $actions ), true );
return array_sum( array_map( 'count', $actions ) );
} elseif ( ! empty( $actions->{ $action } ) ) {
return count( $actions->{ $action } );
}
return 0;
}