Skip to content

Instantly share code, notes, and snippets.

View Dan0sz's full-sized avatar
🤓
Geek-mode Initialized

Daan van den Bergh Dan0sz

🤓
Geek-mode Initialized
View GitHub Profile
@Dan0sz
Dan0sz / adwords.caos.php
Created April 19, 2023 14:14
Use Adwords with CAOS
add_action(
'caos_gtag_additional_config',
function () {
?>
gtag('config', '<?php echo 'AW-453289819'; ?>');
<?php
}
);
@Dan0sz
Dan0sz / anonymize-ip.php
Last active January 23, 2022 21:35
Anonymize the last two octets of an IP address, by replacing it with 0 (zero)
<?php
$octets = explode('.', $ip);
/**
* Instead of using Regex and str_replace, we're slicing the array parts
* and rebuilding the ip (implode) to make sure no duplicate values are
* replaced.
*
* E.g. using str_replace or preg_replace; 192.168.1.1 would result in 092.068.0.0.
*/
@Dan0sz
Dan0sz / daan-date-last-modified.php
Last active March 11, 2020 08:59
Add Date Last Modified next to Published Date in WordPress Posts.
<?php
/**
* Plugin Name: Date Last Modified for WordPress Posts
* Plugin URI: https://daan.dev/wordpress/date-last-updated-modified/
* Description: Display 'Last Updated' date along with 'Date Published' in WordPress.
* Version: 1.0.0
* Author: Daan van den Bergh
* Author URI: https://daan.dev
* License: GPL2v2 or later
* Text Domain: daan-date-last-modified
@Dan0sz
Dan0sz / caos-google-ads.php
Last active October 30, 2023 20:49
Track Google Ads conversions with CAOS for WordPress
<?php
/**
* @formatter:off
* Plugin Name: Google Ads for CAOS
* Plugin URI: https://daan.dev/google-adwords-caos/
* Description: Track Google Ads conversions with CAOS.
* Version: 1.0.0
* Author: Daan van den Bergh
* Author URI: https://daan.dev
* License: GPL2v2 or later
@Dan0sz
Dan0sz / caos-google-optimize.php
Last active January 3, 2020 14:28
Add Google Optimize to CAOS
<?php
/**
* @formatter:off
* Plugin Name: Google Optimize for CAOS
* Plugin URI: https://daan.dev/google-optimize-caos/
* Description: Add Google Optimize for CAOS in gtag.js
* Version: 1.0.0
* Author: Daan van den Bergh
* Author URI: https://daan.dev
* License: GPL2v2 or later
@Dan0sz
Dan0sz / class-wp-proxy.php
Created September 18, 2019 20:58
A WordPress REST Controller to pass-thru Google Analytics Data
<?php
/**
* @author : Daan van den Bergh
* @url : https://daan.dev/how-to/bypass-ad-blockers-caos/
* @copyright: (c) 2019 Daan van den Bergh
* @license : GPL2v2 or later
*/
class Analytics_Proxy extends WP_REST_Controller
{
@Dan0sz
Dan0sz / functions.php
Last active April 30, 2019 17:46
Remove Google Fonts from Sparkling WordPress Theme using a Child Theme
<?php
// The start of my Child Theme's functions.php
function sparkling_remove_google_fonts() {
wp_dequeue_style('sparkling-fonts');
wp_deregister_style('sparkling-fonts');
}
add_action('wp_enqueue_scripts', 'sparkling_remove_google_fonts', 100);
@Dan0sz
Dan0sz / edited-wp-config.php
Last active March 10, 2019 10:54
An example wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'new_db_name' ); # CHANGE THIS!
/** MySQL database username */
define( 'DB_USER', 'existing_db_username' );
/** MySQL database password */
define( 'DB_PASSWORD', 'existing_db_password' );
@Dan0sz
Dan0sz / find-replace.sql
Last active March 10, 2019 09:07
MySQL find and replace query
UPDATE `table_name`
SET `column_name` = replace(column_name, 'olddomain.com', 'newdomain.com')
@Dan0sz
Dan0sz / 301-redirect-with-exception.sh
Last active March 10, 2019 09:00
301 Redirect to new domain including Request URI
RewriteEngine on
# Exception for Google Verification
RewriteCond %{REQUEST_URI} !^/google-verification-file.html
# Exception Let's Encrypt Challenge
RewriteCond %{REQUEST_URI} !^/.well-known/
# 301 Redirect to New Domain incl. Request URI
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]