Skip to content

Instantly share code, notes, and snippets.

View petertwise's full-sized avatar

Peter Wise petertwise

View GitHub Profile
@Acephalia
Acephalia / dopevp.php
Last active October 20, 2024 15:37
Woocommerce Disable Order Processing Email For Virtual Products
// Disable Order Processing Email For Virtual Products
add_action( 'woocommerce_checkout_process', 'virtual_products_that_dont_annoy_customers' );
function virtual_products_that_dont_annoy_customers() {
// Check if the cart contains virtual products only
$virtual_products_only = true;
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
if ( ! $cart_item['data']->is_virtual() ) {
@jchristopher
jchristopher / searchwp-customizations.php
Last active April 22, 2021 20:28
Give Products extraordinary weight boost to ensure Products show up first.
<?php
// Give Products extraordinary weight boost to ensure Products show up first.
// @link https://searchwp.com/documentation/knowledge-base/post-type-first-top/
add_filter( 'searchwp\query\mods', function( $mods ) {
$post_type = 'product'; // Post type name.
$source = \SearchWP\Utils::get_post_type_source_name( $post_type );
@leepowers
leepowers / wpseo-yoast-sitemap-custom.php
Last active March 28, 2024 05:19
WordPress Yoast SEO: Create a custom sitemap with data not sourced from a custom post type.
<?php
/**
* USAGE:
* - Search and replace the `CUSTOM_SITEMAP` string with a lowercase identifier name: e.g., "vehicles", "customer_profiles"
* - The `your_alternate_data_source()` function does not exist; it's simply a placeholder for your own function that returns some sort of data array.
* - Uses heredocs for inline XML: https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
*/
/**
@polevaultweb
polevaultweb / acf_pro_license_constant.php
Last active March 22, 2023 03:06
Define the Advanced Custom Fields Pro license key with a constant
<?php
function my_filter_acf_pro_license_option( $pre ) {
if ( ! defined( 'ACF_PRO_LICENSE' ) || empty( ACF_PRO_LICENSE ) ) {
return $pre;
}
$data = array(
'key' => ACF_PRO_LICENSE,
'url' => home_url(),
@gbot
gbot / wp_offload_media_db_migrate.json
Last active March 20, 2023 20:24
Migrate a WordPress database so that existing media items are served from Amazon S3 or CloudFront. Requires the WP Offload S3 Lite plugin.
{
"use_https": "",
"purge_amazonS3_info": ""
}
@petertwise
petertwise / youtube-cover-art.php
Last active July 31, 2020 07:52
Get the best version of youtube cover image without using the API
<?php
function url_exists( $url ) {
$headers = get_headers($url);
return stripos( $headers[0], "200 OK" ) ? true : false;
}
function get_youtube_id( $url ) {
$youtubeid = explode('v=', $url);
$youtubeid = explode('&', $youtubeid[1]);
<?php
/*
Plugin Name: Square Candy ACF RGB color output
Plugin URI: http://squarecandydesign.com
Description: provides a function to output RGB values from ACF colorpicker fields
Author: Peter Wise
Version: 0.1
Author URI: http://squarecandydesign.com
*/
@macbookandrew
macbookandrew / findStyles.js
Last active March 30, 2024 15:24
List unique CSS properties for all DOM elements
/**
* List unique CSS properties for all DOM elements
* Initially created to list unique font stacks on a page
* @see {@link http://stackoverflow.com/a/35022690/ Inspired by this StackOverflow answer}
*
* @see {@link https://gist.github.com/macbookandrew/f33dbbc0aa582d0515919dc5fb95c00a/ URL for this file}
*
* @author AndrewRMinion Design (https://andrewrminion.com)
* @version 1.1
*
@Farmatique
Farmatique / gist:5c48d1d9b5744117a94901f6ed84f7b5
Last active July 31, 2023 11:39
input[type="number"] plus/minus buttons
<div id="field1">
<button type="button" id="sub" class="sub">-</button>
<input type="text" id="1" value="0" class="field" />
<button type="button" id="add" class="add">+</button>
</div>
$('.add').click(function () {
$(this).prev().val(+$(this).prev().val() + 1);
});
$('.sub').click(function () {
@magicznyleszek
magicznyleszek / css-selectors.md
Last active November 2, 2024 12:22
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Hi! If you see an error or something is missing (like :focus-within for few years :P) please let me know ❤️

Element selectors

Element -- selects all h2 elements on the page

h2 {