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

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

54 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 * Desktop Mode — `bookmark` file type.
4 *
5 * Reference is the URL itself (validated against `esc_url_raw`).
6 * Title falls back to the host when the user hasn't set one — the
7 * UI promotes a separate `title` field stored alongside the
8 * placement in the placement row's `meta` column (Phase 2), but
9 * the base shape works without it.
10 *
11 * @package WPDesktopMode
12 * @since 0.9.0
13 */
14
15 defined( 'ABSPATH' ) || exit;
16
17 /**
18 * @since 0.9.0
19 */
20 class Desktop_Mode_Bookmark_File extends Desktop_Mode_File {
21
22 public static function type(): string {
23 return 'bookmark';
24 }
25
26 public function exists(): bool {
27 return '' !== $this->url();
28 }
29
30 public function title(): string {
31 $url = $this->url();
32 if ( '' === $url ) {
33 return __( '(missing bookmark)', 'desktop-mode' );
34 }
35 $host = wp_parse_url( $url, PHP_URL_HOST );
36 return is_string( $host ) && '' !== $host ? $host : $url;
37 }
38
39 public function icon(): string {
40 return 'dashicons-admin-links';
41 }
42
43 public function serialize(): array {
44 $shape = parent::serialize();
45 $shape['url'] = $this->url();
46 return $shape;
47 }
48
49 private function url(): string {
50 $url = esc_url_raw( $this->ref );
51 return is_string( $url ) ? $url : '';
52 }
53 }
54