Skip to content

Instantly share code, notes, and snippets.

@RichardNesbitt
RichardNesbitt / getImages.py
Created April 5, 2024 00:25
Get urls of images on sub-pages using Python
#This script still contains all of the print() outputs that I used while refining and debugging it.
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from urllib.parse import urljoin
@RichardNesbitt
RichardNesbitt / functions.php
Created December 6, 2020 08:52
Add user to LearnDash groups when they purchase products.
<?php
function jsforwp_add_user_to_group( $order_id ) {
//$group_rules contains settings in the format of product_id => array(groupid, groupid, groupid)
$group_rules = array(
26325 => array(26346, 26348, 26349),
26329 => array(26346, 26348, 26349),
26327 => array(26351, 26353, 26354),
23661 => array(26351, 26353, 26354),
26138 => array(26359),
@RichardNesbitt
RichardNesbitt / functions.php
Created December 6, 2020 08:50
WooCommerce - enable multiple products in add-to-cart query string
<?php
/*
I yoinked this off of Stack Overflow. it was buried in the comments, but it works flawlessly.
I'm making some small modifications, which I'll update here as I go.
*/
//enable multiple add to cart
//use syntax ?add-to-cart=1111,2222,3333
function woocommerce_maybe_add_multiple_products_to_cart() {
@RichardNesbitt
RichardNesbitt / config.php
Created April 6, 2020 07:23
Stop direct access to PHP file in the most annoying way like for wp-config.php or config.php or database.php or any other protected file.
<?php
//just make sure you include $authtoken before you call this file anywhere or you'll be really annoyed!
if(!isset($authtoken)){
for($i=0;$i<1000;$i++){
echo "<script>alert('why for are you haxing mi???');</script>";
}
die("You are not authorized to view this page!!!");
}
@RichardNesbitt
RichardNesbitt / functions.php
Last active February 13, 2024 22:16
Add custom post type to BeTheme by Muffin Group
//add this to your functions.php or include it there from another file.
function mytheme_includes() {
if (! class_exists('Mfn_Post_Type_Video')) { //change references to 'Video or video' to your post type
class Mfn_Post_Type_Video extends Mfn_Post_Type
{
/**
* Mfn_Post_Type_Video constructor
@RichardNesbitt
RichardNesbitt / header.php
Created March 26, 2020 20:01
Custom COVID-19 Header managed in WPBakery Page Builder (formerly Visual Composer)
/*
* place this just inside your theme's <header> tag,
* or above the header and menus if you're theme isn't following proper html5 recommendations
*
* I used CPTUI to create a custom post type of 'COVID-19 Header',
* and then enabled the post type in WPBakery Page Builder > Role Manager
*
* Grab the 'post_id' of the post you create, and use it in the code below
*
* You'll need to give your block elements class names, and write your own CSS. 'Design Tab' settings won't work.
@RichardNesbitt
RichardNesbitt / functions.php
Created March 9, 2020 06:50
WP Bakery Page Builder - Custom Background Parameters for vc_column_inner
/*
Add the following to your theme's functions.php file
In this case, I wanted to add a background image outside of the normal controls
so I could darken it by a % using linear gradients.
I added 2 fields to vc_column_inner:
*/
// The background image
vc_add_param("vc_column_inner", array(
@RichardNesbitt
RichardNesbitt / form-checkout.php
Created December 29, 2019 05:36
Example of some custom validation rules for woocommerce checkout page. Forcing names to match account holder, custom rules based on shipping classes and shipping locations.
<?php
## add this to /wp-content/[your-theme]/woocommerce/checkout ##
/**
* Checkout Form
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-checkout.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
@RichardNesbitt
RichardNesbitt / functions.php
Last active April 23, 2024 09:06
WP Bakery Page Builder - Add URL option to make entire column clickable - Updated 22 June 2023
<?php
/* add this to your theme's functions.php file */
/* Add option for URL to column settings */
vc_add_param("vc_column", array(
"type" => "vc_link",
"class" => "",
"heading" => "Column Link",