render_link( $url, $attr['title'] ); } else { $output = $wp_embed->shortcode( $attr, $url ); } return $output; } /** * Filter oEmbed HTML for PollDaddy to for AMP output. * * @param string $cache Cache for oEmbed. * @param string $url Embed URL. * @param array $attr Shortcode attributes. * @return string Embed. */ public function filter_embed_oembed_html( $cache, $url, $attr ) { $parsed_url = wp_parse_url( $url ); if ( false === strpos( $parsed_url['host'], 'polldaddy.com' ) ) { return $cache; } $output = ''; // Poll oEmbed responses include noscript. if ( preg_match( '##', $cache, $matches ) ) { $output = $matches[1]; } if ( empty( $output ) ) { if ( ! empty( $attr['title'] ) ) { $name = $attr['title']; } elseif ( false !== strpos( $url, 'polldaddy.com/s' ) ) { $name = __( 'View Survey', 'amp' ); } else { $name = __( 'View Poll', 'amp' ); } $output = $this->render_link( $url, $name ); } return $output; } /** * Render poll/survey link. * * @param string $url Link URL. * @param string $title Link Text. * @return string Link. */ private function render_link( $url, $title ) { return sprintf( '
' ); } }