Skip to content

Instantly share code, notes, and snippets.

View yanknudtskov's full-sized avatar

Yan Knudtskov yanknudtskov

View GitHub Profile
@damiencarbery
damiencarbery / conditional-wc-email-sending.php
Last active July 30, 2023 07:32
Conditionally send WooCommerce emails: Dynamically determine whether to send a WooCommerce email. https://www.damiencarbery.com/2018/12/conditionally-disable-woocommerce-emails/
<?php
/*
Plugin Name: Conditionally send WooCommerce emails
Plugin URI: https://www.damiencarbery.com/2018/12/conditionally-disable-woocommerce-emails/
Description: Dynamically determine whether to send a WooCommerce email.
Author: Damien Carbery
Version: 0.2
*/
// The filter name is 'woocommerce_email_enabled_'.WC_Email::id e.g. 'new_order', 'cancelled_order' etc
@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' );
}
?>
@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)
*/
@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)
*/
@bjornjohansen
bjornjohansen / wordpress-menu-cache.php
Last active March 7, 2024 13:57
WordPress Menu Cache
<?php
/**
* WordPress menu cache.
*
* @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)
*/
@willgorham
willgorham / woocommerce-auto-complete-virtual-orders.php
Last active December 29, 2023 02:06
WooCommerce: Automatically complete virtual orders
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'wmg_auto_complete_virtual_orders', 10, 3 );
/**
* Automatically complete orders with only virtual products
*
* @param string $payment_complete_status Order status used after an order payment is received
* @param int $order_id ID of the order being processed
* @param WC_Order $order Order object being processed
@westonruter
westonruter / wp-42573.php
Last active September 21, 2023 13:41
WP Trac #42573: Fix for theme template caching. https://core.trac.wordpress.org/ticket/42573
<?php
/**
* Plugin name: WP Trac #42573: Fix for theme template file caching.
* Description: Flush the theme file cache each time the admin screens are loaded which uses the file list.
* Plugin URI: https://core.trac.wordpress.org/ticket/42573
* Author: Weston Ruter, XWP.
* Author URI: https://weston.ruter.net
*/
function wp_42573_fix_template_caching( WP_Screen $current_screen ) {
<?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')
*/
@bekarice
bekarice / wc-add-order-item-meta-to-rest-response.php
Created December 28, 2016 20:18
Example: Add order item meta to WC REST API
<?php // only copy if needed
/**
* Example: Add order meta to the REST API
* WC 2.6+
*
* @param \WP_REST_Response $response The response object.
* @param \WP_Post $post Post object.
* @param \WP_REST_Request $request Request object.
* @return object updated response object