did_convert_elements ) { return array(); } return array( self::$script_slug => self::$script_src ); } function shortcode( $attr ) { $attr = wp_parse_args( $attr, array( 'tweet' => false, ) ); $id = false; if ( intval( $attr['tweet'] ) ) { $id = intval( $attr['tweet'] ); } else { preg_match( self::URL_PATTERN, $attr['tweet'], $matches ); if ( isset( $matches[5] ) && intval( $matches[5] ) ) { $id = intval( $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] ) && intval( $matches[5] ) ) { $id = intval( $matches[5] ); } if ( ! $id ) { return ''; } return $this->shortcode( array( 'tweet' => $id ) ); } }