Workaround to make plugin work with Amp
File to be modified:
plugins/oembed-gist/oembed-gist.php
Search for Code
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
return sprintf( __( '<a href="%s">See the gist on github</a>.', 'oembed-gist' ), esc_url( $url ) );
}
and Replace with
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
if (!empty($p['id']) && !empty($p['file'])){ //@am changes to make this working with AMP Plugin
$gid = $p['id'];
$gfile = $p['file'];
return'<amp-gist data-gistid="'.$gid.'"
data-file="'.$gfile.'"
layout="fixed-height"
height="197">
</amp-gist>';
}else{
return sprintf( __( '<a href="%s">See the gist on github</a>.', 'oembed-gist' ), esc_url( $url ) );
}
}
Note this works if you are adding Shortcode in this format
[gist id="1231e04bc25e66a77c5487d4cdb65e4r3" file="xyz-file"]
Note You need to add
<script async custom-element="amp-gist" src="https://cdn.ampproject.org/v0/amp-gist-0.1.js"></script>
in theme header
For details visit amp doc
https://amp.dev/documentation/examples/components/amp-gist/
Gist embeds weren’t working for me.
I had to remove a $ in the regex. My new regex string is:
private $regex = '#(https://gist.github.com/([^\/]+\/)?([a-zA-Z0-9]+)(\/[a-zA-Z0-9]+)?)(\#file(\-|_)(.+))?#i';
Not sure how that happened or maybe if something in WP changed.
I wonder if I can take over this plugin to fix it up.
]]>Is there a way to make this plugin show your gists on mobile?
]]>I have problems with some Gist URLs, randomly, not getting converted to code if I’m working on a considerable big blog post.
]]>I am unable to embed single files from gists.
I used the string:
https://gist.github.com/leogdion/7837a0f1fe21b66d441a3ce601d89d84#querying-changes-watchOS4.swift
Thanks
]]>Is it possible to set a max amount of lines, before having it scroll? I have a rather long Gist I need to display, but don’t want my post to be super long. So it would be nice if it could just scroll vertically (already does horizontally).
]]>The gits will not oembed
]]>Hi,
the translation in your plugin file is not the same as in your .pot file.
In your code it’s
__( 'View the code on <a href="%s">Gist</a>.', 'oembed-gist' )
and while creating a translation file I get this string:
<p>View the code on <a href="https://gist.github.com/%s">Gist</a>.</p>
Checking the error logs on our site today and see many lines like this:
[Tue Apr 11 15:59:07.388437 2017] [:error] [pid 1899] [client 66.249.64.190:59399] PHP Warning: Illegal string offset 'id' in /nas/content/live/artandlogic/wp-content/plugins/oembed-gist/oembed-gist.php on line 129
Any ideas on what the issue might be?
]]>Would LOVE it if you guys implemented AMP Integration into the plugin. It will allow the shortcodes to be allowed in AMP pages.
Here’s How: https://github.com/Automattic/amp-wp#handling-media
Any idea on implementation for this? I know GistPress is working on it.
]]>Thanks for the nice plugin. I’m using it for one of my site, and it’s awesome.
I want to highlight multiple lines, not in a row
I know I can highlight lines in gist like
gist-url-L6-L9
will highlight from line#6 to line#9,
But none of them is working with oEmbed Gist:
If this can be added, it’d be awesome. <3
]]>Hi,
I am having a trouble with oembed gist plugin. It doesnt work if the url ends with a html dom element. The example is below:
<li>https://gist.github.com/SmartfaceDocs/d45b42a18e18f6c75bdd#file-structure-m</li>
It recognize the url like that “https://gist.github.com/SmartfaceDocs/d45b42a18e18f6c75bdd#file-structure-m</li>
” and boom!
The solution might be adding another option for the plugin. I mean shortcode. If i write [gist_url] -with the brackets- it should have done the same thing. Enchanced regexp.
Thanks in advance.
]]>When trying to embed multiple gists some of the gists (even though they are copied from the exact same location) come up with 404 errors.
Offending page: https://gregoryamcmullen.com/coding/updated-structured-umbraco-page-titles/
]]>The RSS reader doesn’t support JavasSript, so there is nothing in reader view. But there should be a message to tell visitor to open the blog page, or leave the origin gist link.
BTW, could I join you, and resolve this as an developer?
]]>Take a look at the screen:
Does not work, it is not possible to see brackets ;/
Thanks in advance for your support ! !
]]>Here is my gist link:
https://gist.github.com/khromov/9d01c608e7b237719a4e
It doesn’t seem to be matched by the regex, not sure why it’s not working.
]]>Very nice plugin there ! Thank you !
Is there any chance to get this work from a simple shortcode
[gist]myurl[/gist] so it could be used in others shortcodes ??
Lionel
]]>Hi,
I’m using this plugin for the first time and I have mixed succes.
This URL works:
https://gist.github.com/eNeRGy164/519ab4ac95122c60ce60
But I’m having trouble with the following URL’s:
https://gist.github.com/eNeRGy164/519ab4ac95122c60ce60#file-pulldowntorefreshpanel1-cs (permalink)
https://gist.github.com/eNeRGy164/519ab4ac95122c60ce60#file-pulldowntorefreshpanel1-cs-L8 (highlight Line 8)
What am I doing wrong?
]]>On my site, this plugin still seems to be working just fine with normal gist URLs, such as https://gist.github.com/cgrymala/5457bc5309c4bb6c81a9. However, if I try to embed a gist revision, where the URL structure looks like https://gist.github.com/cgrymala/5222d7a7d543866a1b0e/6a4bcbece7ff0177f9ba481b307fc4fabf1d8da7, it just ignores it altogether and I end up with a plain-text URL in my post.
If I then wrap that URL in [embed][/embed]
shortcodes, it at least auto-links the URL, but still doesn’t actually embed it.
Hey, you didn’t update your changelog properly with your 1.7 and 1.71 updates ??
]]>This plugin also works with WordPress 3.9.1. I tested now.
]]>If you upgrade to JetPack 2.9, then this plugin will stop working. It appears that JetPack has added Gist shortcodes or something to their code and it is causing this plugin to stop working.
I’ve found a fix and posted it to GitHub.
https://gist.github.com/rickrduncan/9142909
Thanks,
Rick
https://www.rickrduncan.com
Testing this plugin with HTML 5 and it simply doesn’t display anything.
I pasted the url on a separate line
]]>‘#https://gist.github.com/([a-zA-Z0-9]+)(\#file_(.+))?$#i’, need to be changed
]]>It seems like the URL structure for gists have been updated. I created a gist yesterday, that wasn’t embedded, unless I removed my username: https://gist.github.com/gish/4754219 -> https://gist.github.com/4754219
I believe an update of the plugin is necessary
]]>Seems with github’s changes to gists behaviour, embeding a single file form a gist does not work any more.
]]>