Skip to content

Instantly share code, notes, and snippets.

View dongilbert's full-sized avatar
😍
Mautic WOOOO

Don Gilbert dongilbert

😍
Mautic WOOOO
View GitHub Profile
@dongilbert
dongilbert / WPAssetLoader.php
Created April 22, 2011 13:23
Helper function for registering and enqueueing CSS and JavaScript files within a WordPress plugin or theme.
/**
* Helper function for registering and loading scripts and styles.
* Uses regex to determine if the file is CSS or JavaScript and calls
* the proper WordPress register and enqueue functions accordingly.
*
* @name ID to register with WordPress
* @file_path Path to actual file, relative to your plugin or theme, without preceding slash.
* @for Whether this is for a plugin or a theme.
*/
function load_file($name, $file_path, $for = 'plugin') {
@dongilbert
dongilbert / wp-shell-install.sh
Created May 2, 2011 15:27
Auto Install Latest WordPress from Shell
#!/bin/bash
# Install script for Latest WordPress by Johnathan Williamson - extended by Don Gilbert
# Disclaimer: It might not bloody work
# Disclaimer 2: I'm not responsible for any screwups ... :)
# DB Variables
echo "MySQL Host:"
read mysqlhost
export mysqlhost
@dongilbert
dongilbert / create_file_hashes.php
Last active October 2, 2015 09:18
This script outputs an array of file hashes recursively for the current directory. Useful for generating hashlist for security scanning programs.
<?php
/**
* This script outputs an array of file hashes recursively for the current directory.
* Useful for generating hashlist for security scanning programs
*
*/
function recursive_md5($dir, $types = null, $recursive = true, $baseDir = '')
{
$to_ignore = array(
'.',
@dongilbert
dongilbert / sms-alerts.php
Created April 18, 2012 14:15
Send SMS Alerts via PHP
<?php
// Get the POST data, if you are sending SMS as a response to a form.
$form = $_POST['form'];
// Insert your message here. Pull some results from $form or do whatever.
$message = 'Message Here.';
$subject = 'Whatever';
$to = array(
'Sprint' => 'phonenumber@messaging.sprintpcs.com',
@dongilbert
dongilbert / geolocate.php
Created April 19, 2012 17:00
Geolocate an Address Using Google Maps via PHP
<?php
// URL Encode the address
$address = urlencode($data['storelocator']['address']);
// Get the JSON response from google. You can also get XML by changing geocode/json to geocode/xml
$geo = file_get_contents('http://maps.google.com/maps/api/geocode/json?sensor=false&address='.$address);
// Decode the results into an Object
$result = json_decode($geo);
@dongilbert
dongilbert / cycle-base.js
Created April 24, 2012 15:05
jQuery Cycle Base Container
/*
* This is a base container for
* whenever I use jQuery Cycle.
* http://jquery.malsup.com/cycle/
*
* Use this as base HTML
*
* <div id="slider">
* <div id="slides">
* <div class="slide" style="display:block">...</div>
@dongilbert
dongilbert / git-wordpress.txt
Created April 27, 2012 14:27
Use Git with WordPress Plugin Development
=== Using Git with WordPress Plugin Development ===
git svn clone -s -r<rev-number> https://svn.wp-plugins.org/<plugin-path> <-- Clone the plugin repo
cd <plugin-path> <-- change to directory
git svn fetch <-- Pull svn history
git remote add -f github git@github.com:<github-url> <-- add github remote
/* ADD CODE */ <-- write code
git add * <-- add to git
git commit -m "Starting to code" <-- commit changes
git svn dcommit <-- push to svn
git push -f github <-- push to github
@dongilbert
dongilbert / jconfirm.js
Created April 27, 2012 16:55
Joomla Request Confirmation Before Closing
/*
* This goes at the top of your plugin edit view,
* and will ask for confirmation before you leave.
* Be sure to replace viewname with your controller
* name, shortened. If you follow 2.5 guidelines
* with sub controllers that handel specific parts
* of the application, then this will work fine.
*/
Joomla.submitbutton = function(task) {
@dongilbert
dongilbert / remove_old_postmeta.sql
Created May 3, 2012 17:07
This SQL will delete postmeta that's still around from deleted posts.
-- Old Post Meta sometimes creeps
-- in from manually deleting revisions
-- and other things direct from the
-- database. Using this SQL below
-- you can remove the postmeta remnants
-- that have been left behind.
DELETE a
FROM wp_postmeta AS a
LEFT JOIN wp_posts AS b
@dongilbert
dongilbert / option_tree_helper.php
Created May 7, 2012 14:10
Helper functions for WP Option Tree
<?php
/**
* Paste this code in your theme's functions.php
* file and wherever you normally would call
* `get_option_tree('option-name');`, use
* `get_theme_option('option-name');` instead.
* This will pass through the already retrieved
* global $option_tree (called when your theme loads)
* and save you from several additional database
* calls on a single page request.