Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Danny van Kooten dannyvankooten

🏠
Working from home
Block or report user

Report or block dannyvankooten

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dannyvankooten
dannyvankooten / custom-subscriber-count.php
Last active Sep 19, 2019
Include unsubscribe count in subscriber count
View custom-subscriber-count.php
<?php
add_filter('mc4wp_subscriber_count', function($count, $list_ids) {
$count = get_transient('guillaume_subscriber_count');
if ($count === false) {
$api = mc4wp_get_api_v3();
$count = 0;
foreach ($list_ids as $list_id) {
$data = $api->get_list($list_id, array('fields' => 'stats'));
@dannyvankooten
dannyvankooten / functions.php
Created Mar 12, 2019
Set additional field values for every person that subscribes using the Mailchimp for WordPress WooCommerce checkout integration.
View functions.php
<?php
add_filter( 'mc4wp_integration_woocommerce_data', function($data) {
$data['BLOGI'] = 'Kyllä';
$data['KAUPPA'] = 'Kyllä';
return $data;
});
View functions.php
<?php
add_filter( 'mc4wp_form_redirect_url', function( $url, $form ) {
if( $form->last_event === 'subscriber_updated' ) {
return '';
}
return $url;
}, 10, 2 );
@dannyvankooten
dannyvankooten / USAGE.md
Last active Oct 15, 2018
Autofill VATMOSS formulier op Belastingdienst.nl. Provided as is, use at your own risk.
View USAGE.md
  1. Add function via browser console
  2. Call function like this:
vatmossbot(`20% VAT SK Standard     20% btw  50,91  10,18
23% VAT PL Standard     23% btw  48,02   11,04
....
`)
@dannyvankooten
dannyvankooten / functions.php
Last active Jul 4, 2018
Keeps billing_first_name and billing_last_name fields (from WooCommerce) to always have the same value as WordPress" first_name and last_name fields.
View functions.php
<?php
add_action( 'profile_update', function( $user_id ) {
$user = get_userdata( $user_id );
update_user_meta( $user_id, 'billing_first_name', $user->first_name );
update_user_meta( $user_id, 'billing_last_name', $user->last_name );
});
View index.html
<script>
(function(f, a, t, h, o, m){
a[h]=a[h]||function(){
(a[h].q=a[h].q||[]).push(arguments)
};
o=f.createElement('script'),
m=f.getElementsByTagName('script')[0];
o.async=1; o.src=t; o.id='fathom-script';
m.parentNode.insertBefore(o,m)
})(document, window, '//ec2-54-215-173-238.us-west-1.compute.amazonaws.com:9000/tracker.js', 'fathom');
@dannyvankooten
dannyvankooten / hs_tickets.15m.py
Created Jun 11, 2018
Argos (and most likely Bitbar) script to show list of open HelpScout tickets in your Gnome menu bar. https://github.com/p-e-w/argos
View hs_tickets.15m.py
#!/usr/bin/env python3
import requests
import base64
# Set these for authorizing with the HelpScout API
# You can create an App from your HS user profile: https://secure.helpscout.net/users
CLIENT_ID = 'client-id-here'
CLIENT_SECRET = 'client-secret-here'
@dannyvankooten
dannyvankooten / functions.php
Created May 28, 2018
Clear IP address & user agent before HTML Forms submissions are saved
View functions.php
<?php
add_action( 'hf_process_form', function( $form, $submission ) {
$submission->ip_address = '';
$submission->user_agent = '';
}, 10, 2 );
@dannyvankooten
dannyvankooten / gist:5bbde3eca3db874b172f95d5589d8189
Created May 25, 2018
Snippet to send full country name to MailChimp from WooCommerce checkout
View gist:5bbde3eca3db874b172f95d5589d8189
add_filter( 'mc4wp_integration_woocommerce_data', function( $data ) {
// Grab MailChimp field values from the current request
if ( isset( $_POST['billing_country'] ) ){
switch( $_POST['billing_country'] ){
case 'AD';
$data['COUNTRY'] = 'Andorra';
break;
case 'AE';
$data['COUNTRY'] = 'United Arab Emirates';
@dannyvankooten
dannyvankooten / functions.php
Last active Apr 30, 2018
Force-load the HTML Forms JavaScript file, when lazy-loading isn't working for you.
View functions.php
<?php
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script('html-forms');
}, 90 );
You can’t perform that action at this time.