Created
August 17, 2018 19:14
-
-
Save AdamSoucie/6894ae91a9357f836bfde7700aac76e1 to your computer and use it in GitHub Desktop.
Beaver Builder Gist Module - Front End
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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