Skip to content

Instantly share code, notes, and snippets.

View KustomDeveloper's full-sized avatar
:octocat:
Building React Apps

Michael Hicks KustomDeveloper

:octocat:
Building React Apps
View GitHub Profile
@KustomDeveloper
KustomDeveloper / country-shortcode.php
Created November 22, 2016 18:18 — forked from MatthewEppelsheimer/country-shortcode.php
WP Contact Form 7 shortcode with list of Countries
<?php
/*
UPDATED: December 31, 2011.
Modifications:
- Truncated the longest country names, including:
-- British Indian Ocean Territories (Chagos Archipelago) -> British Indian Ocean Territories
-- South Georgia and the South Sandhich Islands -> South Georgia & S. Sandwich Islands
// AUTO-SELECT CLICKFUNNELS PRODUCT ON ORDER PAGE
// --
//
// AUTHOR: Robert Klubenspies (klubenspies.com)
//
// REQUIREMENTS: jQuery
//
// USAGE:
// 1) Find your product's ID numbers by using Web Inspector to find
// the code for your order page's radio buttons. They'll look
@KustomDeveloper
KustomDeveloper / Banner Widget
Last active December 4, 2017 20:03
Wordpress custom widget extending wp-widget class
/**
*
* Banner Widget
* Note* - The WP_Widget class is located in wp-includes/class-wp-widget.php.
*/
class Banner_Widget extends WP_Widget {
/**
* Register Widget With Wordpress
<?
// Add at bottom of functions.php file
//Example with minimum options
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
/**
*
* Recent Posts Widget
* Note* - The WP_Widget class is located in wp-includes/class-wp-widget.php.
*/
//Add Custom Excerpt Length
function excerpt($limit) {
function multiple_sidebars_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'themename' ),
'id' => 'sidebar-1',
'description' => 'Sidebar for all pages',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
@KustomDeveloper
KustomDeveloper / Add media uploader to options page
Last active December 19, 2017 15:42 — forked from blogjunkie/child-theme-settings.php
Integrate the WordPress Media Uploader in Theme Options. Reference this function from your add_meta_box() callback
<?php
function upload_image_metabox() {
echo '<p><strong>Upload image</strong></p>';
echo '<input type="text" id="child_logo_url" name="' . $this->get_field_name( 'welcome-image' ) . '" value="' . esc_attr( $this->get_field_value( 'welcome-image' ) ) . '" size="50" />';
echo '<input id="child_upload_logo_button" type="button" class="button" value="Upload Image" /> ';
?>
<?php
add_action( 'admin_menu', 'wpto_add_admin_menu' );
add_action( 'admin_init', 'wpto_settings_init' );
function wpto_add_admin_menu( ) {
add_options_page( 'Theme Options ', 'Theme Options ', 'manage_options', 'theme_options_', 'wpto_options_page' );
}
@KustomDeveloper
KustomDeveloper / SS Content Ads
Last active January 3, 2018 01:38
Ability to select categories and have ads appear multiple times in single content posts. Different categories will get different ad sets.
<?php
/**
* Plugin Name: SS Content Ads
* Plugin URI: http://kustomdesigner.com/ss-content-ads
* Description: Add ads within single posts by category matching. Also, send a ga.js click event with photo-id for use in split testing ads to see which ones are getting the most response.
* Version: 2.0
* Author: Michael Hicks
* Author URI: http://kustomdesigner.com/
*/
@KustomDeveloper
KustomDeveloper / Update querystring parameters
Last active January 23, 2018 14:26 — forked from niyazpk/pQuery.js
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {