Skip to content

Instantly share code, notes, and snippets.

@stuartduff
stuartduff / woocommerce-bookings-change-single-add-to-cart-text.php
Created April 20, 2016 13:43
Change WooCommerce Bookings single add to cart text "Book Now"
function change_booking_single_add_to_cart_text() {
echo 'Changed Text';
}
add_filter( 'woocommerce_booking_single_add_to_cart_text','change_booking_single_add_to_cart_text' );
@cvan
cvan / HOWTO.md
Last active February 27, 2025 14:41
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you
@ummahusla
ummahusla / git-overwrite-branch.sh
Last active September 5, 2024 13:48 — forked from brev/git-overwrite-branch.sh
Git overwrite branch with another branch
# overwrite master with contents of feature branch (feature > master)
git checkout feature # source name
git merge -s ours master # target name
git checkout master # target name
git merge feature # source name
@TimBHowe
TimBHowe / functions.php
Created March 8, 2016 17:54
Forcibly remove the tax line item and calculation from the cart. (suggest just using the GEO setting in WooCommerce)
<?php
// Remove the Tax Line item from the cart.
function wc_remove_cart_tax_totals( $tax_totals, $instance ) {
if( is_cart() ) {
$tax_totals = array();
}
return $tax_totals;
}
@groucho75
groucho75 / merging_wp_queries.php
Last active March 1, 2023 09:43
Merging results of 2 WP_Query
<?php
/**
* Case: related news
*
* At first query for posts of same category, then, if it doesn't find enough posts, query for other posts and merge the 2 results.
*
* Put the following code inside a single template.
*
* @link Inspired by http://wordpress.stackexchange.com/questions/71576/combining-queries-with-different-arguments-per-post-type#answer-71582
var doc = new $window.jsPDF("p", "mm", "a4");
$timeout(function(){
$window.html2canvas( $document[0].getElementsByClassName('print-pass'), {
onrendered: function(canvas){
var imgData = canvas.toDataURL('image/png');
//Page size in mm
var pageHeight = 295;
var imgWidth = 210;
var imgHeight = canvas.height * imgWidth / canvas.width;
var heightLeft = imgHeight;
@thisismitch
thisismitch / corridors_of_code.rb
Created November 18, 2015 05:36
Sonic Pi Songs
# Chrono Trigger Soundtrack - Corridors of Time
# plug this into http://sonic-pi.net/
# still needs synth pads
# global config
use_bpm 112
def play_legato_note(note_value, duration)
release_duration = duration
@endel
endel / number-pad-zero.js
Last active August 1, 2023 11:54
Simplest way for leading zero padding in JavaScript
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
}
(1).pad(3) // => "001"
(10).pad(3) // => "010"
(100).pad(3) // => "100"
@ezekg
ezekg / import-store-locations.php
Last active December 22, 2022 08:35
Import CSV script for WP Store Locator plugin
<?php
/**
* This is a quick and dirty script. This should NEVER be run on a production server.
*
* Include this script at the bottom of your functions.php file, e.g.
*
* ```php
* // Your functions.php file
* // ...
@eduwass
eduwass / duplicate-post.php
Last active September 17, 2024 15:16
Programmatically duplicating a WordPress post
<?php
/**
* Duplicates a post & its meta and returns the new duplicated Post ID.
*
* @param int $post_id The Post ID you want to clone.
* @return int The duplicated Post ID.
*/
function duplicate_post(int $post_id): int
{