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 / 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 / template-sharing-box.php
Created October 21, 2018 12:57
Pure PHP template for Facebook, Twitter and Google+ Share Buttons
<?php
/* Social Share Buttons template for Wordpress
* By Daan van den Bergh
*/
$postUrl = 'http' . ( isset( $_SERVER['HTTPS'] ) ? 's' : '' ) . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?>
<section class="sharing-box content-margin content-background clearfix">
<h5 class="sharing-box-name">Don't be selfish. Share the knowledge!</h5>
<div class="share-button-wrapper">
@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 / apps.conf
Created October 21, 2018 12:33
Nginx configuration for reverse proxy for SABnzbd, Sonarr, Radarr and Transmission
server_name nas.yourdomain.com 192.168.xxx.xxx;
location /sabnzbd {
proxy_pass https://localhost:9080/sabnzbd;
}
location /sonarr {
proxy_pass http://localhost:8989/sonarr;
}
@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 / host-anything-locally.php
Last active April 7, 2021 15:06
Script to host any javascript file locally, which can be scheduled using Crontab
<?php
// Script to update any js-file
// Credits go to: Matthew Horne
// Remote file to download
$remoteFile = 'https://www.google-analytics.com/analytics.js';
$localFile = '/path/to/your/webroot/analytics.js';
// Check if directory exists, otherwise create it.
$uploadDir = '/path/to/your/webroot/';
@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-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);