PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.0.1
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.0.1
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
desktop-mode / includes / desktop-files / wallpaper-menu.php

wallpaper-menu.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.0.1, at includes/desktop-files/wallpaper-menu.php

58 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — Wallpaper context-menu server side.
4 *
5 * Builds the array shipped to the shell as
6 * `serverWallpaperMenuItems`. Plugins extend the menu by
7 * filtering the array — empty by default, so no menu items
8 * arrive from the server unless plugins add them.
9 *
10 * The built-in items (Create folder, New URL, Sort by, Show
11 * desktop, OS Settings) are JS-defined inside the shell — they
12 * need access to closures we'd lose across the wire. Server
13 * items take a `callbackId` string the JS bundle resolves in
14 * its `serverCallbacks` map; plugins that don't ship a JS
15 * callback subscribe via the
16 * `os.wallpaper-context-menu.activated` action
17 * instead.
18 *
19 * @package OpenStation
20 */
21
22 defined( 'ABSPATH' ) || exit;
23
24 /**
25 * Builds the server-borne wallpaper-menu items.
26 *
27 * @return array[]
28 */
29 function openstation_build_wallpaper_menu_items() {
30 $items = array();
31
32 /**
33 * Filter the server-borne wallpaper context-menu items.
34 *
35 * Each item must have at least `id` and `label`. Optional:
36 * `icon`, `sort`, `disabled`, `callbackId`.
37 *
38 * @param array[] $items Items list.
39 */
40 $items = (array) apply_filters( 'openstation_wallpaper_context_menu_items', $items );
41
42 $out = array();
43 foreach ( $items as $entry ) {
44 if ( ! is_array( $entry ) || empty( $entry['id'] ) || empty( $entry['label'] ) ) {
45 continue;
46 }
47 $out[] = array(
48 'id' => (string) $entry['id'],
49 'label' => (string) $entry['label'],
50 'icon' => isset( $entry['icon'] ) ? (string) $entry['icon'] : '',
51 'sort' => isset( $entry['sort'] ) ? (int) $entry['sort'] : 100,
52 'disabled' => ! empty( $entry['disabled'] ),
53 'callbackId' => isset( $entry['callbackId'] ) ? (string) $entry['callbackId'] : '',
54 );
55 }
56 return $out;
57 }
58