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 / .lando.yml
Last active December 11, 2023 02:22
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 <matt.neal@stafflink.com.au>
* @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
*/
@mattneal-stafflink
mattneal-stafflink / update_user_groups.php
Created June 2, 2021 23:34
Assigns a newly registered user to a LearnDash group. Must be registered through a gravity forms form.
<?hp
/**
* Assign the user to their selected groups. Comment out what is not used where possible.
* usage: ld_update_group_access('Id of user (found in $user_id), 'id of group:bool (enter manually after creating group', false);
* $entry[7] is the form line 7. In this case, it is a single select drop down.
*
* @since 1.0.0
*/
add_action( 'gform_user_registered', 'update_user_groups', 10, 4 );
@mattneal-stafflink
mattneal-stafflink / is_valid_email_domain.php
Created June 2, 2021 23:24
Check if the submitted email on the register process is valid. Runs right before registering a user.
<?php
/**
* Check to ensure the users' email address matches the allowed list.
* Update the $valid_email_domains array to a comma separated list of string email addresses.
*
* @since 1.0.0
*/
function is_valid_email_domain($login, $email, $errors ) {
$valid_email_domains = array("imageproperty.com.au","stafflink.com.au");// whitelist email domain lists