Skip to content

Instantly share code, notes, and snippets.

@idokd
idokd / ZoneMethodsParser.php
Created September 18, 2024 23:25
Google for Woocommerce Fix to support [qty] in flat_rate - google-listings-and-ads/src/Shipping/ZoneMethodsParser.php
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Shipping;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WC;
use WC_Shipping_Method;
use WC_Shipping_Zone;
@idokd
idokd / header.html
Last active July 10, 2024 19:38
CookieYes Consent integration with HubSpot, PixelYourSite, Google Consent
<script>
window.dataLayer = window.dataLayer || [];
window.gtag = window.gtag || function gtag() {
dataLayer.push( arguments );
};
var _cec = new Map( Cookies.get( 'cookieyes-consent' ) ? Cookies.get( 'cookieyes-consent' ).split( ',' ).map( a => a.split( ':' ) ) : [] );
var _hsp = window._hsp = window._hsp || [];
if ( _cec.get( 'analytics' ) == 'no' ) {
@idokd
idokd / slickjs-autoloaded.js
Created April 7, 2024 12:45
slickjs-autoload using div attr
jQuery( document ).ready( function() {
/*
<div data-slick="{...slick json settings}" data-slick-enabled="1" data-slick-flex="inline-flex">...</div>
Recommended css in order to obtain better performance / loading, and the use of inline-flex instead of inline slides:
<style>
@idokd
idokd / functions-intl-tel-input.php
Created February 27, 2024 10:44
wordpress intl-tel-input intlTelInput.js ultimate code
<?php
/*
regexp format for woocommerce checkout form editor, in case we wish to add validator there:
/^(\+?[0-9]{1,3})?([0-9]{3})?([0-9]{3})([0-9]{4})(\/[0-9]{4})?$/
*/
// lets define our regexp php validtor if we need it somewhere else
define( 'PHONE_VALIDATION_REGEXP', '/^(\+?[0-9]{1,3})?([0-9]{3})?([0-9]{3})([0-9]{4})(\/[0-9]{4})?$/' );
// selectors of fields that could appear anywhere in the the website
@idokd
idokd / gist:08bb3246c5f5b090fb0961692f9a3905
Created November 11, 2023 11:51
villatheme woocommerce-email-template-customizer rtl fix
/**
* Plugin Name: WooCommerce Email Template Customizer Premium
* Plugin URI: https://villatheme.com/extensions/woocommerce-email-template-customizer/
* Description: Make your WooCommerce emails become professional.
* Version: 1.2.0
*/
fix for rtl issue
woocommerce-email-template-customizer/includes/email-render.php
@idokd
idokd / customize-controls-width.php
Created August 22, 2023 08:58
WordPress Admin Customizer Controls Side-bar width size
<?php
add_action( 'customize_controls_print_styles', function() {
// TODO: consider max-width for the sidebar size
echo '<style>
body {
--site-width-size: 1280px;
--site-width-customizer-extra: 80px;
}
.wp-full-overlay.expanded {
margin-left: calc( 100vw - var( --site-width-size ) - var( --site-width-customizer-extra ) );
@idokd
idokd / autosync.php
Created May 16, 2023 12:23
acfe - autosync php file with text domain for i10n
<?php
// acf-extended/includes/modules/autosync.php: line 450, in function save_file
if ( $l10n_textdomain = apply_filters( 'acfe/settings/php/l10n_textdomain', $l10n_textdomain ) ) {
$keys = apply_filters( 'acfe/settings/php/i10n_keys', [
'title',
'label',
'instructions',
'message',
@idokd
idokd / acf_group_63ee7c57739d9.json
Created February 16, 2023 19:56
Woocommerce Multiple Stripe Accounts By Country
[
{
"key": "group_63ee7c57739d9",
"title": "Stripe Accounts",
"fields": [
{
"key": "field_63ee7c579826f",
"label": "Stripe Accounts",
"name": "stripe_accounts",
"aria-label": "",
@idokd
idokd / wc-product-vendors.php
Last active December 11, 2022 07:30
Woocommerce Product Vendors - Simple using Post Author
<?php
/* Product Vendors */
add_action( 'init', function() {
add_post_type_support( 'product', [ 'author' ] );
add_post_type_support( 'shop_order', [ 'author' ] );
@idokd
idokd / basic-authentication.php
Created September 4, 2022 13:29
PHP Basic Authentication Header
<?php
$realm = 'My Realm Name';
//user => password
$users = [ 'user1' => 'pass1', 'user2' => 'pass2' ];
$authenticated = !empty( $_SERVER[ 'PHP_AUTH_DIGEST' ] );
if ( $authenticated && !( $data = http_digest_parse( $_SERVER[ 'PHP_AUTH_DIGEST' ] ) ) || !isset( $users[ $data[ 'username' ] ] ) ) {