Skip to content

Instantly share code, notes, and snippets.

View macgraphic's full-sized avatar
💣

Mark Smallman macgraphic

💣
View GitHub Profile
// By using class, we replace specified text with the formatted date.
add_filter( 'render_block', function( $edited_date, $block ) {
$field_name = 'latestupdate'; // ACF field name
$postId = false;
$format = 'F jS, Y'; // date format
$class = 'displayDateUpdated'; // Additional CSS Class on block to find
$string = 'LastUpdated'; // string of text to replace with date
$date = get_field( $field_name , $postId, $format );
if (
!is_admin()
// Add class to BODY if cart has items
function onze_cart_has_items( $classes ) {
if ( WC()->cart->get_cart_contents_count() >= 1 ) {
$classes[] = 'itemsInCart';
}
return $classes;
}
add_filter( 'body_class','onze_cart_has_items' );
(function($) {
var infoWindows = new Array();
/*
* render_map
*
* This function will render a Google Map onto the selected jQuery element
* This version includes the auto-close infowindow - requires the var from line 2 above.
*
* @type function
// Theme colour palette
function xyz_setup_theme_supported_features() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Navy', 'xyz' ),
'slug' => 'navy',
'color' => '#032f3c',
),
array(
'name' => __( 'Orange', 'xyz' ),
@macgraphic
macgraphic / ACF-Event-Date
Created August 17, 2019 10:04
template output for ACF date
<p class="event-date-time">
<?php esc_url( svg_icon( 'calendar' ) ); ?>
<?php
$date = get_field( 'event_date' );
if ( $date ) : ?>
<?php echo esc_html( $date ); ?>,
<?php endif; ?>
<?php
$starttime = get_field( 'event_start_time' );
@macgraphic
macgraphic / newsslider.php
Last active August 14, 2019 18:11
News Slider Block Template
<?php
/**
* News Slider Block Template.
*/
// Create id attribute allowing for custom "anchor" value.
$id = 'newsslider-' . $block['id'];
if ( ! empty( $block['anchor'] ) ) {
$id = $block['anchor'];
// Add Supporter Levels (Taxonomies)
// Register Custom Taxonomy
function supporter_lvl_taxonomy() {
$labels = array(
'name' => _x( 'Supporter Levels', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Supporter Level', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Supporter Levels', 'text_domain' ),
'all_items' => __( 'All Levels', 'text_domain' ),
'parent_item' => __( 'Parent Item', 'text_domain' ),
var savedRuler= app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
//if w==h already square
app.preferences.rulerUnits = savedRuler;
@macgraphic
macgraphic / Woo header icons function
Last active March 5, 2019 21:24
Displays SVG icon in header for Yith Woo wishlist
function items_in_whishlist() {
if ( yith_wcwl_count_all_products() == 0 ) { ?>
<a data-toggle="wishlist-empty">
<img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/assets/images/heart-empty-24px.png' ); ?>">
</a>
<?php
} else { ?>
<a href="<?php echo esc_url( site_url( '/wishlist' ) ); ?>" data-toggle="wishlist-fill">
<img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/assets/images/heart-fill-24px.png' ); ?>">
</a>
@macgraphic
macgraphic / simple.php
Created March 2, 2018 12:29
Woo simple - single product page, adding svg icon to button _ theme/woocommerce/single-product/add-to-cart.php/simple.php
<?php
/**
* Simple product add to cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and