Developers

wp.hooks.applyFilters( 'riff.menu', items, track, context )

Filters the items of the track menu, the … beside every row and every track in Up next.

Parameters

itemsObject[]
The items, each { id, label, run, href }: id names it, label is what the listener reads, run() is called when it is picked, after the menu closes, and href, in place of run, makes it a link.
trackObject
The track the menu is for, in the shape Tracks::schema() describes.
contextObject
Where the menu was opened.
  • wherestring
    row, a row on the page, or queue, a track in Up next.
  • indexnumber
    For Up next, the track's place in the queue, from 0.

More Information

Return the items with yours added where they belong: the menu shows them in the order given. Riff's own are, in order, next (Play next), add (Add to queue), like, playlist, then in Up next up, down and remove, then post (Go to post), each only where it applies, with what Riff's own features add, such as Listen along, among them; find one by its id rather than its place. An item with neither run nor href, or with no label, is left out.

Usage

wp.hooks.addFilter( 'riff.menu', 'my-plugin', ( items, track, context ) => {
	return items;
} );

Source

const all = filter(
'menu',
ours,
t,
at === undefined
? { where: 'row' }
: { where: 'queue', index: at }
);

Changelog

VersionDescription
5.9.0Introduced.