Skip to content

Instantly share code, notes, and snippets.

View devinsays's full-sized avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / devpress-price-testing.php
Created April 4, 2025 20:51
DevPress Price Testing - A one file WordPress plugin for testing pricing in WooCommerce.
<?php
/**
* Plugin Name: DevPress Price Testing
* Plugin URI: https://devpress.com
* Description: A plugin to test different pricing variants based on cookies.
* Version: 1.0.0
* Author: DevPress
* Author URI: https://devpress.com
* Text Domain: devpress-price-testing
*
@devinsays
devinsays / example-ajax-enqueue.php
Last active January 27, 2025 15:51
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array( 'jquery' )
);
@devinsays
devinsays / sync.sh
Created January 20, 2025 20:04
Sync - Partial DB sync
#!/bin/bash -e
# Default false for flags
db=false
uploads=false
overwrite=false
# Checks for flags
while getopts dupo option
do
@devinsays
devinsays / performance.php
Created November 19, 2021 18:17
Dequeue scripts and styles
<?php
namespace DevPress\Frontend;
/**
* Class Performance
*
* @package DevPress\Performance
*/
class Performance {
@devinsays
devinsays / delete-customers-without-orders.php
Created January 13, 2024 19:45
Deletes users with customer role in WooCommerce that do not have orders.
<?php
/**
* Deletes customers without orders
*
* To run the script:
* wp eval-file delete-customers-without-orders.php
*/
// Query for customers registered since this date.
$date_after = '2000-01-01';
@devinsays
devinsays / gist:a7da04026f99e84d801841e410f18d0b
Created October 31, 2024 13:55
Header Banner Custom Styles
.page-header {
background-color: #f3f3f7;
background-repeat: no-repeat;
background-position: right center;
background-size: auto 375px;
height: 375px;
// 600px viewport
@include breakpoint(m-lg) {
background-size: auto 600px;
@devinsays
devinsays / ActionSchedulerHighVolume.php
Last active September 21, 2024 15:47
Modifications to Action Scheduler in order to run higher volumes of actions.
<?php
/**
* High volume modifications to Action Scheduler.
*
* Adapted from https://github.com/woocommerce/action-scheduler-high-volume/
*
* Increase Action Scheduler batch size, concurrency, timeout period, and claim action query
* ORDER BY to process large queues of actions more quickly on servers with more server resources.
*
* @package UniversalYums\ActionScheduler
@devinsays
devinsays / custom_edd_sl_license_response
Last active September 5, 2024 01:48
Allow "Package" downloads. Multiple file downloads using the same license.
/**
* This code requires one additional filter param to be added to edd_sl_license_response in EDD_Software_Licensing.php:
* $response = apply_filters( 'edd_sl_license_response', $params, $download, $data)
*/
/**
* Allows EDD to bypass the name check for files
*/
define( 'EDD_BYPASS_NAME_CHECK', true );
@devinsays
devinsays / woocommerce-cart-restrictions.php
Created November 6, 2017 23:40
Restricts which items can be added to cart based on whether a specific item is already in the cart or being added to the cart.
<?php
/**
* WooCommerce code snippet that restricts which items can be added to cart:
*
* 1) The $trial_product should not be added to cart if existing items are in the cart.
* 2) Other products should not be added to cart if $trial_product is already in cart.
*/
function example_cart_filtering( $passed_validation, $product_id ) {
// ID of the trial product
@devinsays
devinsays / delete-fraud-activity-by-ip.php
Created May 7, 2021 16:52
Deleted WooCommerce orders, subscriptions, and customers based on the IP address used to order.
<?php
/**
* This script will delete all `on-hold` subscriptions and their orders and users.
* It will delete all subscriptions based on IP.
*
* wp eval-file delete-fraud-activity-by-ip.php 127.0.0.1
*
* Dry run:
* wp eval-file delete-fraud-activity-by-ip 127.0.0.1 dry
*