Tribe__Events__Aggregator__Record__Activity::add( string $slug, string|array $items, array $ids = array() )

Logs an Activity


Parameters

$slug

(string) (Required) Name of this Activity

$items

(string|array) (Required) Type of activity

$ids

(array) (Optional) items inside of the action

Default value: array()


Top ↑

Return

(boolean)


Top ↑

Source

File: src/Tribe/Aggregator/Record/Activity.php

	public function add( $slug, $items, $ids = array() ) {
		if ( ! $this->exists( $slug ) ) {
			return false;
		}

		if ( ! isset( $this->map[ $slug ] ) ) {
			return false;
		}

		// Map the Slug
		$slug = $this->map[ $slug ];

		if ( is_scalar( $items ) ) {
			// If it's a scalar and it's not one of the registered actions we skip it
			if ( ! isset( self::$actions[ $items ] ) ) {
				return false;
			}

			// Make the actual Array of items
			$items = array( $items => $ids );
		} else {
			$items = (object) $items;

			// Doesn't contain any of the Possible Actions
			if ( 0 === count( array_intersect_key( self::$actions, (array) $items ) ) ) {
				return false;
			}
		}

		foreach ( $items as $action => $ids ) {
			// Skip Empty ids
			if ( empty( $ids ) ) {
				continue;
			}

			$this->items[ $slug ]->{ $action } = array_unique( array_filter( array_merge( $this->items[ $slug ]->{ $action }, (array) $ids ) ) );
		}

		return true;
	}