'', 'width' => 640, 'height' => 0, ), $atts, 'dadan' ); // DADAN-19: bare share codes must not go through esc_url_raw (it prepends http://). $raw = sanitize_text_field( trim( (string) $atts['url'] ) ); if ( '' === $raw ) { return $this->error_markup( __( 'Dadan shortcode requires a url attribute.', 'dadan' ) ); } $url = preg_match( '/^[A-Za-z0-9_-]{1,64}$/', $raw ) ? $raw : esc_url_raw( $raw ); $parsed = Dadan_Url::parse( $url ); if ( ! $parsed ) { return $this->error_markup( __( 'Invalid Dadan video URL.', 'dadan' ) ); } if ( 'video' === $parsed['kind'] ) { return $this->error_markup( __( 'Use a Dadan share URL (…/video/share/…) to embed. Direct /video/{id} links are not embeddable.', 'dadan' ) ); } $width = Dadan_Url::sanitize_dimension( $atts['width'], 640 ); $height = absint( $atts['height'] ); $html = Dadan_Fallback::render_from_url( $url, $width, $height ); if ( '' === $html ) { return $this->error_markup( __( 'Unable to embed this Dadan video.', 'dadan' ) ); } return $html; } /** * Escaped notice for editors; empty string for anonymous front-end visitors. * * @param string $message Message text. * @return string */ private function error_markup( $message ) { if ( ! is_user_logged_in() || ! current_user_can( 'edit_posts' ) ) { return ''; } return '
'; } }