Skip to content

Instantly share code, notes, and snippets.

View nilsbosman's full-sized avatar

Nils Bosman nilsbosman

View GitHub Profile
@nilsbosman
nilsbosman / gulpfile.js
Last active November 8, 2021 10:19
Gulp4 - Tailwind and SCSS
// Load plugins
const gulp = require("gulp");
const sass = require('gulp-sass')(require('sass'));
const postcss = require("gulp-postcss");
const cssnano = require("gulp-cssnano");
const concat = require("gulp-concat");
const autoprefixer = require("autoprefixer");
// CSS task
function styles() {
@nilsbosman
nilsbosman / wc-custom-tracking-code-for-thanks-page.php
Last active June 7, 2021 13:39
Custom tracking code for the thanks page (only triggers once per order)
<?php
add_action( 'woocommerce_thankyou', 'tracking_code', 10, 1 );
function tracking_code( $order_id ) {
if ( ! $order_id )
return;
// Ignore localhost/dev submits
@nilsbosman
nilsbosman / .htaccess
Created March 15, 2021 18:29
.htaccess - Maintenance mode with whitelisted IP's
# Rewrite url for maintenance mode
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^123\.456\.78\.90
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.true -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
</IfModule>
@nilsbosman
nilsbosman / translatepress-custom-language-switcher.php
Created February 11, 2021 12:58
TranslatePress custom language switcher
<?php
// Custom language switcher for TranslatePress
$trp = TRP_Translate_Press::get_trp_instance();
$trp_url = $trp->get_component( 'url_converter' );
$trp_settings = $trp->get_component( 'settings' )->get_settings();
// Get all published languages
$lang = $trp_settings['publish-languages'];
@nilsbosman
nilsbosman / add-cc-bcc-to-woocommerce-emails.php
Last active February 11, 2021 12:50
Add CC and BCC to WooCommerce Emails
<?php
// place this code in your functions.php file.
function add_cc_to_certain_emails( $headers, $id ) {
// Define the email type and check if true (You can use all woocommerce email types, for more info: https://docs.woocommerce.com/wc-apidocs/class-WC_Email.html)
if ( 'new_order' === $id ) {
$headers .= "Cc: FirstName LastName <fistname-lastname@mail.com>\r\n";
$headers .= "Bcc: FirstName LastName <fistname-lastname@mail.com>\r\n";
// You can add more extra email headers here. Make sure you use $headers .= otherwise it will overwrite the variable.
}