Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Wise petertwise

View GitHub Profile
@jchristopher
jchristopher / searchwp-customizations.php
Last active Apr 22, 2021
Give Products extraordinary weight boost to ensure Products show up first.
View searchwp-customizations.php
<?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 Aug 9, 2022
WordPress Yoast SEO: Create a custom sitemap with data not sourced from a custom post type.
View wpseo-yoast-sitemap-custom.php
<?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 Jul 5, 2022
Define the Advanced Custom Fields Pro license key with a constant
View acf_pro_license_constant.php
<?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 Dec 4, 2021
Migrate a WordPress database so that existing media items are served from Amazon S3 or CloudFront. Requires the WP Offload S3 Lite plugin.
View wp_offload_media_db_migrate.json
{
"use_https": "",
"purge_amazonS3_info": ""
}
@petertwise
petertwise / youtube-cover-art.php
Last active Jul 31, 2020
Get the best version of youtube cover image without using the API
View youtube-cover-art.php
<?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]);
View sqcdy_acf_rgb.php
<?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 Sep 8, 2022
List unique CSS properties for all DOM elements
View findStyles.js
/**
* 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
*
@magicznyleszek
magicznyleszek / css-selectors.md
Last active Nov 25, 2022
CSS Selectors Cheatsheet
View css-selectors.md

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 {
@woogist
woogist / gist:1128a0803928edc4bd0f
Last active Jun 8, 2020
WooCommerce: change "add to cart" button text by product type
View gist:1128a0803928edc4bd0f
<?php
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
@ms-studio
ms-studio / wp-gallery-shortcode-override.php
Last active Apr 17, 2019
an override of the default WP gallery shortcote
View wp-gallery-shortcode-override.php