Skip to content

Instantly share code, notes, and snippets.

View netwizards's full-sized avatar

Krzysztof netwizards

View GitHub Profile
@netwizards
netwizards / functions.php
Created July 31, 2024 08:47 — forked from certainlyakey/functions.php
Remove an item from Breadcrumbs NavXT plugin trail (Wordpress)
if (function_exists('bcn_display')) {
function theme_remove_news_from_trail_on_404($trail) {
if ( is_404() ) {
unset($trail->trail[1]);
array_keys($trail->trail);
}
}
add_action('bcn_after_fill', 'theme_remove_news_from_trail_on_404');
}
@netwizards
netwizards / functions.php
Created February 28, 2024 21:41 — forked from paaljoachim/functions.php
WooCommerce show/hide products based on if the user is logged inn or logged out.
<?php
// https://businessbloomer.com/woocommerce-remove-specific-category-shop-loop/
// https://stackoverflow.com/questions/34684881/hide-products-from-users-who-are-not-logged-in-using-tags/34689768#34689768
add_action( 'woocommerce_product_query', 'show_hide_products_category_shop' );
function show_hide_products_category_shop( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
if ( is_user_logged_in() ) {
@netwizards
netwizards / gist:e8873478d721e0d70883919a490924a7
Created February 18, 2024 20:11 — forked from corsonr/gist:81a67e71dca0e9bd18f3
WooCommerce: filter shipping packages
add_filter( 'woocommerce_cart_shipping_packages', 'bulky_woocommerce_cart_shipping_packages' );
function bulky_woocommerce_cart_shipping_packages( $packages ) {
// Reset the packages
$packages = array();
// Bulky items
$bulky_items = array();
$regular_items = array();
@netwizards
netwizards / woocommerce_update_shipping_costs.php
Created February 18, 2024 20:10 — forked from neamtua/woocommerce_update_shipping_costs.php
WooCommerce: Update shipping costs on checkout using ajax
<script type="text/javascript">
/* in order to update info on your checkout page you need to trigger update_checkout function
so add this in your javascript file for your theme or plugin
*/
jQuery('body').trigger('update_checkout');
/* what this does is update the order review table but what it doesn't do is update shipping costs;
the calculate_shipping function of your shipping class will not be called again;
so if you were like me and you made a shipping method plugin and you had to change costs based on payment method then
@netwizards
netwizards / template-functions.php
Created May 30, 2023 08:40 — forked from interplaydesign/template-functions.php
wp_nav_menu_objects filter
/**
* Menu customizations
*/
add_filter('wp_nav_menu_objects', 'intro_nav_menu_objects', 10, 2);
function intro_nav_menu_objects( $items, $args ) {
//If our menu has the id primary-menu in the wp_nav_menu in our header.php
if ( $args->menu_id == 'primary-menu' ){
//var_dump( $items );
//For each item in the menu. the $item->ID is the menu item ID not the page/post ID
//The post id will be the $item->object_id if it is a post/page
@netwizards
netwizards / gist:54f034d87414d4fa852fdba2eba23099
Created April 12, 2023 18:43 — forked from bohnna/gist:0edf12dd39cf8883234f
(Wordpress) Remove UL from wp_nav_menu
<?php
$my_menu = array(
'menu' => 'main-menu',
'container' => '',
'items_wrap' => '%3$s'
);
wp_nav_menu( $my_menu );
<?php
/*
Plugin Name: Set Image Alt field
Plugin URI: https://www.damiencarbery.com
Description: Set the alt field of uploaded images to the title. Copy image title to alt when inserted into editor. Set alt of post thumbnail to post title. Code copied from various sources.
Author: Damien Carbery, Francisco Ruiz, Dan and Bojan Petrovic.
Version: 0.1
*/
@netwizards
netwizards / Inserts thumbnails to products
Created September 3, 2021 05:50 — forked from bubuku/Inserts thumbnails to products
Adds link and title the image, it applies to all archives of products #sublime #woocommerce
<?php
/* This snippet removes the action that inserts thumbnails to products in the loop
* and adds link and title the image, it applies to all archives of products.
*
* @original plugin: WooCommerce
* @author of snippet: Luis Ruiz
**/
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
@netwizards
netwizards / 1-remove-woocommerce-tabs.php
Created September 1, 2021 09:13 — forked from kittenlane/1-remove-woocommerce-tabs.php
Remove tabs but keep product description in WooCommerce
//* http://gasolicious.com/remove-tabs-keep-product-description-woocommerce/
// Location: add to functions.php
// Output: removes woocommerce tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
@netwizards
netwizards / README.md
Created November 22, 2019 12:09 — forked from jonathantneal/README.md
SASS @font-face mixin

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);