Google Docs Embed Shortcode

  • Author
  • #564647


    How about a shortcode to easily embed Google Docs. Perhaps something like this:

    [gdoc 0B5jR2HibJE1COTI0ODliM2MtOTFkZC00YjVhLWI0ZmItOWQxMjQ0NzM1Y2M5]



    Hello there,
    If you wish you can send you suggestion directly to Staff.



    This is an excellent idea. I hadn’t realised it was possible to embed Google Docs until now, but it seems you can “publish as a web page” which provides you with a URL which looks like this:

    Unfortunately it doesn’t provide an embed code to use which is kinda annoying, but the posts could either be parsed to look for a URL string like that and automatically turn it into a shortcode, or the end-users could be made to make the shortcode themselves. I’d be more inclined to go for the latter.

    If I find some spare time this evening I might make whip together some code to do this as it seems like a really great idea.



    Actually, it seems that word processor documents DO provide an embed code. The spreadsheets however do not.



    Here’s a new plugin which adds support for this feature:

    The first 40 characters of the URL string in the embed code is checked against a white list of known Google Docs to ensure that only specific Google Docs sub-domains are being used and then parses the URL through esc_url() to strip out any other potential nasties.

    Feel free to use the code, just let me know if you do make use of it and if you make any changes/improvements I’d love to hear about those too :) …

    In particular, this plugin needs that autoembed functionality so that users can just dump the embed codes (for the Google Docs that support it) rather than having to figure out the shortcode syntax.

    I may have missed some strings for the white list. I didn’t look very hard for various combinations, I just opened up a bunch of docs and grabbed what I saw. It’s highly likely I’ve missed a couple.




    Plug-in’s are not allowed on WordPress.COM so your Post is very misleading to users here.

    Your Plug-in flat will not work and can not be installed here.



    It is not misleading in the slightest. My plugin would work. Whether I can install it here myself or not is irrelevant.

    This is the ideas forum, hence I’m posting it here as an idea for to implement.



    Sorry if that came across a little blunt. It’s 3am and I’m too sleepy to find an edit button.

    I’m aware of where I’m posting this. But since it’s in the ideas forum and I was already writing the code anyway, it seemed like the most sensible place to post it.



    Moderator Emeritus


    To be very clear:
    Plug-ins are not allowed here on wordpress.COM. We volunteers in the forums have no authority to change that.

    So as not to confuse wordpress.COM users, please follow the link timethief and justjennifer provided:

    Because further discussion would not be useful, I’ll close this thread.


The topic ‘Google Docs Embed Shortcode’ is closed to new replies.