Skip to content

Instantly share code, notes, and snippets.

Avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / schedule-products-sale.php
Created Nov 23, 2022
WP CLI script schedule a product sale in WooCommerce.
View schedule-products-sale.php
<?php
/**
* WP CLI script to schedule a sale for specific dates.
*
* To support scheduled sales to the hour/minute, use this free plugin:
* https://wordpress.org/plugins/precise-sales-for-woocommerce/
*
* wp eval-file schedule-products-sale.php
*/
if ( ! defined( 'ABSPATH' ) ) {
@devinsays
devinsays / coupon-generator.php
Last active Nov 2, 2022
WP CLI script for generating coupon copies
View coupon-generator.php
<?php
/**
* Generate coupon copies from an existing coupon.
* Replaces UNQCODE with a unique generated coupon code.
*
* For more information about this script:
* https://devpress.com/wp-cli-script-to-duplicate-woocommerce-coupons/
*
* wp eval-file coupon-generator.php
*/
@devinsays
devinsays / sync-config.sh
Created Oct 21, 2022
Bash script for syncing WP Engine production to local
View sync-config.sh
sshenv=yoursite
replace=('yoursite.com' 'yoursite.local')
@devinsays
devinsays / .gitignore
Created Oct 19, 2022
GitIgnore Example for WooCommerce
View .gitignore
# Filetypes
*.sql
debug.log
.DS_Store
# Directories
node_modules/
/tmp/
/vendor/
@devinsays
devinsays / channel-logic.php
Last active Oct 4, 2022
Fulfil channel logic
View channel-logic.php
<?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 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 );