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
{
ID: 1787,
comment_count: "0",
comment_status: "open",
filter: "raw",
guid: "http://local.wordpress-trunk.dev/?post_type=uc_item&p=1787",
menu_order: 0,
ping_status: "open",
pinged: "",
post_author: "1",
@joshcanhelp
joshcanhelp / ejunkie-to-woocommerce
Created February 17, 2015 16:20
This script is used to migrate a transaction export from ejunkie into a Woocommerce-powered site. Please read the comments throughout to adjust this to your use case.
<?php
/**
* Class EjunkieWpCli
*
* This class adds an 'ejunkie' command to wp-cli with a 'migrate' action
* This works for simple products, variations, and the Woocommerce API Manager
* TODO: Look for lines marked as "TODO" to change this script for your use case
*/
final class EjunkieWpCli extends WP_CLI_Command {
@joshcanhelp
joshcanhelp / gist:8a133591d79c7db04a46
Last active August 29, 2015 14:17
Completely nuke comment support in WordPress
/**
* 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/
*/
/**
@joshcanhelp
joshcanhelp / gist:5c31f8aa7194e63582bd
Last active August 29, 2015 14:21
Three columns using a shortcode (don't hate)
function otm_sc_column_wrap ( $atts = array(), $content ) {
return '<div class="column-wrap">' . do_shortcode( $content ) . '</div>';
}
add_shortcode( 'column_wrap', 'otm_sc_column_wrap' );
function otm_sc_column_3 ( $atts = array(), $content ) {
return '<div class="column-3">' . do_shortcode( $content ) . '</div>';
}
@joshcanhelp
joshcanhelp / single-tweet
Created August 14, 2015 16:19
Create a widget at Settings > Widgets > Create New, add your Twitter name, check "Exclude replies, uncheck "Auto-expand photos", then Create Widget, find the data-widget-id attribute and paste in this Gist
<div class="home-tweet">
<h6>Latest Tweet</h6>
<a class="twitter-timeline" data-dnt="true" href="[[DIRECT TWITTER PROFILE URL]]" data-widget-id="[[TWITTER WIDGET ID]]"
data-link-color="#ce2029" data-chrome="nofooter noheader noscrollbar noborders transparent" data-tweet-limit="1">
<script>!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + "://platform.twitter.com/widgets.js";
<script>
( function() {
"use strict";
// Get headline link URLs
var wpdHeadlines = document.getElementsByClassName('headline-link');
// Combine and win
var wpdTrackThese = Array.prototype.slice.call(wpdHeadlines);
@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">
@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 / 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 / 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';