Skip to content

Instantly share code, notes, and snippets.

@maciejbis
Last active November 10, 2021 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejbis/88010dc6f02dfec1f707513b7db1b754 to your computer and use it in GitHub Desktop.
Save maciejbis/88010dc6f02dfec1f707513b7db1b754 to your computer and use it in GitHub Desktop.
A barebone plugin that allows you to add custom code snippets to your WordPress website
<?php
/*
* Plugin Name: My custom code snippets
* Plugin URI: https://permalinkmanager.pro/
* Description: A barebone plugin that allows you to add custom code snippets to your WordPress website
* Version: 1.0.0
* Author: Maciej Bis
* Author URI: http://maciejbis.net/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*/
/**
* [Add Google Analytics Tracking]
* This is only an example snippet, you are free to remove the below function.
*/
function bis_add_google_analytics_code() {
?>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<?php
}
add_action( 'wp_footer', 'bis_add_google_analytics_code' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment