PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.9.7
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.9.7
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 0.9.7, at includes/widgets/widget-notes.php

96 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Desktop Mode — 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 WPDesktopMode
16 * @since 0.9.6
17 */
18
19 defined( 'ABSPATH' ) || exit;
20
21 /**
22 * Register the JS bundle and CSS stylesheet handles.
23 *
24 * @since 0.9.6
25 */
26 function desktop_mode_register_notes_widget_assets() {
27 $suffix = desktop_mode_asset_suffix();
28 $version = defined( 'DESKTOP_MODE_VERSION' ) ? DESKTOP_MODE_VERSION : '0';
29
30 $js_path = DESKTOP_MODE_DIR . 'assets/js/widget-notes' . $suffix . '.js';
31 $css_path = DESKTOP_MODE_DIR . 'assets/js/widget-notes' . $suffix . '.css';
32
33 wp_register_style(
34 'desktop-mode-notes-widget',
35 DESKTOP_MODE_URL . 'assets/js/widget-notes' . $suffix . '.css',
36 array(),
37 file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version
38 );
39
40 wp_register_script(
41 'desktop-mode-notes-widget',
42 DESKTOP_MODE_URL . 'assets/js/widget-notes' . $suffix . '.js',
43 array(),
44 file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version,
45 true
46 );
47 }
48 add_action( 'init', 'desktop_mode_register_notes_widget_assets', 5 );
49
50 /**
51 * Eagerly enqueue the CSS on Desktop Mode shell pages.
52 *
53 * The JS loads lazily (widget server-sync); the CSS must be present
54 * before first mount to avoid a flash of unstyled pad.
55 *
56 * @since 0.9.6
57 */
58 function desktop_mode_enqueue_notes_widget_styles() {
59 if ( function_exists( 'desktop_mode_is_enabled' ) && ! desktop_mode_is_enabled() ) {
60 return;
61 }
62 if ( function_exists( 'desktop_mode_is_chromeless_request' ) && desktop_mode_is_chromeless_request() ) {
63 return;
64 }
65 wp_enqueue_style( 'desktop-mode-notes-widget' );
66 }
67 add_action( 'admin_enqueue_scripts', 'desktop_mode_enqueue_notes_widget_styles', 20 );
68
69 /**
70 * Announce the widget to Desktop Mode.
71 *
72 * @since 0.9.6
73 */
74 function desktop_mode_register_notes_widget() {
75 if ( ! function_exists( 'desktop_mode_register_widget' ) ) {
76 return;
77 }
78
79 desktop_mode_register_widget(
80 'desktop-mode/notes',
81 array(
82 'label' => __( 'Note Pad', 'desktop-mode' ),
83 'description' => __( 'Write a note and drag it onto the desktop to pin it.', 'desktop-mode' ),
84 'icon' => 'dashicons-sticky',
85 'script' => 'desktop-mode-notes-widget',
86 'movable' => true,
87 'resizable' => true,
88 'min_width' => 240,
89 'min_height' => 300,
90 'default_width' => 300,
91 'default_height' => 360,
92 )
93 );
94 }
95 add_action( 'init', 'desktop_mode_register_notes_widget', 6 );
96