Skip to content

Instantly share code, notes, and snippets.

View petertwise's full-sized avatar

Peter Wise petertwise

View GitHub Profile
@ms-studio
ms-studio / wp-gallery-shortcode-override.php
Last active April 17, 2019 14:13
an override of the default WP gallery shortcote
<?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
*/
@woogist
woogist / gist:1128a0803928edc4bd0f
Last active June 8, 2020 23:11
WooCommerce: change "add to cart" button text by product type
<?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;
@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]);
@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 );
@jshawl
jshawl / Gruntfile.js
Last active January 18, 2023 13:52
Grunt + Sass + Autoprefixer
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options:{
style:'compressed'
},
files: {
'css/style.css' : 'scss/style.scss'
@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": ""
}
@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(),
@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 () {
@charleslouis
charleslouis / custom-search-acf-wordpress.php
Last active December 15, 2023 09:11
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}