Clanbite Social Kit Since 1.6.2 Updated in 1.6.4

register_object_type( string $object_type, array $args ): bool

Register a reactable object type.

public static

Class: Kernowdev\ClanbiteSocialKit\Social\Reactions

Parameters

$object_type (string) Required

Lowercase slug (a-z0-9_-), unique per kind of thing, e.g. forum_topic.

$args (array<string, mixed>) Required

Definition.

  • $label string Readable name.
  • $toggle callable ( int $id, int $user_id, string $slug ): array stores the reaction and returns the new state (active, reaction_type, reactions_count, reactions_by_type, user_reactions). Required.
  • $exists callable ( int $id ): bool whether the object exists. Optional (default: assume it does).
  • $can_react callable ( int $id, int $user_id, string $slug ): bool|WP_Error whether this user may react. Return a WP_Error to explain a refusal. Optional (default: any signed-in user).
  • $can_view callable ( int $id, int $user_id ): bool|WP_Error whether this user may see the object, so the "See all" list of who reacted is only given to people who can see it. Optional (default: anyone).
  • $enabled callable (): bool whether this kind of object currently allows reactions (a settings switch). Optional (default: Social Kit's "Social reactions" setting).
  • $reactors callable ( int $id, int $per_slug ): array who reacted, as slug => list<user id>, for the reactor stacks in tooltips. Optional (default: none shown).
  • $author callable ( int $user_id ): array how a reactor is described to the browser (id, name, profile_url, avatar_url…). Optional (default: Reactions::default_author()).
  • $types callable (): array reaction types usable on this object. Optional (default: the shared registry, Reaction_Registry::get_types()).
  • $key_prefix string Prefix of the tooltip key the UI uses per reaction ({prefix}{id}-{slug}), unique per type on one page, e.g. t for forum topics. Optional.

Returns

bool True when registered.

Defined in inc/Social/Reactions.php

Changelog

VersionDescription
1.6.4Updated.
1.6.2Introduced.