PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.8.9
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.8.9
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 0.8.9, at includes/desktop-files/wallpaper-menu.php

63 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Desktop Mode — 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 four built-in items (Create folder, Show desktop, OS
11 * Settings, Wallpapers) 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 * `desktop-mode.wallpaper-context-menu.activated` action
17 * instead.
18 *
19 * @package WPDesktopMode
20 * @since 0.9.0
21 */
22
23 defined( 'ABSPATH' ) || exit;
24
25 /**
26 * Builds the server-borne wallpaper-menu items.
27 *
28 * @since 0.9.0
29 *
30 * @return array[]
31 */
32 function desktop_mode_build_wallpaper_menu_items() {
33 $items = array();
34
35 /**
36 * Filter the server-borne wallpaper context-menu items.
37 *
38 * Each item must have at least `id` and `label`. Optional:
39 * `icon`, `sort`, `disabled`, `callbackId`.
40 *
41 * @since 0.9.0
42 *
43 * @param array[] $items Items list.
44 */
45 $items = (array) apply_filters( 'desktop_mode_wallpaper_context_menu_items', $items );
46
47 $out = array();
48 foreach ( $items as $entry ) {
49 if ( ! is_array( $entry ) || empty( $entry['id'] ) || empty( $entry['label'] ) ) {
50 continue;
51 }
52 $out[] = array(
53 'id' => (string) $entry['id'],
54 'label' => (string) $entry['label'],
55 'icon' => isset( $entry['icon'] ) ? (string) $entry['icon'] : '',
56 'sort' => isset( $entry['sort'] ) ? (int) $entry['sort'] : 100,
57 'disabled' => ! empty( $entry['disabled'] ),
58 'callbackId' => isset( $entry['callbackId'] ) ? (string) $entry['callbackId'] : '',
59 );
60 }
61 return $out;
62 }
63