Skip to content

Instantly share code, notes, and snippets.

View joshcanhelp's full-sized avatar
👋
Open to new connections!

Josh Cunningham joshcanhelp

👋
Open to new connections!
View GitHub Profile
@joshcanhelp
joshcanhelp / wp-env.php
Last active April 24, 2018 21:36
Get WordPress environment telemetry
function get_wp_env() {
$server_software = filter_input( INPUT_SERVER, 'SERVER_SOFTWARE', FILTER_SANITIZE_STRING );
if ( $server_software ) {
$server_software = explode( ' ', trim( $server_software ) );
$server_software = $server_software[0];
} else {
$server_software = __( 'unknown', 'wp-auth0' );
}
try {
@joshcanhelp
joshcanhelp / generate_wp_environment.sh
Created April 18, 2018 21:51
Generate a WP-Auth0 testing platform with PHP and MySQL already installed
#!/usr/bin/env bash
#
# Check for flags
#
# -d will use all default values
USE_DEFAULTS=false;
# -r will reset the install first (delete the DB and files)
@joshcanhelp
joshcanhelp / auth0-styleguide.scss
Created April 10, 2018 23:24
Auth0 Styleguide SCSS include
// Primary colors
// http://styleguide.auth0.com/#/design/primary-colors
$color-red: #EB5424;
$color-blue-light: #44C7F4;
$color-blue: #16214D;
$color-yellow: #EACA2C;
// Secondary colors
// http://styleguide.auth0.com/#/design/secondary-colors
@joshcanhelp
joshcanhelp / wp-auth0-hook.php
Created March 29, 2018 17:55
Append a cache-breaking parameter to login_url redirects
/**
* Append a cache-breaking parameter to login_url redirects
*
* @param string $login_url
* @param string $redirect
*
* @return string
*/
function wp_auth0_gist_cache_break_redirect_to( $login_url, $redirect ) {
if ( ! empty( $redirect ) ) {
/**
* Find next available server number
*
* @param servers
*
* @return {int}
*/
function next_server_number( servers ) {
'use strict';
@joshcanhelp
joshcanhelp / WPRemoveComments.php
Created March 1, 2017 20:07
WordPress: remove comment support completely
<?php
/**
* Completely nuke comments support
* Need to also also turn off comments/pingbacks at wp-admin > Settings > Discussion
* Need to also turn off comments for posts individually (Bulk Edit or DB find/replace)
*
* Adapted from: https://www.dfactory.eu/wordpress-how-to/turn-off-disable-comments/
*
* @package WordPress
@joshcanhelp
joshcanhelp / parseUrlParams.js
Last active February 5, 2017 03:39
Get the various parameters from a URL piece, hash or query
/**
* Get the various parameters from a URL piece, hash or query
*
* @param params
*
* @returns {{}}
*/
function parseUrlParams( params ) {
'use strict';
@joshcanhelp
joshcanhelp / scrollTo.js
Last active January 28, 2022 13:21
Animated scrollTo for specific element or top of page
//
// Smooth scroll-to inspired by:
// http://stackoverflow.com/a/24559613/728480
//
module.exports = function (scrollTo, scrollDuration) {
//
// Set a default for where we're scrolling to
//
@joshcanhelp
joshcanhelp / gist:87e1bb70f97475bccc9eb123e3fe2f1c
Last active February 21, 2020 13:58
Lets you add custom fields to a WordPress post or page via shortcodes. This allows you to use the WordPress mobile app to update custom fields. Currently working on this for a product release and wanted to share.
<?php
/*
Plugin Name: Custom Field Shortcodes
Version: 0.0.1
Plugin URI: https://gist.github.com/joshcanhelp/87e1bb70f97475bccc9eb123e3fe2f1c
Description: Lets you add custom fields to a WordPress post or page via shortcodes.
Author: Josh Can Help
Author URI: http://www.joshcanhelp.com/
License: GPL v3
*/
@joshcanhelp
joshcanhelp / google-recaptcha.php
Last active December 6, 2023 05:53
Add a Google RECAPTCHA and honeypot to a WordPress registration form
<?php
/**
* Adds first and last name to the registration field
*/
function proper_add_user_reg_fields () {
?>
<p class="reg-email-validation">
<label for="confirm_email_address">