Skip to content

Instantly share code, notes, and snippets.

View jshrssll's full-sized avatar

Joshua jshrssll

  • Sydney, AU
  • 03:06 (UTC +10:00)
View GitHub Profile
@jshrssll
jshrssll / theme_set_post_views.php
Last active November 26, 2019 23:46
Increment page view count in Wordpress
function theme_set_post_views($id) {
$count_key = 'theme_post_views_count';
$count = get_post_meta($id, $count_key, true);
if ($count == '') {
$count = 0;
delete_post_meta($id, $count_key);
add_post_meta($id, $count_key, '0');
} else {
$count++;
@jshrssll
jshrssll / analytics.js
Last active September 27, 2019 11:55
/**
* @class Analytics
* @author Joshua Russell <josh.russell@holler.com.au>
*
* A wrapper class for sending Google Analytics events
* https://developers.google.com/analytics/devguides/collection/analyticsjs/events
* ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue]);
*
* Usage:
* Add a data-ga to html elements to track `click` events