Github Get a plugin for WordPress


GitHub Get was born as a personal need to embed code from GitHub in WordPress. GitHub Get uses the WordPress HTTP API, basic authentication and Personal access tokens for consuming GitHub Restful services. Among the features of GitHub Get we can mention

  • It allows to embed code from a Repository or Gist
  • It allows to embed code from a public or private Repository or Gist
  • Based on shortcode syntax
  • Caches the response using the native set_transient WordPress function, this allows to use the plugin on heavy load sites. If the Repo file or Gist changes it is not necessary to clean the cache, GitHub Get detects the change and updates the cache showing the updated version.
  • Easy to use and setup.
  • Compatible with WP Code Highlight.js
  • Free software, released under the GPL v3.

Install and configure

The development model is based on a single branch (master) and each version is marked by a commit in the form: Release vx.x.x and a tag in the form: vx.x.x. This simple development model allows me to use GitHub Updater for get changes from one version to another. If you do not use GitHub Updater you can download the zipped from GitHub and follow the procedure described in Manual_Plugin_Installation


  1. Login to the WordPress Admin Panel
  2. Menu > Settings > GitHub Get
  3. Specify the user and GitHub Personal access tokens
  4. Save


[ghget attr=val]content[/ghget]


The content value for a Gist is the identifier of the Gist (the hash). In the case of a file that is in a repo is the path of the file within the repo. To find the path, navigate to the repository from GitHub until you find the file, then use the function "Copy path", paste the result in a text editor before to copy it  in the WordPress editor (WordPress visual editor will copy the complete URL and we only need the path of the file).


All attributes are optional. You can specify the following attributes (default values are in bold)

  • ribbon = true | false. Show GitHub ribbon.
  • repo = true | false, true to embed a file that is in a repository.
  • container = container | ". Allows to specify the container of the embedded file. This attribute accepts a string with the following format: container1(classes){inline styles}.container2(classes){inline styles}. Useful when used with ribbon = true because it will show the ribbon out of the container.
  • filename = gist-file-name |". If you have a Gist with multiple files you can specify what file you want to embed otherwise embed the first found.
  • account = github-account-name = | ". By default GitHut Get will get the content of the file using the credentials provided in the configuration. This parameter overrides this behavior allowing you to embed content from any public repo or gist.
  • htmlenc = true | false. By default, apply the htmlspecialchars function to avoid the browser renders html tags if you want to change this behavior, set the value of this attribute in false.
  • Examples

    To embed content from GitHub insert the shortcode in a Post or Page.

    Embedding content from a Repo

    [ghget repo="true" container=pre.code(perl)]sysadmin/pscript/filereader[/ghget]
    #!/usr/bin/env perl
    # This script is released under GPL V2+
    open(FILEREAD, "< /home/yoander/projects/cake/.perms");
    my @arr;
    while (<FILEREAD>) {
    	my($line) = $_;
    close FILEREAD;
    exit join(' ',@arr); 

    Using the filename attribute for a Gist with multiple files

    [ghget  filename="file2.yaml" container=pre(yaml)]ca53e97e02cbd4e24dc2babc9b676bb7[/ghget]
    firstName: John
    lastName: Smith
    age: 25
    job: Software Developer
      streetAddress: 21 2nd Street
      city: New York
      state: NY
      postalCode: 10021
    - type: home
      number: 212 555-1234
    - type: fax
      number: 646 555-4567
      type: male

    Using the account attribute

    [ghget repo="true" account=symfony container=pre(markdown)]symfony/[/ghget]
    <p align="center"><a href="" target="_blank">
        <img src="" alt="Symfony Logo">
    [Symfony][1] is a **PHP framework** for web and console applications and a set
    of reusable **PHP components**. Symfony is used by thousands of web
    applications and most of the [popular PHP projects][2].
    * [Install Symfony][4] with Composer (see [requirements details][3]).
    * Symfony follows the [semantic versioning][5] strictly, publishes "Long Term
      Support" (LTS) versions and has a [release process][6] that is predictable and
    Symfony 7.1 is [backed][27] by
    - [Rector][29]
    - [JoliCode][30]
    - [][31]
    **Rector** helps successful and growing companies to get the most of the code
    they already have. Including upgrading to the latest Symfony LTS. They deliver
    automated refactoring, reduce maintenance costs, speed up feature delivery, and
    transform legacy code into a strategic asset. They can handle the dirty work,
    so you can focus on the features.
    **JoliCode** is a team of passionate developers and open-source lovers, with a
    strong expertise in PHP & Symfony technologies. They can help you build your
    projects using state-of-the-art practices.
    **** is a team of 70+ Symfony experts who can help you design, develop and
    fix your projects. They provide a wide range of professional services including development,
    consulting, coaching, training and audits. They also are highly skilled in JS, Go and DevOps.
    They are a worker cooperative!
    Help Symfony by [sponsoring][28] its development!
    * Read the [Getting Started guide][7] if you are new to Symfony.
    * Try the [Symfony Demo application][23] to learn Symfony in practice.
    * Discover Symfony ecosystem in detail with [Symfony The Fast Track][26].
    * Master Symfony with the [Guides and Tutorials][8], the [Components docs][9]
      and the [Best Practices][10] reference.
    * [Join the Symfony Community][11] and meet other members at the [Symfony events][12].
    * [Get Symfony support][13] on GitHub Discussions, Slack, etc.
    * Follow us on [GitHub][14], [Twitter][15] and [Facebook][16].
    * Read our [Code of Conduct][24] and meet the [CARE Team][25].
    Symfony is an Open Source, community-driven project with thousands of
    [contributors][19]. Join them [contributing code][17] or [contributing documentation][18].
    Security Issues
    If you discover a security vulnerability within Symfony, please follow our
    [disclosure procedure][20].
    About Us
    Symfony development is led by the [Symfony Core Team][22]
    and supported by [Symfony contributors][19].

    Exotic example

    In this example we will use the attribute container creating 2 div and giving styles to create a quote effect

    [ghget htmlenc=false container="div(myclass1){border-left:3px solid #2196f3;font-style:italic;}.div{background-color:#ddffff;padding:7px;}(myclass2)"]a9507adb2aa40a23ca7daa1d06ef183a[/ghget]
    GNU Manifesto
    GNU, which stands for Gnu's Not Unix, is the name for the complete Unix-compatible software system which I am writing so that I can give it away free to everyone who can use it.
    Richard Stallman.


    If GitHub Get cannot get the desired file it will display an informational message in order to give you any hints about what may be wrong.

    Invalid Repo file name

    Invalid repo file: sysadmin/shscript/acl-webdev1 (Not Found), Repos

    Invalid Gist file name

    Invalid file name: file2.json, Gist

    Invalid Gist hash

    Invalid Gist: ca53e97e02cbd4e24dc2babc9b676bbss7 (Not Found), Gists

    As a final note, it is recommended to use this plugin together with Transients Manager so that you can clear the cache if you wish. All the cache keys have the ghget word

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.