PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.9.0
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.9.0
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 / types / class-desktop-mode-embed-file.php

class-desktop-mode-embed-file.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 0.9.0, at includes/desktop-files/types/class-desktop-mode-embed-file.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Desktop Mode — `embed` file type.
4 *
5 * An "embedded web window" tile — double-click opens the stored URL
6 * in an iframe-based desktop window so the page renders inside the
7 * shell instead of a new browser tab. The URL is the entity
8 * reference; an optional human-friendly name lives on the
9 * placement row's `meta.name`. The window's last `{ x, y, width,
10 * height }` is persisted on `meta.window` after every drag /
11 * resize end so the next open restores that geometry (clamped to
12 * the current desktop area on the JS side).
13 *
14 * @package WPDesktopMode
15 * @since 0.18.0
16 */
17
18 defined( 'ABSPATH' ) || exit;
19
20 /**
21 * @since 0.18.0
22 */
23 class Desktop_Mode_Embed_File extends Desktop_Mode_File {
24
25 public static function type(): string {
26 return 'embed';
27 }
28
29 public function exists(): bool {
30 return '' !== $this->url();
31 }
32
33 public function title(): string {
34 $url = $this->url();
35 if ( '' === $url ) {
36 return __( '(missing embed)', 'desktop-mode' );
37 }
38 $host = wp_parse_url( $url, PHP_URL_HOST );
39 return is_string( $host ) && '' !== $host ? $host : $url;
40 }
41
42 public function icon(): string {
43 return 'dashicons-welcome-view-site';
44 }
45
46 public function serialize(): array {
47 $shape = parent::serialize();
48 $shape['url'] = $this->url();
49 return $shape;
50 }
51
52 private function url(): string {
53 $url = esc_url_raw( $this->ref );
54 return is_string( $url ) ? $url : '';
55 }
56 }
57