Skip to content

Instantly share code, notes, and snippets.

View pacotole's full-sized avatar

Pacotole pacotole

View GitHub Profile
@pacotole
pacotole / wordpress-disable-optimizers.md
Last active January 20, 2026 10:30
WordPress debug bypass optimizers with a url query param

Optimizers

Some WordPress optimization plugins allow you to view the original page without applying optimizations to compare and check if it works correctly before applying them.

You can view the original page by adding a query parameter to the URL.

Note that the first parameter of the URL is preceded by "?" and subsequent parameters are preceded by "&".

Autoptimize

@pacotole
pacotole / joinchat-ai-fix-expired-nonce.php
Last active January 16, 2026 15:37
Joinchat AI fix expired nonce with page cache
/**
* Joinchat AI disable nonce validation in front requests to prevent page cache with expired nonces.
*/
add_action( 'rest_api_init', function() {
// Only modify the authentication for the Joinchat AI refresh token endpoint.
if ( ! isset( $_SERVER['REQUEST_URI'] ) || ! str_contains( wp_unslash( $_SERVER['REQUEST_URI'] ), '/joinchat-ai/v1/refresh_token' ) ) {
return;
}
@pacotole
pacotole / joinchat-show-chat-window.php
Created February 19, 2024 18:19
Joinchat always show Chat Window
<?php
/**
* Snippet 1: Set current CTA always as "not viewed".
* Chat Window will show with your Joinchat settings.
*/
add_filter( 'joinchat_get_settings', function( $settings, $obj ) {
$settings['is_viewed'] = false;
return $settings;
}, 10, 2 );
@pacotole
pacotole / joinchat-propagate-product-category-settings.php
Last active September 15, 2023 17:45
Propagate product category custom Joinchat settings to products with that category and propagate to Cart and Checkout Pages if contains that product.
<?php
/**
* Joinchat use Product category settings on product page
*
* Use custom Joinchat settings from the first category of the product
* with custom Joinchat settings.
*
* @param array $settings
* @return array
@pacotole
pacotole / images-to-webp.php
Created June 29, 2023 15:00
Fork of "Images to WebP" (https://wordpress.org/plugins/images-to-webp/) with ABSPATH filter
<?php
/*
Plugin Name: Images to WebP
Plugin URI: https://www.paypal.me/jakubnovaksl
Description: Convert JPG, PNG and GIF images to WEBP, speed up your web
Version: 4.2
Author: KubiQ
Author URI: https://kubiq.sk
Text Domain: images-to-webp
Domain Path: /languages
@pacotole
pacotole / creame-optimize.php
Last active October 31, 2024 21:15
WordPress must-use plugin with site optimizations
<?php
/*
Plugin Name: Creame Optimize
Plugin URI: https://crea.me/
Description: Optimizaciones de Creame para mejorar tu <em>site</em>.
Version: 2.1.5
Author: Creame
Author URI: https://crea.me/
License: MIT License
*/
@pacotole
pacotole / class-wc_update-variation_in-cart_ck.php
Created April 6, 2022 15:05
"Woo Update Variations In Cart" updated for WooCommerce 6 and PHP 8
<?php
class Wc_updateVariationInCart {
public function __construct() {
if ( $this->woo_ck_wuvic_is_woocommerce_active() ) {
// add js file to cart
add_action( 'wp_head', array( $this, 'woo_ck_wuvic_hook_js' ) );
@pacotole
pacotole / review-structured-data-shortcode.php
Created June 1, 2021 11:53
Shortcode to output Review Structured Data ld+json
<?php
/**
* Shortcode to output Review Structured Data ld+json
*
* Example: to use in Tesminonial CPT
* Usage: [review_json]
*/
function review_structured_data_shortcode() {
$post_id = get_the_ID();
@pacotole
pacotole / joinchat-cta-force-https.php
Created June 1, 2021 11:33
Join.chat CTA Extras force https on links and image sources
<?php
add_filter( 'joinchat_format_replacements', function($replaces) {
$replaces['/(http:\/\/)/u'] = 'https://';
return $replaces;
}, 999);