Skip to content

Instantly share code, notes, and snippets.

View labboy0276's full-sized avatar

John Ouellet labboy0276

View GitHub Profile
@labboy0276
labboy0276 / RebuildCache.php
Last active May 6, 2023 14:18
Drupal 8/9/10 Core Cache Rebuild
<?php
namespace Drupal\YOUR_MODULE\Commands;
use Drush\Commands\DrushCommands;
/**
* Rebuild the cache mechanism via drush.
*/
class RebuildCache extends DrushCommands {
@labboy0276
labboy0276 / docker-destroy-all.sh
Last active October 5, 2023 15:40
Purge all Docker Containers & Lando Cache
#!/bin/bash
echo 'Stopping Containers'
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
echo 'Deleting Containers'
@labboy0276
labboy0276 / terminus3-fatal-error-fix.patch
Last active December 7, 2021 15:09
Addresses Attempt to assign property "id" on null in phar:///usr/local/bin/terminus/src/Collections/TerminusCollection.php
diff --git a/src/Collections/TerminusCollection.php b/src/Collections/TerminusCollection.php
index 4f583f50..07443b1f 100644
--- a/src/Collections/TerminusCollection.php
+++ b/src/Collections/TerminusCollection.php
@@ -91,6 +91,10 @@ abstract class TerminusCollection implements ContainerAwareInterface, RequestAwa
public function fetch()
{
foreach ($this->getData() as $id => $model_data) {
+ if ($model_data === NULL) {
+ continue;
@labboy0276
labboy0276 / smush.patch
Created June 8, 2021 02:14
Smush PRO Bedrock patch
diff --git a/core/modules/class-cdn.php b/core/modules/class-cdn.php
index d86d910..2af3541 100644
--- a/core/modules/class-cdn.php
+++ b/core/modules/class-cdn.php
@@ -430,7 +430,7 @@ class CDN extends Abstract_Module {
$src = apply_filters( 'smush_filter_generate_cdn_url', $src );
// Support for WP installs in subdirectories: remove the site url and leave only the file path.
- $path = str_replace( get_site_url(), '', $src );
+ $path = str_replace( WP_HOME, '', $src );
@labboy0276
labboy0276 / stripe.php
Last active February 18, 2021 13:43
Gravity Forms Stripe Update Default Credit Card
/**
* Use with a form that has an update cc feed.
*/
function update_default_credit_card($entry, $form) {
if (get_user_meta( get_current_user_id(), 'stripe_customer_id', true ) !== '') {
// Get last 4 of cc entered. Replace with whatever entry field is your CC.
$last4 = str_replace('X', '', $entry["8.1"]);
// Init Stripe Client.
try {
@labboy0276
labboy0276 / gfapc-tweak.patch
Created May 19, 2020 14:13
GF Advanced Post Creation Add On Non Duplication Patch
diff --git a/class-gf-advancedpostcreation.php b/class-gf-advancedpostcreation.php
index 1c58a64..b5ae638 100644
--- a/class-gf-advancedpostcreation.php
+++ b/class-gf-advancedpostcreation.php
@@ -1793,14 +1793,19 @@ class GF_Advanced_Post_Creation extends GFFeedAddOn {
// Initialize uploaded files array.
$this->set_current_media();
- // Prepare post object.
- $post = array(
@labboy0276
labboy0276 / facetwp-alpha-filter.patch
Created May 12, 2020 17:02
Adds a filter to the FacetWP Alpha output
diff --git a/class-alpha.php b/class-alpha.php
index b70c8b1..76b888a 100644
--- a/class-alpha.php
+++ b/class-alpha.php
@@ -86,7 +86,7 @@ class FacetWP_Facet_Alpha_Addon extends FacetWP_Facet
}
}
- return $output;
+ return apply_filters( 'facetwp_alpha_render', $output );
@labboy0276
labboy0276 / domdocument.php
Created May 6, 2020 17:19
WordPress (or any PHP framework) DomDocument HTML output alter
<?php
/**
* Use to easily alter HTML Output.
*/
class MarkupAlter {
/**
* The content we are altering.
*
@labboy0276
labboy0276 / composer-private-github-platformsh.md
Created May 5, 2020 19:39
Using a GitHub Personal Access Token for Private Composer Packages on Platform.sh
  1. Visit https://github.com/settings/tokens.

  2. Click Generate new token

  3. Use the repo scope and give it a name.

  4. Run this command:

platform variable:create --project PROJECT-ID --level project --name env:COMPOSER_AUTH \
@labboy0276
labboy0276 / header.html.twig
Created February 4, 2020 14:00
Bootstrap 4 - Drupal 8 vanilla JS menu
<header id="header" class="header" role="banner" aria-label="{{ 'Site header'|t}}">
<nav class="navbar navbar-expand-lg fixed-top" id="main-navbar">
<div class="navbar-brand d-lg-none d-xl-none">YOUR SITE NAME</div>
<button id="navbar-toggler-id" class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#CollapsingNavbar" aria-controls="CollapsingNavbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="CollapsingNavbar">
{{ page.primary_menu }}
</div>
</nav>
</header>