Skip to content

Instantly share code, notes, and snippets.

View mattneal-stafflink's full-sized avatar

Matthew Neal mattneal-stafflink

View GitHub Profile
@mattneal-stafflink
mattneal-stafflink / env-plugin-manager-readme.md
Last active November 15, 2024 00:15
Plugin Manager Documentation

Plugin Manager MU-Plugin

The Plugin Manager is designed to enforce the activation and deactivation of specific plugins based on the environment in which your WordPress site is running. It allows you to specify:

  • Plugins to activate per environment.
  • Plugins to deactivate per environment.

Installation

  1. Add the plugin to your mu-plugins directory. Get it here.
@mattneal-stafflink
mattneal-stafflink / env-plugin-manager.php
Created November 14, 2024 23:29
Force active/inactive plugins based on your WP_ENV.
<?php
/*
Plugin Name: ENV Plugin Manager
Description: Enforces activation and deactivation of specific plugins based on environment. Add your plugins to the appropriate environment array in this file.
Version: 1.1
Author: Matthew Neal
Author URI: https://realcoder.com.au/
*/
// Exit if accessed directly.
@mattneal-stafflink
mattneal-stafflink / .lando.yml
Last active May 22, 2024 12:40
Lando Performant Config For WordPress/Bedrock.
name: {{ WEBSITE NAME }}
recipe: wordpress
env_file:
- .env.example
- .lando.env
excludes:
- vendor
- node_modules
config:
php: "8.2"
@mattneal-stafflink
mattneal-stafflink / Bootstrap5NavWalker.md
Created November 22, 2023 23:05 — forked from smutek/Bootstrap5NavWalker.md
Bootstrap 5 Nav Walker for Sage 10

Bootstrap 5 Walker for Sage 10

Adds Bootstrap 5 css classes to the nice Soil nav walker in a Sage 10 project.

Assumptions

  • Assumes you're using Sage 10.
  • Assumes the Roots/Soil plugin is installed and activated.
  • Assumes Tailwind has been removed from the Sage project and Bootstrap 5 has been added.
@mattneal-stafflink
mattneal-stafflink / _hubspot-boostrap.scss
Last active October 19, 2023 04:32
BootStrap 5 styling for HubSpot forms
.hs-form {
.hs-button.primary {
@extend .btn;
@extend .btn-primary;
}
.hs-dependent-field {
@extend .w-100;
}
@mattneal-stafflink
mattneal-stafflink / .gitignore
Created September 26, 2022 04:03
WordPress SpinupWP LocalWP Specific Gitignore
# Ignore Packages
vendor/
node_modules/
# ignore all files starting with . or ~
.*
~*
# Don't ignore these ones though...
!.env.example
@mattneal-stafflink
mattneal-stafflink / save_partial_hubspot.php
Created January 19, 2022 05:01
Save partial entries to Hubspot
<?php
// Fires when Gravity Forms saves a partial entry
add_action( 'gform_partialentries_post_entry_saved', 'matt_neal_is_god', 10, 2 );
function matt_neal_is_god( $partial_entry, $form ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
// If we have Gravity Forms Hubspot extention...
if ( function_exists( 'gf_hspot' ) ) {
$partial_entry['status'] = 'partial';
GFCommon::log_debug( __METHOD__ . '(): trigger Hubspot for Partial Entry: ' . print_r( $partial_entry, true ) );
@mattneal-stafflink
mattneal-stafflink / delete_post_media.php
Created October 6, 2021 10:03
Delete attached media when deleting custom post type called "Property".
add_action( 'before_delete_post', 'delete_all_attached_media' );
function delete_all_attached_media( $post_id ) {
if( get_post_type($post_id) == "property" ) {
$attachments = get_attached_media( '', $post_id );
foreach ($attachments as $attachment) {
wp_delete_attachment( $attachment->ID, 'true' );
}
@mattneal-stafflink
mattneal-stafflink / sl_email_domain_validator.php
Created June 2, 2021 23:40
Restrict email addresses on Gravity forms register sign up.
<?php
/*
*
* Include a list of valid domains for Gravity Form Email fields.
*
* @version 1.4
* @author Matt Neal <[email protected]>
* @license GPL-2.0+
*/
@mattneal-stafflink
mattneal-stafflink / my_forcelogin_bypass.php
Created June 2, 2021 23:36
Allow /register to be accessed when using forcelogin plugin.
<?php
/**
* Bypass Force Login to allow for exceptions. Used to push everyone to the login page, except if they are registering.
* As it stands, this code allows the forcelogin plugin to ignores /register.
*
* @param bool $bypass Whether to disable Force Login. Default false.
* @param string $visited_url The visited URL.
* @return bool
*/