'; } $id = ( ! empty( $content ) ) ? $content : $atts[0]; // Parse a URL if ( ! is_numeric( $id ) ) { $id = preg_replace( '#https?://gist.github.com/([a-zA-Z0-9]+)#', '$1', $id ); } if ( ! $id ) { return ''; } if ( Jetpack_AMP_Support::is_amp_request() ) { /* * According to : * * > Note: You must find the height of the gist by inspecting it with your browser (e.g., Chrome Developer Tools). * * However, this does not seem to be the case any longer. The actual height of the content does get set in the * page after loading. So this is just the initial height. * See . */ $height = 240; $parsed_url = wp_parse_url( $id ); // Strip Github user name. $id = preg_replace( '#^.*/(?=[a-z0-9]+)#', '', $parsed_url['path'] ); $file = null; if ( ! empty( $parsed_url['query'] ) ) { $query_args = wp_parse_args( $parsed_url['query'] ); if ( isset( $query_args['file'] ) ) { $file = $query_args['file']; } } if ( ! $file && ! empty( $parsed_url['fragment'] ) && preg_match( '#^file-(.+)#', $parsed_url['fragment'], $matches ) ) { $file = $matches[1]; // Make best guess of file for fragment that was slugified. $file = preg_replace( '/-(\w+)/', '.$1', $file ); } $amp_tag = sprintf( ''; if ( isset( $_POST['type'] ) && 'embed' === $_POST['type'] && isset( $_POST['action'] ) && 'parse-embed' === $_POST['action'] ) { return github_gist_simple_embed( $id ); } return $return; } /** * Use script tag to load shortcode in editor. * * @since 3.9.0 * * @param string $id The ID of the gist. * * @return string */ function github_gist_simple_embed( $id ) { $id = str_replace( 'json', 'js', $id ); return ''; }