url(); } /** * Get a label from the embed URL's host. * * @return string */ public function title(): string { $url = $this->url(); if ( '' === $url ) { return __( '(missing embed)', 'desktop-mode' ); } $host = wp_parse_url( $url, PHP_URL_HOST ); return is_string( $host ) && '' !== $host ? $host : $url; } /** * Get the Dashicon class for embed tiles. * * @return string */ public function icon(): string { return 'dashicons-welcome-view-site'; } /** * Augment the base serialized shape with the embed URL. * * @return array */ public function serialize(): array { $shape = parent::serialize(); $shape['url'] = $this->url(); return $shape; } /** * Sanitize the stored ref into a valid URL. * * @return string Empty string when the ref is not a valid URL. */ private function url(): string { $url = esc_url_raw( $this->ref ); return is_string( $url ) ? $url : ''; } }