Skip to content

Instantly share code, notes, and snippets.

View devinsays's full-sized avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / .gitignore
Created October 19, 2022 02:57
GitIgnore Example for WooCommerce
# Filetypes
*.sql
debug.log
.DS_Store
# Directories
node_modules/
/tmp/
/vendor/
@devinsays
devinsays / channel-logic.php
Last active October 4, 2022 19:51
Fulfil channel logic
<?php
/**
* Determine which Fulfil channel ID to use based on order type, source.
*
* @param Order $order Order to check
*
* @return mixed
*/
public static function getChannelId(Order $order)
{
@devinsays
devinsays / OrdersList.php
Created June 2, 2022 15:45
Speeds up the loading of /wp-admin/edit.php?post_type=shop_order and /wp-admin/edit.php?post_type=subscription.
<?php
namespace UniversalYums\Admin\Performance;
class OrdersList {
/**
* The single instance of the class.
*/
protected static $instance;
@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 / 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 / flag-renewal-orders.php
Created October 22, 2021 18:45
Example script that sets post_content = 'renewal' for renewal orders
<?php
/**
* Flag historical renewal orders.
*
* wp eval-file flag-renewal-orders.php
*/
global $wpdb;
$last_processed = (int) get_transient( 'uy_last_processed_for_flagging' );
@devinsays
devinsays / categories-with-price-range.php
Created September 25, 2021 21:06
Categories with price range
$cat_args = array(
'orderby' => 'name',
'order' => 'asc',
'hide_empty' => false,
);
$product_categories = get_terms( 'product_cat', $cat_args );
foreach ( $product_categories as $key => $category ) {
$range = reddit_get_category_price_range( $category->term_id );
@devinsays
devinsays / update-product-prices.php
Last active June 5, 2023 20:01
Updates product prices via WP CLI script.
<?php
/**
* Updates product prices.
* More about WP CLI scripts:
* https://wptheming.com/2021/05/wp-cli-scripts-and-woocommerce/
*
* wp eval-file update-product-prices.php
*/
$products = get_posts([
@devinsays
devinsays / export-product-data.php
Last active February 15, 2024 19:39
WooCommerce Export Product Data
<?php
/**
* Exports product data.
*
* More about WP CLI scripts:
* https://wptheming.com/2021/05/wp-cli-scripts-and-woocommerce/
*
* wp eval-file export-product-data.php
*/
@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
*