Skip to content

Instantly share code, notes, and snippets.

@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 April 17, 2024 14:45
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);
@pacotole
pacotole / joinchat-filter-examples.php
Last active May 24, 2021 18:28
Joinchat Agents filter examples of available agents by product category
<?php
// Array filter items that field contains $value
function array_filter_field_contains( $array, $field, $values ) {
return array_filter(
$array,
function( $item ) use ( $field, $values ) {
foreach ( (array) $values as $value ) {
if ( false !== stripos( $item[ $field ], $value ) ) {
return true;
@pacotole
pacotole / contact-form-7.php
Last active July 21, 2021 07:45
Only enqueue Contact Form 7 scripts when there is a form in the page
/**
* Contact Form 7 only enqueue scripts when there is a form in the page
*/
// Disable contact-form-7 recaptcha enqueue action
remove_action( 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts', 20 );
// Dequeue contact-form-7 scripts
function contact_form_7_dequeue_scripts() {
wp_dequeue_script( 'contact-form-7' );