Skip to content

Instantly share code, notes, and snippets.

View westcoastdigital's full-sized avatar

Jon Mather westcoastdigital

View GitHub Profile
@westcoastdigital
westcoastdigital / acf-gf-form-picker.php
Created June 8, 2019 11:45
Gravity Form ACF Field
<?php
function wcd_choose_gravity_forms( $field ) {
$field['choices'] = array();
$forms = GFAPI::get_forms();
foreach ( $forms as $form ) {
$title = $form['title'];
$field['choices'][ $title ] = $title;
}
@westcoastdigital
westcoastdigital / gf-readonly-fields.php
Created June 8, 2019 03:49
Enable option to make GF fields readonly
<?php
add_filter('gform_field_content', function ($field_content, $field) {
$fieldtype = $field['type'];
if( $fieldtype == 'text' || $fieldtype == 'email' || $fieldtype == 'number' || $fieldtype == 'phone' ) {
$readonlySupport = 'true';
} else {
$readonlySupport = 'false';
}
@westcoastdigital
westcoastdigital / functions.php
Created May 15, 2019 13:56
Dynamically add WooCommerce product categories to primary menu
<?php
function gp_add_woo_categories_to_menu($items, $args)
{
if ($args->theme_location == 'primary') {
$cat_args = array(
'orderby' => 'name',
'order' => 'asc',
'hide_empty' => true,
@westcoastdigital
westcoastdigital / category-template.php
Created May 15, 2019 13:08
Create a page template to display categories
<?php
/* Template Name: Category Template */
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header(); ?>
<div id="primary" <?php generate_do_element_classes( 'content' ); ?>>
@westcoastdigital
westcoastdigital / gp-menu-icon.css
Last active February 9, 2020 04:14
Style the GeneratePress Menu Icon
/**
* Set the Menu text to &nbsp; so the span is there but no text
*/
.menu-toggle {
position: absolute;
top: 22px;
right: 0px;
width: 36px;
height: 36px;
@westcoastdigital
westcoastdigital / custom-logo.php
Created March 14, 2019 01:18
Determines if a custom logo SVG format when uploaded to WordPress Customiser
/** Add SVG support first **/
function wcd_add_svg_support($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'wcd_add_svg_support');
/*
@westcoastdigital
westcoastdigital / archive-product_cat.php
Created September 5, 2018 11:27
Check if current term is a child or parent term and load different templates based on result
<?php get_header(); ?>
<div id="content" role="main">
<?php
// get the current term
$term = get_queried_object();
// taxonomy to check against
@westcoastdigital
westcoastdigital / menu-logo.js
Created August 29, 2018 05:42
Move logo to middle of menu in GeneratePress
(function($) {
$(function() {
/**
* Move logo to middle of menu
*/
wcd_move_logo();
$(window).resize(function() {
var exists = $("#primary-menu .menu li.menu-logo").length;
// check if isnt already in menu and if isnt then move
if (exists == 0) {
@westcoastdigital
westcoastdigital / woocommerce-plus-minus.js
Last active July 10, 2018 07:09
Append +/- buttons to woocommerce cart and product qty fields trigger updates
'use strict';
( function( $ ) {
$( function() {
woocommerce_add_to_cart_and_update();
$( document.body ).on( 'updated_cart_totals', function() {
woocommerce_add_to_cart_and_update();
} );
@westcoastdigital
westcoastdigital / seasalt.php
Created May 3, 2018 10:35
fix iodine issue
<?php
function iodine_is_active() {
if ( !class_exists('Iodine_Plugin') ) {
?>
<div class="notice notice-error is-dismissible">
<p>
<a target="_blank"
href="https://github.com/saltnpixels/Iodine"> <?php _e( 'This theme works best with iodine installed!!', 'digipress' ); ?></a>
</p>