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 / types / class-openstation-embed-file.php

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

56 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 * OpenStation — `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 OpenStation
15 */
16
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * The `embed` desktop file type.
21 */
22 class OpenStation_Embed_File extends OpenStation_File {
23
24 public static function type(): string {
25 return 'embed';
26 }
27
28 public function exists(): bool {
29 return '' !== $this->url();
30 }
31
32 public function title(): string {
33 $url = $this->url();
34 if ( '' === $url ) {
35 return __( '(missing embed)', 'desktop-mode' );
36 }
37 $host = wp_parse_url( $url, PHP_URL_HOST );
38 return is_string( $host ) && '' !== $host ? $host : $url;
39 }
40
41 public function icon(): string {
42 return 'dashicons-welcome-view-site';
43 }
44
45 public function serialize(): array {
46 $shape = parent::serialize();
47 $shape['url'] = $this->url();
48 return $shape;
49 }
50
51 private function url(): string {
52 $url = esc_url_raw( $this->ref );
53 return is_string( $url ) ? $url : '';
54 }
55 }
56