Skip to content

Instantly share code, notes, and snippets.

View WPprodigy's full-sized avatar
🖥️
🍕🍕🍕

Caleb Burks WPprodigy

🖥️
🍕🍕🍕
View GitHub Profile
@WPprodigy
WPprodigy / functions.php
Created January 25, 2017 23:52
Add an extra button on single product pages in WooCommerce
add_action( 'woocommerce_after_add_to_cart_button', 'wc_ninja_add_extra_button', 20 );
function wc_ninja_add_extra_button() {
echo "<a href='#' class='button'>Return to shop</a>";
}
@WPprodigy
WPprodigy / ignore-cron-events.php
Created December 23, 2022 09:50
Prevent certain cron events from existing
<?php
function get_cron_events_to_ignore() {
return [
'a8c_cron_control_force_publish_missed_schedules',
'a8c_cron_control_confirm_scheduled_posts',
];
}
// If an ignorable cron event runs, let's unschedule it so it runs no more.
@WPprodigy
WPprodigy / functions.php
Last active December 4, 2022 16:17
Change add to cart button text in WooCommerce if product is on backorder.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wc_ninja_change_backorder_button', 10, 2 );
function wc_ninja_change_backorder_button( $text, $product ){
if ( $product->is_on_backorder( 1 ) ) {
$text = __( 'Pre-Order', 'woocommerce' );
}
return $text;
}
@WPprodigy
WPprodigy / functions.php
Created January 20, 2016 17:11
Remove the password strength meter from WooCommerce checkout
function wc_ninja_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 );
@WPprodigy
WPprodigy / functions.php
Last active June 23, 2022 23:25
WC backend performance enhancements
<?php
// We don't need this query to run if it's asking for all comments (post_id = 0).
add_filter( 'wp_count_comments', function ( $count, $post_id ) {
if ( 0 === $post_id ) {
$stats = array(
'approved' => 0,
'moderated' => 0,
'spam' => 0,
'trash' => 0,
@WPprodigy
WPprodigy / wp-create
Created December 21, 2019 08:11
WP local site creation script. Made for use with https://laravel.com/docs/6.x/valet
#!/bin/bash
# Usage: wp-create sitename
if [ $# -eq 0 ]; then
echo "Need to provide the directory name to be created."
exit 1
fi
# set up new folder to house the WP install
@WPprodigy
WPprodigy / plugin.php
Last active March 10, 2022 08:17 — forked from joncave/plugin.php
An intentionally vulnerable plugin developed for WordPress plugin author education.http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* Text Domain: damn-vulnerable-wordpress-plugin
* License: GPLv2+
*
@WPprodigy
WPprodigy / action-scheduler.php
Last active November 17, 2021 09:48
Dynamic Queue adjustments for autoscaling Action Scheduler.
<?php
/*
* Dynamic Queue adjustments for autoscaling Action Scheduler.
*
* Every few minutes, this checks to see if the AS queue has exceeded a certain
* threshold of "due now" actions. And if so, will schedule additional queues to run
* concurrently in cron until the queue is caught up.
*
* Scales directly off of cron control's JOB_CONCURRENCY_LIMIT.
@WPprodigy
WPprodigy / functions.php
Created February 7, 2018 04:02
Add Customer Notes column back to orders page.
<?php
add_filter( 'manage_shop_order_posts_columns', 'wc_define_columns', 15 );
function wc_define_columns( $columns ) {
$columns['customer_notes'] = __( 'Customer Notes', 'woocommerce' );
return $columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'wc_render_customer_notes_column', 10, 2 );
function wc_render_customer_notes_column( $column, $post_id ) {
<?php
/**
* Plugin Name: Conditional WooCommerce Checkout Fields
* Description: Adds the abilitiy to conditionally show / hide checkout fields.
* Version: 1.0
* Author: Caleb Burks
* Author URI: http://calebburks.com
*/