Skip to content

Instantly share code, notes, and snippets.

View yanknudtskov's full-sized avatar

Yan Knudtskov yanknudtskov

View GitHub Profile
@bjornjohansen
bjornjohansen / wordpress-menu-cache-timing.php
Created January 20, 2018 17:49
Timing for the WordPress menu cache
<?php
/**
* WordPress menu cache timing.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@rayrutjes
rayrutjes / search-by-algolia-for-woocommerce.php
Created September 23, 2016 11:14
This is a boilerplate for using Algolia in WooCommerce
<?php
/**
* @wordpress-plugin
* Plugin Name: Search by Algolia for WooCommerce - Instant & Relevant results
*/
/**
* If Algolia is not active, let users know.
@kloon
kloon / gist:4633463
Last active December 27, 2019 15:04
WooCommerce Disable Coupons on Sale Items
<?php
// Exclude coupons from being applied when products on sale
add_filter( 'woocommerce_coupon_is_valid', 'woocommerce_coupon_check_sale_items', 10, 2 );
function woocommerce_coupon_check_sale_items( $valid, $coupon ) {
global $woocommerce;
$valid_for_cart = $valid;
if (sizeof($woocommerce->cart->get_cart())>0) : foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) :
if ( function_exists( 'get_product') )
$product = get_product( $cart_item['product_id'] );
@WillBrubaker
WillBrubaker / gist:4d9f1cd122513e9eb0bc
Created June 3, 2015 03:37
Restrict WooCommerce order notes field to a number of characters
add_filter( 'woocommerce_checkout_fields', 'filter_checkout_fields' );
function filter_checkout_fields( $fields ) {
$fields['order']['order_comments']['maxlength'] = 200;
return $fields;
}
<?php
/**
* Connect a Gravity Form File Upload Field to an ACF Image Field.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_set_acf_gallery_field', 10, 2 );
function jdn_set_acf_gallery_field( $entry, $form ) {
$gf_images_field_id = 7; // the upload field id
@kevinwhoffman
kevinwhoffman / acf-seo-image.php
Last active November 8, 2020 18:29 — forked from bahia0019/acf-seo-image.php
For ACF users, creates an easy to use function that wraps your image in HTML5 <figure> adds <figcaption>. Also adds Schema markup in JSON LD. Parameters are 1. ACF field name, 2. Size, 3. Figure CSS class, 4. Figcaption CSS class.
function fsc_figure( $image, $size, $imageclass, $captionclass ){
/**
* Let plugins pre-filter the image meta to be able to fix inconsistencies in the stored data.
*
* @param string $image The ACF field name (i.e. 'your_photo_name').
* @param string $size Thumbnail size (i.e. 'Thumbnail', 'Medium', 'Large')
* @param string $imageclass The Figure class you want to use (ex: 'my-figure')
* @param string $captionclass The Figcaption class you want to use (ex: 'caption-blue')
*/
@corsonr
corsonr / gist:7370707
Created November 8, 2013 13:00
WooCommerce - display order coupons used in confirmation email and edit order page
add_action( 'woocommerce_email_after_order_table', 'add_payment_method_to_admin_new_order', 15, 2 );
/**
* Add used coupons to the order confirmation email
*
*/
function add_payment_method_to_admin_new_order( $order, $is_admin_email ) {
if ( $is_admin_email ) {
@temsool
temsool / dequeue-fontawesome-elementor.php
Last active April 15, 2021 07:58
How dequeue fontawesome elementor
<?php
add_action( 'wp_print_styles', 'dequeue_font_awesome_style' );
function dequeue_font_awesome_style() {
wp_dequeue_style( 'font-awesome' );
wp_deregister_style( 'font-awesome' );
}
?>
@spivurno
spivurno / gw-gravity-forms-user-registration-skip-registration-for-existing-email.php
Last active September 14, 2021 13:01
Gravity Wiz // Gravity Forms // User Registration // Skip Registration if Email Exists
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-user-registration-skip-registration-for-existing-email.php
*/
/**
* Gravity Wiz // Gravity Forms // User Registration // Skip Registration if Email Exists
*
* If submitted email is already registered, skip registration.
@bjornjohansen
bjornjohansen / logging.php
Last active January 20, 2023 18:48
Simple logging for WordPress
<?php
/**
* Simple logging for WordPress.
*
* @package BJ\Log
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/