Skip to content

Instantly share code, notes, and snippets.

Avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / OrdersList.php
Created Jun 2, 2022
Speeds up the loading of /wp-admin/edit.php?post_type=shop_order and /wp-admin/edit.php?post_type=subscription.
View OrdersList.php
<?php
namespace UniversalYums\Admin\Performance;
class OrdersList {
/**
* The single instance of the class.
*/
protected static $instance;
@devinsays
devinsays / ActionSchedulerHighVolume.php
Last active Jun 3, 2022
Modifications to Action Scheduler in order to run higher volumes of actions.
View ActionSchedulerHighVolume.php
<?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 Nov 19, 2021
Dequeue scripts and styles
View performance.php
<?php
namespace DevPress\Frontend;
/**
* Class Performance
*
* @package DevPress\Performance
*/
class Performance {
@devinsays
devinsays / flag-renewal-orders.php
Created Oct 22, 2021
Example script that sets post_content = 'renewal' for renewal orders
View flag-renewal-orders.php
<?php
/**
* Flag historical renewal orders.
*
* wp eval-file flag-renewal-orders.php
*/
global $wpdb;
$last_processed = (int) get_transient( 'uy_last_processed_for_flagging' );
View categories-with-price-range.php
$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 Dec 8, 2021
Updates product prices via WP CLI script.
View update-product-prices.php
<?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 May 31, 2021
WooCommerce Export Product Data
View export-product-data.php
<?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
Deleted WooCommerce orders, subscriptions, and customers based on the IP address used to order.
View delete-fraud-activity-by-ip.php
<?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
*
@devinsays
devinsays / challenge.md
Last active Aug 16, 2021
WooCommerce MySQL Challenge
View challenge.md

Here's a couple MySQL challenges. No tricks or gotchas, just straightforward MySQL queries.

We generally use TablePlus when making SQL queries, but you can also use the command line or whatever you're most comfortable with.

Here's an example query to get all orders on WooCommerce site:

SELECT
	*
FROM
View PreventMetaCopy.php
<?php
/**
* Some meta data should not be copied to subscriptions or renewal orders.
*/
namespace UniversalYums\Subscriptions;
class PreventMetaCopy {
/**