Skip to content

Instantly share code, notes, and snippets.

@rgadon107
rgadon107 / code-challenge-7.js
Last active Jan 31, 2021
Solution to Code Challenge 7 from "Refactoring Tweaks Workbook"
View code-challenge-7.js
/* Code Challenge 7, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ). */
/***************************************************
*
* Original code to be refactored.
*
**************************************************/
window.PluginName = (function(window, document, $, undefined){
'use strict';
@rgadon107
rgadon107 / code-challenge-6.php
Created Jan 30, 2021
Solution to Code Challenge 6 from "Refactoring Tweaks Workbook"
View code-challenge-6.php
/* Code Challenge 6, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ). */
/***************************************************
*
* Original code to be refactored.
*
**************************************************/
/**
@rgadon107
rgadon107 / code-challenge-5.php
Created Jan 29, 2021
Solution to Code Challenge 5 from "Refactoring Tweaks Workbook"
View code-challenge-5.php
/* Code Challenge 5, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ). */
/***************************************************
*
* Original code to be refactored.
*
**************************************************/
class Session {
@rgadon107
rgadon107 / code-challenge-4.php
Last active Jan 29, 2021
Solution to Code Challenge 4 from "Refactoring Tweaks Workbook"
View code-challenge-4.php
/* Code Challenge 4, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ). */
/***************************************************
*
* Original code to be refactored.
*
**************************************************/
class Prefix_Shortcode_Course_Categories implements Prefix_Shortcode_Interface {
@rgadon107
rgadon107 / code-challenge-3.php
Last active Jan 27, 2021
Solution to Code Challenge 3 from "Refactoring Tweaks Workbook"
View code-challenge-3.php
/* Code Challenge 3, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ). */
/***************************************************
*
* Original code to be refactored.
*
**************************************************/
class Form {
@rgadon107
rgadon107 / code-challenge-2.php
Created Jan 27, 2021
Solution to Code Challenge 2 from "Refactoring Tweaks Workbook"
View code-challenge-2.php
/* Code Challenge 2, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ). */
/***************************************************
*
* Original code to be refactored.
*
**************************************************/
/* This function grabs the custom header from the current theme so that it can be displayed. */
@rgadon107
rgadon107 / code-challenge-1.php
Last active Jan 26, 2021
Solution to Code Challenge 1 from "Refactoring Tweaks Workbook"
View code-challenge-1.php
// # Code Challenge 1, from “Refactoring Tweaks Workbook” by Tonya Mork ( 2016, LeanPub (https://leanpub.com/littlegreenbookofrefactoringtweaks-workbook) ).
// ## Original code to be refactored
/**
* Check if custom post type exists, to provide data
*/
function prefix_is_post_type( string $type, int $post_id ) {
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
@rgadon107
rgadon107 / setup-phpunit.sh
Created Mar 30, 2020 — forked from keesiemeijer/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
View setup-phpunit.sh
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
@rgadon107
rgadon107 / single-event.php
Created Aug 19, 2018
Render an event venue when calling 'single-event.php'.
View single-event.php
add_action( 'genesis_entry_header', __NAMESPACE__ . '\add_content_wrap_markup_open', 3 );
/*
* Add content wrap around Event entry_header & render post thumbnail on single.
*
* @since 1.0.0
*
* return void
*/
function add_content_wrap_markup_open() {
$event_id = (int) get_the_ID();
@rgadon107
rgadon107 / Set Cookie on Form Submit and Close
Created Jul 19, 2017
Custom function to pass in a jQuery script to set a cookie via manual JS during 'on_click' trigger event and on form close.
View Set Cookie on Form Submit and Close