Skip to content

Instantly share code, notes, and snippets.

View capitalize_words.js
/**
* HubSpot custom code action
*
* Capitalizes the first letter of every part of a contact's first name, last name, address and city.
*
* Can easily be configured to update any other contact property.
*
* Examples:
* - john -> John
* - DOE -> Doe
View get_visitor_ip.php
<?php
// https://stackoverflow.com/a/2031935/4688612
// https://stackoverflow.com/q/67277544/4688612
protected function get_visitor_ip(): string
{
$proxy_headers = [
'HTTP_CF_CONNECTING_IP', // Cloudflare
'HTTP_TRUE_CLIENT_IP', // Cloudflare Enterprise
'HTTP_INCAP_CLIENT_IP', // Incapsula
View disable-pmw-on-thrive-editor.php
<?php
/**
* This mu plugin deactivates the Pixel Manager
* while the Thrive Theme editor is active.
*
* Create a file disable-pmw-on-thrive-editor.php.
* Place it in the /mu-plugins/ folder within the /wp-content/ folder.
* If the /mu-plugins/ folder doesn't exist yet, it must be manually created.
*/
View changelog.php
<?php
/*
* Keywords: freemius, readme.txt, changelog, free version, pro version
*
* Description: This code takes a readme.txt of a WordPress plugin, that has been prepared for deployment
* over freemius, and generates a changelog text output with the changelog for the free and one for the pro version.
*/
$source_file = '../src/readme.txt';
@alewolf
alewolf / wpm_google_ads_conversion_identifiers.php
Last active Feb 1, 2022
add conversion identifiers to the Google Ads pixel output
View wpm_google_ads_conversion_identifiers.php
<?php
/*
* Since version 1.8.2 of the plugin.
*
* This filter will add aditional conversion ID and label pairs to the output
* of the Google Ads pixel.
*
* It will add the output to every page with the Google Ads remarketing pixel,
* including the purchase confirmation page.
@alewolf
alewolf / gist:5d933417e35a3d7585b96e2ada9f2e05
Last active Jul 15, 2020
resync variable product in WooCommerce
View gist:5d933417e35a3d7585b96e2ada9f2e05
<?php
/***********************************************************************************************
* This function will automatically resync variable product prices in case the prices don't show
* on the catalogue pages anymore.
*
* Simply place it in functions.php
***********************************************************************************************/
add_filter( 'woocommerce_get_price_html', 'resync_variable_product', 100, 2 );
View gist:b37fbd2679afae7abac390090c76c63c
/**
* Title: Generic Keywords Remover
* Descritpion: Remove generic keywords from branded search campaigns
* Author: Wolf+Bär Agency, Aleksandar Vucenovic
* Website: https://wolfundbaer.ch
* License: GNU GPLv3
* Version: 0.2
* URL: https://gist.github.com/alewolf/b37fbd2679afae7abac390090c76c63c
* URL:
*/
View .htaccess
# BEGIN WPML Redirect
RewriteEngine on
RewriteCond %{QUERY_STRING} lang=(..) [NC]
RewriteCond %{REQUEST_URI} !^/wp-admin [NC]
RewriteRule ^(.*\/)|^$ /%1/$1? [L,R=301]
# END WPML Redirect
View new-reply-to.php
<?php
// replace reply-to email address for WooCommerce customer emails
add_filter( 'woocommerce_email_headers', 'new_customer_order_reply_to_email_address', 20, 3 );
function new_customer_order_reply_to_email_address( $header, $email_id ) {
$customer_email_ids = array(
'customer_on_hold_order',
'customer_processing_order',
@alewolf
alewolf / gist:ae90ea9c658df09b08d129f58575213c
Last active Mar 19, 2018
AdWords MCC Script: Triple Match
View gist:ae90ea9c658df09b08d129f58575213c
/**
* Title: Triple Match MCC
* Descritpion: Adds the missing match types of each keyword in every ad group
* Author: Wolf+Bär Agency, Aleksandar Vucenovic
* Website: https://wolfundbaer.ch
* License: GNU GPLv3
* Version: 0.4
* URL: https://gist.github.com/alewolf/ae90ea9c658df09b08d129f58575213c
* URL:
*/