Skip to content

Instantly share code, notes, and snippets.

View westcoastdigital's full-sized avatar

Jon Mather westcoastdigital

View GitHub Profile
@westcoastdigital
westcoastdigital / gist:bba170c2994c5b5f904c2cbf20d2657f
Created April 8, 2025 02:29
How to add a custom field to WordPress menu item on specific registered menu
/*
* WP Version: 6.7.2
*/
// Add the checkbox to the menu item custom fields only for main-menu
function wcd_add_product_categories_checkbox($item_id, $item) {
// Get the global menu variable that holds the current menu being edited
global $nav_menu_selected_id;
// Get all menu locations
@westcoastdigital
westcoastdigital / acf-woo-conditional.php
Created February 20, 2024 04:55
Add Custom Conditional Logic to ACF
<?php
// Add WooCommerce Conditional Logic
function jm_acf_woo_product_filter($choices)
{
if (!isset($choices['WooCommerce'])) {
$new_choices = array();
foreach ($choices as $key => $value) {
$new_choices[$key] = $value;
if ($key == 'Post') { // position in the drop down in thios case after Post
@westcoastdigital
westcoastdigital / acf-image-select.php
Created November 8, 2021 01:35
ACF Radio as Image Select
/**
* Create a radio button field and set it to horizontal
* Add each choice with image as label like beow
* animation : <img src="/wp-content/themes/cobaltdesign/img/animation.svg" />
* Change $field_name in the acf_icon_css function to what you called your theme
*/
function acf_icon_css()
{
$field_name = 'expertise_icon';
@westcoastdigital
westcoastdigital / change-category-name.php
Created October 28, 2021 06:32
Change the WordPress Category name and text on the admin screen
<?php
/**
* Change core category to Channel
*/
if( !function_exists('wcd_rename_category_theme') ) {
function wcd_rename_category_theme() {
$singular_name = 'Channel';
$plural_name = 'Channels';
@westcoastdigital
westcoastdigital / add_customizer_back_to_fse.php
Last active May 18, 2021 03:36
Adds back customizer link to Appearance in admin and admin bar when using the Full Site Editing in Gutenberg due out in WP 5.8
<?php
/**
* Plugin Name: WCD Add Customizer Back
*/
function wcd_add_customizer_back()
{
if (!gutenberg_is_fse_theme()) {
return;
}
@westcoastdigital
westcoastdigital / slick-custom-navigation.js
Created March 27, 2020 05:04
Slick custom navigation
(function($) {
$(function() {
// Activate custom navigation for Slick
$('[data-slick-navigation]').slickNavigation();
// Activate slick slider
$('#custom-slick-slider').slick({
});
@westcoastdigital
westcoastdigital / buttons.php
Created January 3, 2020 15:09
Add Button Border Controls
<?php
/**
* Add button controls to customiser
*/
function wcd_customize_controls_register($wp_customize)
{
$wp_customize->add_setting('button_border_colour', array(
));
$wp_customize->add_control(
@westcoastdigital
westcoastdigital / make_model.php
Last active October 16, 2019 01:48
Poplulate make from parent term of model
<?php
function update_custom_terms($post_id) {
/**
* Define taxonomies
*/
$make = 'make';
$model = 'model';
@westcoastdigital
westcoastdigital / taxonomy-product_cat-rubs.php
Created September 23, 2019 03:02
WooCommerce product_cat term by product_brand custom term
<?php
defined('ABSPATH') || exit;
get_header('shop');
$rubs = get_queried_object();
/**
@westcoastdigital
westcoastdigital / generatepress-slideout.css
Created September 16, 2019 03:22
Change the GeneratePress overlay menu slide in
#generate-slideout-menu {
left: -100vw;
top: -100vh;
opacity: 1;
border-bottom-right-radius: 100%;
-webkit-transition: left 0.5s ease-in, top 0.5s ease-in, border-radius 0.7s ease-in;
transition: left 0.5s ease-in, top 0.5s ease-in, border-radius 0.7s ease-in;
}
#generate-slideout-menu.is-open {
left: 0;