Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Mustin alexmustin

View GitHub Profile
@alexmustin
alexmustin / functions.php
Created Oct 6, 2022
Function to determine if a Hex color is "light" or "dark"
View functions.php
<?php
function isColorLightOrDark( $color ) {
$red = hexdec(substr($color, 1, 2));
$green = hexdec(substr($color, 3, 2));
$blue = hexdec(substr($color, 5, 2));
$result = (($red * 299) + ($green * 587) + ($blue * 114)) / 1000;
if ( intval($result) > 128 ) {
$lightdark = "light";
} else {
$lightdark = "dark";
@alexmustin
alexmustin / style.scss
Last active Sep 20, 2022
CSS background cover mobile iOS fix
View style.scss
/**
* This applies to Genesis Blocks that have
* a 'fixed' background image applied.
*/
.gb-has-parallax {
/**
* This is the fix for mobile (iOS).
* It displays as a normal background image which fills
* the container and scrolls with the content.
@alexmustin
alexmustin / style.css
Created Sep 14, 2022
Slick Slider - make all Slides the same height
View style.css
.slick-track {
display: flex !important;
}
.slick-slide {
height: auto;
}
@alexmustin
alexmustin / functions.php
Last active Aug 18, 2022
Custom Genesis Pagination functions and styles
View functions.php
<?php
// CUSTOM LABEL: PREVIOUS BUTTON.
add_filter( 'genesis_prev_link_text', 'modify_previous_link_text' );
function modify_previous_link_text($text) {
$text = '< PREV';
return $text;
}
// CUSTOM LABEL: NEXT BUTTON.
@alexmustin
alexmustin / readme.md
Last active Jun 19, 2022
ConvertKit - How to create a Visual Automation for a Giveaway
View readme.md

ConvertKit Giveaway Automation

The following is an example of how to incorporate a ConvertKit Automation for a Giveaway.

This example assumes you have setup a Form on ConvertKit (called 'Giveaway Form').

1. Setup the Visual Automation

The following is a rough diagram of a sample Visual Automation. An explanation is provided after the diagram.

      [WEBSITE FORM]
@alexmustin
alexmustin / functions.php
Created Apr 5, 2022
WordPress: Enable the Block-based Widget Editor
View functions.php
<?php
//* Enable the block-based widget editor
add_filter( 'use_widgets_block_editor', '__return_true' );
@alexmustin
alexmustin / shortcode.php
Created Dec 2, 2021
A shortcode to display the latest release number for a provided GitHub repository
View shortcode.php
<?php
/**
* Displays the latest release number from a provided GitHub repository.
*
* Example usage: [show_repo_version_number repo="alexmustin/woo-custom-emails-per-product"]
*
* @param array $atts An array of shortcode attributes.
* @return string $output A string of text including the release number.
*/
function show_repo_version_number_function( $atts ) {
@alexmustin
alexmustin / _grid.scss
Last active Nov 11, 2021
CSS Grid - responsive 3-column grid example
View _grid.scss
.products-wrap {
display: grid;
justify-content: space-between;
grid-template-columns: repeat(auto-fill, 100%);
@include media( $screen--m ) {
grid-template-columns: repeat(auto-fill, 48%);
grid-gap: 2%;
}
@alexmustin
alexmustin / style.css
Last active Nov 10, 2021
Responsive / Fluid Typography -- CSS clamp() example
View style.css
/*
* This will keep the element's font size between 24px and 42px.
* The middle value automatically calculates the font size between
* the Min and Max, using the browser window viewport width.
*/
.archive-title {
font-size: clamp(24px, calc(3vw + 1rem), 42px);
}
@alexmustin
alexmustin / functions.php
Last active Nov 1, 2021
WooCommerce - disable 'Order Complete' emails for specific Product ID
View functions.php
<?php
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'themename_disable_customer_order_email_for_product', 10, 2 );
function themename_disable_customer_order_email_for_product( $recipient, $order ) {
// Get the current page.
$page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : '';
// If we're on a WooCommerce settings page, return the regular recipient.
if ( 'wc-settings' === $page ) {
return $recipient;
}