Skip to content

Instantly share code, notes, and snippets.

View Matt-Welland's full-sized avatar

Matt Welland Matt-Welland

  • Devon, United Kingdom
  • 23:30 (UTC +01:00)
View GitHub Profile
@Matt-Welland
Matt-Welland / script.js
Created October 17, 2023 15:47
Wordpress React Social Share Buttons
// Imports
const { render } = wp.element // <--- Wordpressify React
import { FaTwitter, FaFacebookF, FaWhatsapp } from 'react-icons/fa';
// Variables for the share button
const shareText = encodeURIComponent( "Check this out!~" )
const shareUrl = window.location.href
const hashTags = "Hashtag,Awesome,Cool"
const params = "menubar=no,toolbar=no,status=no,width=570,height=570" // for window
@Matt-Welland
Matt-Welland / functions.php
Last active October 17, 2023 15:44
Automatically change order status if specific product is found within order.
<?php
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$product_ids = array('12'); // Here set your targeted product(s) Id(s)
$product_found = true;
@Matt-Welland
Matt-Welland / delete_all_cats_woocommerce.sql
Last active October 17, 2023 15:40
Useful Wordpress SQL Queries - Use at own risk.
DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id
WHERE c.taxonomy = 'product_tag';
DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id
WHERE c.taxonomy = 'product_cat';
@Matt-Welland
Matt-Welland / app.js
Last active August 23, 2023 14:20
Changes how we use querySelector, querySelectorAll, addEventListener, and removeEventListener.
// # Changes how we use querySelector, querySelectorAll, addEventListener, and removeEventListener.
const $ = () => document.querySelector.call(this, arguments);
const $$ = () => document.querySelectorAll.call(this, arguments);
HTMLElement.prototype.on = (a, b, c) => this.addEventListener(a, b, c);
HTMLElement.prototype.off = (a, b) => this.removeEventListener(a, b);
// And therefore we can use this like...
let nav = $("nav");
// rather than...
let nav = document.querySelector("nav");
@Matt-Welland
Matt-Welland / functions.php
Created July 14, 2023 09:16
Custom Image Sizes and Rendering of...
<?php
// Example setting some image sizes
add_image_size( 'hero', 1900, 940 );
add_image_size( 'square-large', 1200, 1200, true );
add_image_size( 'square', 600, 600, true );
add_image_size( 'featured-large', 2280, 860, true );
add_image_size( 'featured', 1140, 430, true );
add_image_size( 'image-block', 1140, 430, false );
add_image_size( 'teaser-large', 720, 480, true );
add_image_size( 'teaser', 360, 240, true );