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-link-file.php

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

53 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — `link` file type.
4 *
5 * A "web link" tile — double-click opens the stored URL in a new
6 * browser tab via `window.open( url, '_blank', 'noopener,noreferrer' )`.
7 * The URL itself is the entity reference; an optional human-friendly
8 * name lives on the placement row's `meta.name` so two tiles
9 * pointing at the same URL can carry different labels.
10 *
11 * @package OpenStation
12 */
13
14 defined( 'ABSPATH' ) || exit;
15
16 /**
17 * The `link` desktop file type.
18 */
19 class OpenStation_Link_File extends OpenStation_File {
20
21 public static function type(): string {
22 return 'link';
23 }
24
25 public function exists(): bool {
26 return '' !== $this->url();
27 }
28
29 public function title(): string {
30 $url = $this->url();
31 if ( '' === $url ) {
32 return __( '(missing link)', 'desktop-mode' );
33 }
34 $host = wp_parse_url( $url, PHP_URL_HOST );
35 return is_string( $host ) && '' !== $host ? $host : $url;
36 }
37
38 public function icon(): string {
39 return 'dashicons-admin-links';
40 }
41
42 public function serialize(): array {
43 $shape = parent::serialize();
44 $shape['url'] = $this->url();
45 return $shape;
46 }
47
48 private function url(): string {
49 $url = esc_url_raw( $this->ref );
50 return is_string( $url ) ? $url : '';
51 }
52 }
53