Skip to content

Instantly share code, notes, and snippets.

View scotcrop's full-sized avatar

Scott scotcrop

View GitHub Profile
@devinsays
devinsays / staging-update-routine.php
Last active February 7, 2021 15:02
staging-update-routine.php
<?php
/**
* Update site to use test mode in local and staging environments
*/
function prefix_env_settings() {
// If settings have already been updated, return early
if ( 1 == get_transient( 'staging-settings-updated' ) ) {
return;
}
@bekarice
bekarice / wc-add-featured-flash.php
Created July 3, 2015 22:48
Adds a "Featured" flash to featured WooCommerce products (like a sale flash)
@devinsays
devinsays / efficient-fitvids.php
Created June 15, 2015 22:49
Efficient Script Loading for oEmbeds
/**
* Enqueue theme scripts
*/
function prefix_scripts() {
// FitVids Script conditionally enqueued from inc/extras.php
wp_register_script(
'prefix-fitvids',
get_template_directory_uri() . '/js/jquery.fitvids.min.js',
array( 'jquery' ),
@bekarice
bekarice / auto-approve-customer-users.php
Last active March 7, 2023 11:09
Automatically approve WooCommerce customers with New User Approve (https://wordpress.org/plugins/new-user-approve/)
<?php
/**
* Integrates WooCommerce with New User Approve
*
* Automatically approves new customers who register at checkout or on the My Account page,
* but holds all other user registrations for approval (i.e., wholesale customers)
*
* @param int $customer_id the new customer ID
*/
@LordZardeck
LordZardeck / silder
Last active July 10, 2021 03:56
Allows videos within a flexslider to stop the slider when playing, and continue the slider when done.
$(function() {
var slider, // Global slider value to force playing and pausing by direct access of the slider control
canSlide = true; // Global switch to monitor video state
// Load the YouTube API. For some reason it's required to load it like this
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
@corsonr
corsonr / gist:6775121
Last active October 7, 2018 15:21
WooCommerce - Product already in cart, change "add to cart" text
<?php
/**
* Change the add to cart text on single product pages
*/
add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
@krogsgard
krogsgard / wp-query-the-right-way.php
Last active January 4, 2021 21:59
sample custom WP_Query the right way
<?php
/*
* WP_Query happy dance
*
* this is a sample WP_Query the right way
*/
$args = array (
'post_type' => 'post',
@mikejolley
mikejolley / gist:3969579
Created October 28, 2012 19:28
WooCommerce - Create a coupon via PHP
$coupon_code = 'UNIQUECODE'; // Code
$amount = '10'; // Amount
$discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product
$coupon = array(
'post_title' => $coupon_code,
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'shop_coupon'
@simonlk
simonlk / Woocommerce - output product variations in tab
Last active February 21, 2022 20:27
Output Woocommerce product variations as a table within a tab on the single product page
// Add to functions.php
/*===================================================
Created by sk from Renegade Empire with help
from these sources:
http://docs.woothemes.com/document/editing-product-data-tabs/
http://www.sean-barton.co.uk/2013/03/remove-woocommerce-20-reviews-tab/#.UYnWe7XfB6N
http://www.sean-barton.co.uk/2013/03/sb-add-woocommerce-tabs-wordpress-plugin/#.UYrYL7XfB6M
@luetkemj
luetkemj / wp-query-ref.php
Last active April 25, 2024 09:37
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/