Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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.
<?
// 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);
}
@FreshLondon
FreshLondon / hexdec-to-rgba-usage.php
Created August 16, 2019 11:24
Convert hexdec color string to rgb(a) string > USAGE
<?
// Here's a usage example how to use this function for dynamicaly created CSS
$color = '#ffa226';
$rgb = hex2rgba($color);
$rgba = hex2rgba($color, 0.7);
// CSS output
echo '
@FreshLondon
FreshLondon / hexdec-to-rgba.php
Last active August 16, 2019 11:23
Convert hexdec color string to rgb(a) string
<?
/* Convert hexdec color string to rgb(a) string */
function hex2rgba($color, $opacity = false) {
$default = 'rgb(0,0,0)';
//Return default if no color provided
if (empty($color)) return $default;
//Sanitize $color if "#" is provided