Skip to content

Instantly share code, notes, and snippets.

Avatar

Yan Knudtskov yanknudtskov

View GitHub Profile
@amindiary
amindiary / dequeue-fontawesome-elementor.php
Last active Jan 30, 2020
How dequeue fontawesome elementor
View dequeue-fontawesome-elementor.php
<?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 Oct 16, 2020
Simple logging for WordPress
View logging.php
<?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 Jan 20, 2018
Timing for the WordPress menu cache
View wordpress-menu-cache-timing.php
<?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)
*/
View wordpress-menu-cache.php
<?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 Sep 3, 2020
WooCommerce: Automatically complete virtual orders
View woocommerce-auto-complete-virtual-orders.php
<?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 Jul 30, 2020
WP Trac #42573: Fix for theme template caching. https://core.trac.wordpress.org/ticket/42573
View wp-42573.php
<?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 ) {
View gravity-form-to-acf-image-field-fornt-end-posting.php
<?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 Nov 8, 2020 — 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.
View acf-seo-image.php
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 Dec 28, 2016
Example: Add order item meta to WC REST API
View wc-add-order-item-meta-to-rest-response.php
<?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
@rayrutjes
rayrutjes / search-by-algolia-for-woocommerce.php
Created Sep 23, 2016
This is a boilerplate for using Algolia in WooCommerce
View search-by-algolia-for-woocommerce.php
<?php
/**
* @wordpress-plugin
* Plugin Name: Search by Algolia for WooCommerce - Instant & Relevant results
*/
/**
* If Algolia is not active, let users know.
You can’t perform that action at this time.