Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
webtoffee-git / gist:73653578b6c8a8245fc7d3e12507d84d
Created June 29, 2026 09:57
Code to add EU withdrawal button API endpoint to Perfmatters rest api exclusion - By WebToffee (WebToffee's EU withdrawal button plugin)
<?php //Do not copy this line of code
add_filter( 'perfmatters_rest_api_exceptions', function( $exceptions ) {
$exceptions[] = 'wbte-ewb';
return $exceptions;
} );
{
"mcpServers": {
"webtoffee-ai": {
"command": "npx",
"args": ["-y", "@automattic/mcp-wordpress-remote@latest"],
"env": {
"WP_API_URL": "https://yoursite.example/wp-json/mcp/mcp-adapter-default-server",
"WP_API_USERNAME": "{admin_user}",
"WP_API_PASSWORD": "{application-password}"
}
@webtoffee-git
webtoffee-git / functions.php
Last active June 23, 2026 07:52
Filter to modify EU Withdrawal button visibility - By WebToffee (WebToffee's EU Withdrawal Button plugin)
<?php //do not copy this line of code
// Show Eu withdrawal footer link only in EU countries.
add_filter( 'wbte_ewb_show_footer_withdrawal_link', function ( $show, $country ) {
$eu_countries = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' );
return $show && in_array( $country, $eu_countries, true );
}, 10, 2 );
// To Render Eu withdrawal button shortcode [wt_eu_order_withdrawal] only in EU countries.
add_filter( 'wbte_ewb_show_withdrawal_button_shortcode', function ( $show, $country ) {
$eu_countries = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' );
@webtoffee-git
webtoffee-git / gist:09cfb0dad60ea38221a41257fa783bd7
Last active June 22, 2026 08:53
WebToffee Facebook Feed: Fix missing video tag from Meta for WooCommerce - By WebToffee(WebToffee WooCommerce Product Feeds – Google Shopping, Pinterest, TikTok Ads, & More)
<?php //Do not copy this line of code
add_filter( 'wt_batch_product_export_row_data_facebook', 'wt_fix_facebook_video_field', 10, 2 );
function wt_fix_facebook_video_field( $row, $product ) {
// Only run if the feed actually has a 'video' column mapped
if ( ! array_key_exists( 'video', $row ) ) {
return $row;
}
@webtoffee-git
webtoffee-git / functions.php
Created June 18, 2026 15:27
Create a codesnipet to hide EU Withdrawal button for non-eu customer - By WebToffee
<?php //do not copy this line of code
/**
* Show withdrawal shortcode in footer for EU customers only.
*/
add_action( 'wp_footer', function () {
if ( is_admin() || ! function_exists( 'WC' ) ) {
return;
}
if ( is_user_logged_in() ) {
@webtoffee-git
webtoffee-git / functions.php
Created June 3, 2026 08:30
Code snippet for importing comma separated images as pipe separated - By WebToffee
<?php //Do not copy this line of code
add_filter('wt_woocommerce_product_import_image_separator',function(){ return ',';});
@webtoffee-git
webtoffee-git / sample.css
Created April 28, 2026 09:02
CSS to control the appearance of the link - By WebToffee
.wcc-cookie-settings-link {
display: inline-block;
font-size: 14px;
color: #0073aa; /* Adjust to match your brand color */
text-decoration: underline;
cursor: pointer;
margin-top: 10px;
}
.wcc-cookie-settings-link:hover {
color: #005177; /* Darker shade for hover state */
@webtoffee-git
webtoffee-git / sample.html
Created April 28, 2026 09:01
Code to simulate click on the revisit button - By WebToffee
<a href="#" class="wcc-cookie-settings-link" onclick="document.querySelector('.wcc-btn-revisit').click(); return false;">
Cookie Settings
</a>
@webtoffee-git
webtoffee-git / sample.js
Last active April 28, 2026 09:00
Listen for consent and replace the iframe src conditionally - by WebToffee
document.addEventListener("wcc_consent_update", function (eventData) {
const categories = eventData.detail.categories;
const accepted = categories && categories.accepted;
document.querySelectorAll('iframe[data-src*="youtube.com"]').forEach(function (iframe) {
if (accepted && accepted.includes('marketing')) {
iframe.src = iframe.getAttribute('data-src');
} else {
iframe.removeAttribute('src');
}
@webtoffee-git
webtoffee-git / sample.js
Created April 28, 2026 08:37
check whether the user has already consented in a previous session and act accordingly - By WebToffee
document.addEventListener("_wccBannerVisible", function (event) {
const consentData = getWccConsent();
// Check stored analytics consent
if (consentData.categories.analytics === true) {
console.log("Analytics consent is YES (true).");
// Load analytics scripts
} else {
console.log("Analytics consent is NO (false).");
// Do not load analytics scripts