Skip to content

Instantly share code, notes, and snippets.

@AdamSoucie
Created August 17, 2018 19:14
Show Gist options
  • Save AdamSoucie/6894ae91a9357f836bfde7700aac76e1 to your computer and use it in GitHub Desktop.
Save AdamSoucie/6894ae91a9357f836bfde7700aac76e1 to your computer and use it in GitHub Desktop.
Beaver Builder Gist Module - Front End
<?php
/**
* The frontend of the Gist Module.
*
* @package wds-gist
*/
// Get our fields.
$user_name = $settings->github_username;
$url = $settings->gist_url;
// Break up our URL.
$exploded = explode( '/', $url );
// Find the length of the exploded string array.
$length = count( $exploded );
// Grab the last item in the array.
$gist_id_index = $length - 1;
$gist_id = $exploded[ $gist_id_index ];
// Build the embed.
$embed = "<script src='https://gist.github.com/$user_name/$gist_id.js'></script>";
// Echo out the embed.
echo $embed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment