Skip to content

Instantly share code, notes, and snippets.

🎅

Robert Fletcher robbiegod

🎅
Block or report user

Report or block robbiegod

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@robbiegod
robbiegod / licence activation.php
Created Dec 5, 2019 — 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.
View licence activation.php
// 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 Feb 24, 2020
Google Tag Manager and Google Analytics Event Tracking
View google tag manager and google analytics with event tracking.md

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>

<script>
@robbiegod
robbiegod / index.html
Last active Feb 5, 2019
Expandable Area
View index.html
<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 — 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.
View imagick_average_colour.php
<?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 Apr 16, 2018 — forked from andrewahead4/rest_insert_post.php
A simple post insert using WP REST API and PHP over basic authentication
View rest_insert_post.php
<?php
///////////////////////////////////////////////////////////////////////////////////
// //
// This is using a sample local WordPress Install and is not production safe //
// It uses the REST and Basic Auth plugins //
// //
///////////////////////////////////////////////////////////////////////////////////
View register-post-type.php
<?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 Aug 28, 2018
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.
View functions.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 Feb 21, 2017
makeImage with PHP function
View function.textoimage.php
<?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");
View genericIhttpHandler.ashx
<%@ 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 Oct 10, 2017
Wordpress Short Title Function and Google Analytics Shortcode
View wordpress_functions.php
<?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 ) {
You can’t perform that action at this time.