Skip to content

Instantly share code, notes, and snippets.

@FreshLondon
FreshLondon / _media_query_mixins.scss
Created March 13, 2019 06:43
Sass (SCSS) media query mixins
//
// MEDIA QUERIES
//––––––––––––––––––––––––––––––––––––––––––––––––––
// A map of breakpoints.
$breakpoints: (
xs: 576px,
sm: 768px,
md: 992px,
lg: 1200px
@FreshLondon
FreshLondon / backups-s3.sh
Last active February 12, 2023 05:54
S3 bucket backup script
#!/usr/bin/bash
# CWP - Custom backup script
# Modified for external Amazon S3 buckets
# based on a backup script by ejsolutions/Teo/cynique
#
# set cron job with something like: 0 4 * * * /backups-s3.sh > /dev/null 2>&1
#
# Set the following 3 items to suit
tmp_dir=/home/backups_tmp/
s3_bucket=freshlondon-backups-singapore
add_action( 'wp', 'remove_lightbox', 99 );
function remove_lightbox() {
remove_theme_support( 'wc-product-gallery-lightbox' ); // removes photoswipe markup on frontend
}
// disable flexslider js
function flex_dequeue_script() {
wp_dequeue_script( 'flexslider' );
}
<?php
function fl_archive_cats() {
$args = array( 'taxonomy' => 'katagori' );
$categories = get_categories( $args );
?>
<div class="fl-archive-cats">
<?php
foreach ( $categories as $category ) {
@FreshLondon
FreshLondon / backup-s3.sh
Last active September 8, 2021 06:45
Custom backup script for CWP > Amazon S3 bucket
#!/usr/bin/bash
# CWP - Custom backup script
# Modified for external Amazon S3 buckets
# based on a backup script by ejsolutions/Teo/cynique
#
# Set the following 3 items to suit
tmp_dir=/home/backups_tmp/
s3_bucket=YOUR-BUCKET-NAME-HERE
retention=1
# -------------------
function toREM (size = 1) {
let winWidth = jQuery(window).width();
if (winWidth <= 991) {
//base font size at 750px is 22px.
let baseFontSizeSmall = 29.1;
let winPercentSmall = winWidth / 991;
let fontSizeSmallFinal = window.finalFont = (baseFontSizeSmall * winPercentSmall);
return size / fontSizeSmallFinal;
} else {
//base font size at 1920px is 16px.
@FreshLondon
FreshLondon / fading-hyperlink.js
Last active February 18, 2021 17:48
Fading screen on hyperlink click
<?
// I'd like to see whether the task row is odd or even in CSS for printing
// as for PHP DomPDF I cant use pseudo classes (:nth-child(odd))
// get the tasks
$tasks = json_decode(get_post_meta($post->ID, 'tasks', true), true);
// set an evenm starting point, eg 0
$row_oddEven = 10;
<?php
// Check whether a number is odd or even.
if (!function_exists('checkOddEven')) {
function checkOddEven($number){
if($number % 2 == 0){
echo "Even";
}
else{
echo "Odd";
}
@FreshLondon
FreshLondon / functions-edit.php
Created August 12, 2020 18:36
Only load WooCommerce scripts on shop pages/checkout/cart
if (!is_woocommerce() && !is_cart() && !is_checkout()) {
remove_action('wp_enqueue_scripts', [WC_Frontend_Scripts::class, 'load_scripts']);
remove_action('wp_print_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5);
remove_action('wp_print_footer_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5);
}