did_convert_elements ) { return array(); } return array( self::$script_slug => self::$script_src ); } function shortcode( $attr ) { $attr = wp_parse_args( $attr, array( 'tweet' => false, ) ); if ( empty( $attr['tweet'] ) && ! empty( $attr[0] ) ) { $attr['tweet'] = $attr[0]; } $id = false; if ( is_numeric( $attr['tweet'] ) ) { $id = $attr['tweet']; } else { preg_match( self::URL_PATTERN, $attr['tweet'], $matches ); if ( isset( $matches[5] ) && is_numeric( $matches[5] ) ) { $id = $matches[5]; } if ( empty( $id ) ) { return ''; } } $this->did_convert_elements = true; return AMP_HTML_Utils::build_tag( 'amp-twitter', array( 'data-tweetid' => $id, 'layout' => 'responsive', 'width' => $this->args['width'], 'height' => $this->args['height'], ) ); } function oembed( $matches, $attr, $url, $rawattr ) { $id = false; if ( isset( $matches[5] ) && is_numeric( $matches[5] ) ) { $id = $matches[5]; } if ( ! $id ) { return ''; } return $this->shortcode( array( 'tweet' => $id ) ); } }