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 }:idnames it,labelis what the listener reads,run()is called when it is picked, after the menu closes, andhref, in place ofrun, makes it a link. trackObject- The track the menu is for, in the shape
Tracks::schema()describes. contextObject- Where the menu was opened.
wherestringrow, a row on the page, orqueue, a track in Up next.indexnumberFor 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 }
);plugins/riff/assets/player/menu.jsView on GitHub
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |