Skip to content

Instantly share code, notes, and snippets.

@runezero
runezero / wp_all_import_is_post_to_update.php
Last active June 21, 2022 12:55
[Check if post import can update] Implement a check if an item in WP-All may import with this filter #wordpress
function my_is_post_to_update( $continue, $post_id, $xml_node, $import_id ) {
// Run this code on a specific import
if ($import_id === 5) {
// Do something to decide if this post should update
if ( ... ) {
return true;
}
// Don't update this post
return false;
}
@runezero
runezero / backorder.php
Last active June 21, 2022 12:03
[Force stock and backorder status] Set product status with a selection of filters #woocommerce
//https://stackoverflow.com/questions/52462239/allow-backorders-and-notify-customer-for-specific-product-categories-in-woocomme
add_filter( 'woocommerce_product_is_in_stock', 'filter_product_is_in_stock', 10, 2 );
function filter_product_is_in_stock( $is_in_stock, $product ){
// Here set the products categories in the array (can be terms ids, slugs or names)
$categories = array("clothing");
if( has_term( $categories, 'product_cat', $product->get_id() ) ){
$is_in_stock = true;
}
@runezero
runezero / font-awesome.php
Last active June 21, 2022 09:14
[Font awesome enqueue] Register Font-Awesome icons to use #wordpress
add_action( 'wp_enqueue_scripts', 'my_enqueue_fontawesome' );
function my_enqueue_fontawesome(){
wp_enqueue_script( 'wp_fontawesome', 'https://kit.fontawesome.com/1339480997.js', [], '5' );
}
@runezero
runezero / install.txt
Created June 20, 2022 14:41
[Set up Multisite] Enable multisite #wordpress
Multi site opzetten + dupliceren
EN: .com
Japan: .com/ja
China: .com/zh-hans
Volg stappenplan:
https://codex.wordpress.org/Create_A_Network
@runezero
runezero / admin_init.php
Created June 20, 2022 14:06
[Change product meta] update bulk products to adjust the meta data #woocommerce
<?php
add_action('admin_init', function(){
$query = new WC_Product_Query( array(
'limit' => -1,
'type' => 'variable',
'return' => 'ids',
'backorders' => 'no',
//'manage_stock' => true
@runezero
runezero / Download_ics_file.php
Last active June 20, 2022 12:09
[Download Calendar file] Download a calendar file according to given parameters #tools
include('ICS.php');
date_default_timezone_set('Europe/Amsterdam');
$date = "18-06-2022";
$time = "15:30:00";
$startTime = $date . " " . $time;
if (date('I', strtotime($startTime))) {
$timestamp = strtotime($startTime) - (60*60*2); //minus 2 hours for server time for summer time
$startTime = date('Y-m-d H:i:s', $timestamp);
@runezero
runezero / woocommerce_get_image_size_gallery_thumbnail.php
Created June 20, 2022 11:41
[Archive Change image size] Change the archive image size for WooCommerce products #woocommerce
@runezero
runezero / woocommerce_after_shop_loop.php
Last active June 16, 2022 12:26
[Replace Woo pager with FacetWP pager] Removes the WooCommerce default pager and displays a FacetWP Pager #woocommerce
<?php
// FacetWP pager
add_action('wp', function(){
if (is_product_category()) {
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_after_shop_loop', 'avia_woocommerce_after_shop_loop', 10);
add_action( 'woocommerce_after_shop_loop', function(){
echo '<div class="archive-pager">';
echo '<div class="pagination">'.facetwp_display( 'pager' ).'</div>';
@runezero
runezero / body_class.php
Created June 13, 2022 14:11
[Add body css class] Add a custom body class to the WordPress website #wordpress
<?php
// Add specific CSS class by filter.
add_filter( 'body_class', function( $classes ) {
$classes[] = 'dsm_body_' . get_current_blog_id();
return $classes;
} );
@runezero
runezero / mobile-size.scss
Created June 13, 2022 13:55
[Mobile menu custom width] Change the breakpoint for the mobile menu width #enfold
@media (max-width: 1250px) { /* Change the width as you need */
.responsive #top #avia-menu.av-main-nav .menu-item {
display: none !important;
}
.responsive #top .#avia-menu.av-main-nav .menu-item-avia-special {
display: block !important;
}
}