Skip to content

Instantly share code, notes, and snippets.

Avatar

Greg Boggs Greg-Boggs

View GitHub Profile
View webhook.php
<?php
try {
$payload = json_decode($_REQUEST['payload']);
if ($payload->ref === 'refs/heads/master') {
$output = array();
// Pull Data
exec('cd /var/www && /usr/bin/git pull', $output);
print($output[0]);
@Greg-Boggs
Greg-Boggs / purge_cf.php
Last active Mar 27, 2020
PHP code to Purge Cloudflare Cache
View purge_cf.php
<?php
// Replace EMAIL/API_KEY/ZONE_ID with your details.
// Zone ID is on the dashboard for the domain in the bottom right.
// Api keys are generated from the account settings. You must give cache purge permissions
// Place this script on your webserver and point a Github Webhook at it, and you'll clear
// the Cloudflare cache every time you do a push to GH.
try {
$head = [];
$head[] = 'Content-Type: application/json';
View email.md

Hi First_Name,

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt exercitation ullamco est laborum.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

~G

@Greg-Boggs
Greg-Boggs / nav.php
Last active Jul 24, 2019
Nav component
View nav.php
<nav class="navbar navbar-default">
<!-- toggle -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
@Greg-Boggs
Greg-Boggs / breadcrumb-cache-example.php
Last active Jul 24, 2019
Expire the cache for Breadcrumbs when the page changes in Drupal 8
View breadcrumb-cache-example.php
<?php
// Expire the cache per url.
$breadcrumb->addCacheContexts(['url.path']);
// Expire cache context for config changes.
$breadcrumb->addCacheableDependency($this->config);
// Handle views path expiration cache expiration.
$parameters = $route_match->getParameters();
foreach ($parameters as $key => $parameter) {
@Greg-Boggs
Greg-Boggs / EasyBreadcrumb.html
Last active May 8, 2019
Easy Breadcrumb Release notes for 1.9
View EasyBreadcrumb.html
Release notes below.
@Greg-Boggs
Greg-Boggs / events.js
Last active Sep 10, 2020
Event tracking example with Google universal analytics
View events.js
jQuery(document).ready(function ($) {
// Track all link clicks internal and external
$('a').click(function(e) {
var linkUrl = e.target.href;
var linkText = $(this).text();
if (this.hostname && this.hostname !== location.hostname) {
ga('send', 'event', {
eventCategory: 'Outbound Link',
@Greg-Boggs
Greg-Boggs / events.js
Last active Apr 6, 2020
data layer tracking example
View events.js
jQuery(document).ready(function ($) {
// Track all link clicks internal and external
$('a').click(function(e) {
var linkUrl = e.target.href;
var linkText = $(this).text();
if (this.hostname && this.hostname !== location.hostname) {
dataLayer.push({
'event' : 'gaEvent',
@Greg-Boggs
Greg-Boggs / functions.php
Created Apr 12, 2018
Get the title of any page in Drupal 8
View functions.php
<?php
$title = $this->titleResolver->getTitle($route_request, $route_match->getRouteObject());
// Many paths return a translatable markup object.
if ($title instanceof TranslatableMarkup) {
// Sets the title to the translated string.
$title = $title->render();
}
@Greg-Boggs
Greg-Boggs / functions.php
Last active Apr 7, 2018
Helper function to get renderable region for Drupal 8
View functions.php
<?php
// Example usage: $build = blocks_get_blocks_by_region('sidebar_first');
function blocks_get_blocks_by_region($region_name) {
$build = [];
$blocks = entity_load_multiple_by_properties('block', ['theme' => $GLOBALS['theme'], 'region' => $region_name]);
uasort($blocks, 'Drupal\block\Entity\Block::sort');
foreach ($blocks as $key => $block) {
You can’t perform that action at this time.