Skip to content

Instantly share code, notes, and snippets.

View katsar0v's full-sized avatar
💭
Happy

Kristiyan Katsarov katsar0v

💭
Happy
View GitHub Profile
@katsar0v
katsar0v / migrateorders.php
Created July 31, 2021 13:08 — forked from cfaria/migrateorders.php
Migrate WooCommerce Orders
<?php
//increase max execution time of this script to 150 min:
ini_set('max_execution_time', 9000);
//increase Allowed Memory Size of this script:
ini_set('memory_limit','960M');
// Copies woocommerce orders and users over from source to target.
// I use this on my local machine - loading both db's up there side by side
// could easily adjust the connect strings to connect elsewhere if needed.
@katsar0v
katsar0v / remove-not-needed-libraries.php
Created July 25, 2021 13:58
Optimize WooCommerce For Web Vitals
<?php
/**
* Disable WooCommerce block styles (front-end).
*/
function slug_disable_woocommerce_block_styles() {
if( function_exists( 'is_woocommerce') ) {
if( !is_woocommerce() && !is_cart() && !is_checkout() ) {
wp_dequeue_style( 'wc-block-style' );
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'woocommerce-layout' );
@katsar0v
katsar0v / create-webp-copy-in-wp.php
Last active February 16, 2023 02:09
Create WebP Copy In WordPress
<?php
function generate_webp_from_file($file, $compression_quality = 80) {
// check if file exists
if (!file_exists($file)) {
return false;
}
// If output file already exists return path
$output_file = $file . '.webp';
if (file_exists($output_file)) {
@katsar0v
katsar0v / delay-inline-js.php
Last active July 25, 2021 11:06
Delay Inline JavaScript With W3 Total Cache
<?php
add_filter('w3tc_process_content', function( $content ) {
preg_match_all( "/<script(?:[^>]*)>(?<content>[\s\S]*?)<\/script>/ims", $content, $matches, PREG_SET_ORDER );
foreach ( $matches as $code ) {
if ( strpos( $code['content'], 'jQuery(' ) === false ) {
continue;
}
if ( strpos( $code['content'], 'DOMContentLoaded' ) !== false ) {
continue;