PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.1
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.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 / widgets / widget-notes.php

widget-notes.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.1, at includes/widgets/widget-notes.php

89 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — Note Pad widget PHP registration.
4 *
5 * The composer surface for pinned notes: a pad of pastel paper on the
6 * widget column. The user writes on the top sheet and drags it out of
7 * the pad onto the wallpaper, where it becomes a pinned `wpd_note`
8 * (see `includes/notes/bootstrap.php` for the data layer).
9 *
10 * Same registration shape as every widget (template:
11 * `includes/widgets/widget-starter.php`): register the script + style
12 * handles at `init@5`, announce the widget at `init@6`, eagerly
13 * enqueue only the CSS on shell pages.
14 *
15 * @package OpenStation
16 */
17
18 defined( 'ABSPATH' ) || exit;
19
20 /**
21 * Register the JS bundle and CSS stylesheet handles.
22 */
23 function openstation_register_notes_widget_assets() {
24 $suffix = openstation_asset_suffix();
25 $version = defined( 'OPENSTATION_VERSION' ) ? OPENSTATION_VERSION : '0';
26
27 $js_path = OPENSTATION_DIR . 'assets/js/widget-notes' . $suffix . '.js';
28 $css_path = OPENSTATION_DIR . 'assets/js/widget-notes' . $suffix . '.css';
29
30 wp_register_style(
31 'os-notes-widget',
32 OPENSTATION_URL . 'assets/js/widget-notes' . $suffix . '.css',
33 array(),
34 file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version
35 );
36
37 wp_register_script(
38 'os-notes-widget',
39 OPENSTATION_URL . 'assets/js/widget-notes' . $suffix . '.js',
40 array(),
41 file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version,
42 true
43 );
44 }
45 add_action( 'init', 'openstation_register_notes_widget_assets', 5 );
46
47 /**
48 * Eagerly enqueue the CSS on OpenStation shell pages.
49 *
50 * The JS loads lazily (widget server-sync); the CSS must be present
51 * before first mount to avoid a flash of unstyled pad.
52 */
53 function openstation_enqueue_notes_widget_styles() {
54 if ( function_exists( 'openstation_is_enabled' ) && ! openstation_is_enabled() ) {
55 return;
56 }
57 if ( function_exists( 'openstation_is_chromeless_request' ) && openstation_is_chromeless_request() ) {
58 return;
59 }
60 wp_enqueue_style( 'os-notes-widget' );
61 }
62 add_action( 'admin_enqueue_scripts', 'openstation_enqueue_notes_widget_styles', 20 );
63
64 /**
65 * Announce the widget to OpenStation.
66 */
67 function openstation_register_notes_widget() {
68 if ( ! function_exists( 'openstation_register_widget' ) ) {
69 return;
70 }
71
72 openstation_register_widget(
73 'desktop-mode/notes',
74 array(
75 'label' => __( 'Note Pad', 'desktop-mode' ),
76 'description' => __( 'Write a note and drag it onto the desktop to pin it.', 'desktop-mode' ),
77 'icon' => 'dashicons-sticky',
78 'script' => 'os-notes-widget',
79 'movable' => true,
80 'resizable' => true,
81 'min_width' => 240,
82 'min_height' => 300,
83 'default_width' => 300,
84 'default_height' => 360,
85 )
86 );
87 }
88 add_action( 'init', 'openstation_register_notes_widget', 6 );
89