Skip to content

Instantly share code, notes, and snippets.

View thetwopct's full-sized avatar

James Hunt thetwopct

View GitHub Profile
@thetwopct
thetwopct / component.php
Created November 3, 2021 05:54
Log variables/arrays in Laravel
<?php
use Illuminate\Support\Facades\Log;
class Component extends Model {
Log::info(print_r($variable, true));
}
@thetwopct
thetwopct / functions.php
Created September 8, 2021 15:41
Register an ACF Block (Gutenberg) with API v2 options
// register the dots background block.
acf_register_block_type(
array(
'name' => 'section-dots',
'title' => 'Section - Dots',
'description' => 'A full width section similar to group block to allow for dots background image.',
'render_template' => get_template_directory() . '/theme-parts/blocks/section-dots.php',
'enqueue_style' => get_template_directory() . '/theme-parts/blocks/section-dots.css',
'mode' => 'preview',
'icon' => 'format-aside',
@thetwopct
thetwopct / bash.sh
Last active September 1, 2021 05:50
Useful Docker Commands
# display the logs of a container
docker logs
# continue showing log updates
docker logs -f mycontainer
# lists the volumes
docker volume ls
# stops all running containers
@thetwopct
thetwopct / style.css
Created August 4, 2021 10:19
Hide the tick on WooCommerce Tax Toggle
/* Hides the tick on WooCommerce Tax Toggle */
#wcvat-toggle.on::before {
content: "";
background-image: url();
padding-left: 0;
background-size: 0;
}
@thetwopct
thetwopct / cors.json
Created July 9, 2021 04:58
Allow Cross-origin resource sharing (CORS) for Laravel Livewire JS
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"HEAD",
@thetwopct
thetwopct / cli.sh
Created July 1, 2021 11:32
Change PHP version on MacOS with Home Brew
# show php version i.e. 7.3.8
php -v
# update brew to latest
brew update
# to show all php versions available i.e. php@7.4
brew search php
# install it
@thetwopct
thetwopct / colors.scss
Last active June 18, 2021 10:31
SASS function to loop through color palette and spit out classes
// color palette.
$palette: (
primary: (
400: #1bb1e4,
700: #4d84c8,
900: #7ea0c3,
),
secondary: (
400: #a66aae,
700: #5f61a9,
@thetwopct
thetwopct / styles.css
Last active June 9, 2021 12:33
CSS Snippets for Tax Toggle for WooCommerce
/* CSS Snippets for Tax Toggle for WooCommerce. Add these to your CSS file or to your theme via Customizer. */
/* Move down on left */
#wcvat-toggle {
top: 90%;
}
/* Move to right side of screen */
#wcvat-toggle {
left: unset;
@thetwopct
thetwopct / .htaccess
Created May 22, 2021 05:30
WordPress - Using .htaccess to load images from production server
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# If images not found on development site, load from production
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp-content/uploads/[^/]+/.+\.(jpe?g|jpg|png|gif)$ https://production.com/$0 [R=302,L]
@thetwopct
thetwopct / functions.php
Last active December 5, 2022 15:02
Translate Tax Toggle for WooCommerce
<?php // don't copy this opening PHP tag if you are pasting in to functions.php
/**
* Change text strings for WooCommerce Tax Toggle
*
* Translate the text used in Tax Toggle plugin.
* Copy the code below to your theme functions.php file.
*
* @param string $translated_text Translated text.
* @param string $text Text to translate.