Skip to content

Instantly share code, notes, and snippets.

View robbiegod's full-sized avatar
🧛‍♂️

Robert Fletcher robbiegod

🧛‍♂️
View GitHub Profile
@robbiegod
robbiegod / licence activation.php
Created December 5, 2019 21:33 — forked from mattradford/licence activation.php
ACF5 Pro licence activation. Could be adapted for any other plugin that requires a licence key, but doesn't yet support defining it in wp-config. Fires on theme activation.
// Place this in wp-config
define( 'ACF_5_KEY', 'yourkeyhere' );
// Set ACF 5 license key on theme activation. Stick in your functions.php or equivalent.
function auto_set_license_keys() {
if ( ! get_option( 'acf_pro_license' ) && defined( 'ACF_5_KEY' ) ) {
$save = array(
'key' => ACF_5_KEY,
@robbiegod
robbiegod / google tag manager and google analytics with event tracking.md
Last active November 4, 2020 15:21
Google Tag Manager and Google Analytics Event Tracking

Google Tag Manager and Google Analytics with Event Tracking using gtag.js

Setup gtm container Add the code to webpage. Setup a Google Analytics property, get the GA Tracking ID Add gtag.js to the webpage before GTM code.

<script async src="https://www.googletagmanager.com/gtag/js?id=######"></script>
@robbiegod
robbiegod / index.html
Last active February 5, 2019 20:25
Expandable Area
<button id="btnExpand" onClick="showMsg();">Click here to see all +</button>
<div id="welcomeMsg" class="closed">
<div id="collapse-window" class="standard-window">
<div class="inner-wrapper">
<h5>In 2018, we also helped the following audiences:</h5>
<p>Lorum ipsum</p>
</ul>
</div>
@robbiegod
robbiegod / imagick_average_colour.php
Last active May 9, 2018 19:28 — forked from paulferrett/imagick_average_colour.php
This function will get the average colour of an image file using PHP and Image Magick using the IMagick extension.
<?php
/**
* Get the average pixel colour from the given file using Image Magick
*
* @param string $filename
* @param bool $as_hex Set to true, the function will return the 6 character HEX value of the colour.
* If false, an array will be returned with r, g, b components.
*/
function get_average_colour($filename, $as_hex_string = true) {
@robbiegod
robbiegod / rest_insert_post.php
Created April 16, 2018 15:32 — forked from andrewahead4/rest_insert_post.php
A simple post insert using WP REST API and PHP over basic authentication
<?php
///////////////////////////////////////////////////////////////////////////////////
// //
// This is using a sample local WordPress Install and is not production safe //
// It uses the REST and Basic Auth plugins //
// //
///////////////////////////////////////////////////////////////////////////////////
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Skubbs_Post_Types {
public static function init() {
add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
@robbiegod
robbiegod / functions.php
Last active August 28, 2018 16:00
Wordpress Function: Loads a single-{cat->slug}.php by category slug or single-{post_type}.php custom template by post type. If these don't exist use single.php.
<?php
/**
* single-{category_slug}.php || single-post-type.php || single.php
*
* Gets post cat slug, post type and look matching single- templates.
* If $categories is not empty, get the category slug, and look for single-{$category_slug}.php. If this file doesn't exist then return single.php.
* If $categories is empty, then check the post_type. If its not equal to post, then we are using a custom post type. Look for
* single-{$post_type}.php. If this file doesn't exist then use single.php.
* If $categories is empty and post_type is equal to post then use single.php.
*
@robbiegod
robbiegod / function.textoimage.php
Last active February 21, 2017 19:27
makeImage with PHP function
<?php
function makeImage( $msg, $msg2, $font='./arial.ttf', $fontsize=40, $output='pic1.png')
{
$fontcolor = imagecolorallocate($im, 128, 128, 128);
echo $msg;
echo "<br/>".$msg2;
$backgroundImg = imagecreatefromjpeg("logo-usarmy-with-texture-640x360.jpg");
<%@ WebHandler Language="C#" Debug="true" Class="name" %>
using System.Web;
public class name : IHttpHandler {
public void ProcessRequest (HttpContext context) {
}
@robbiegod
robbiegod / wordpress_functions.php
Last active October 10, 2017 18:01
Wordpress Short Title Function and Google Analytics Shortcode
<?php
/* Short Title
* return a short title with ellipsis if the title is too long
* accepts a maxchar value
* Usage Example: echo short_title( $maxchar = 100 );
* Place the code inside the loop and set the character limit. If the title is longer than the character limit set,
* it will display ellipsis at the end.
--------------------------------------------------------------------*/
function short_title( $maxchar = 90 ) {