Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Mustin alexmustin

View GitHub Profile
@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;
}
@alexmustin
alexmustin / functions.php
Created Nov 25, 2020
WordPress - Add page slug to body class
View functions.php
<?php
// Add page slug to Body class.
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
@alexmustin
alexmustin / load-scripts.php
Created Oct 16, 2020
Course Maker Pro - /lib/load-scripts.php
View load-scripts.php
<?php
/**
* Loads scripts and stylesheets for the Course Maker Pro theme.
*
* @since 1.0
*
* @package Course Maker Pro
*/
add_action( 'wp_enqueue_scripts', 'course_maker_enqueue_scripts_styles' );
@alexmustin
alexmustin / appearance.php
Created Oct 15, 2020
Course Maker Pro - /config/appearance.php
View appearance.php
<?php
/**
* Course Maker Pro appearance settings
*
* @package Course Maker Pro
* @author brandiD
* @license GPL-2.0-or-later
*/
$course_maker_default_colors = array(
@alexmustin
alexmustin / responsive-menus.php
Created Oct 15, 2020
Course Maker Pro - /config/responsive-menus.php
View responsive-menus.php
<?php
/**
* Course Maker - Responsive Menu features
*
* @package Course Maker Pro
* @author StudioPress
* @license GPL-2.0-or-later
* @link https://my.studiopress.com/themes/genesis-sample/
*/