Skip to content

Instantly share code, notes, and snippets.

View sheabunge's full-sized avatar
😴

Shea Bunge sheabunge

😴
View GitHub Profile
<?php
const ACTION_NAME = 'shea_ajax_example';
$handler = function () {
check_ajax_referer( ACTION_NAME );
wp_send_json_success( 'it works!' );
};
@sheabunge
sheabunge / autoload.php
Last active June 27, 2023 03:35
Basic PHP class autoloader that follows the WordPress coding standards for class names and class filenames
<?php
namespace Shea\Example_Plugin;
/**
* Enable autoloading of plugin classes in namespace.
*
* @param $class_name
*/
function autoload( $class_name ) {
@sheabunge
sheabunge / google-search-form.html
Created October 1, 2012 09:58
Add a Google Search form to your website
<!--
See: http://bungeshea.com/easy-google-search-form/
Remember to replace 'example.com' with the domain of your site.
-->
<form action="http://www.google.com/search" method="get">
<input type="hidden" name="q" value="site:http://example.com">
<input type="text" name="q" alt="search">
<input type="submit" value="Search">
</form>
@sheabunge
sheabunge / wp-loop.php
Last active March 18, 2020 08:45
WordPress loop generator function, as described at https://wpscholar.com/blog/creating-better-wordpress-loop/
<?php
/**
* Simplifies the WordPress loop.
*
* @param WP_Query|WP_Post[] $iterable
*
* @return Generator
*/
function wp_loop( $iterable = null ) {
@sheabunge
sheabunge / explainxkcd.js
Created July 19, 2013 23:08
Explain xkcd bookmarklet
javascript:location.href='http://www.explainxkcd.com/wiki/index.php?title='+window.location.pathname.replace(/^\/|\/$/g, '')
@sheabunge
sheabunge / shortcode-exists.php
Last active June 28, 2017 04:29 — forked from r-a-y/shortcode.php
Check if a shortcode exists in WordPress
<?php
if ( ! function_exists( 'shortcode_exists' ) ) :
/**
* Check if a shortcode is registered in WordPress.
*
* Examples: shortcode_exists( 'caption' ) - will return true.
* shortcode_exists( 'blah' ) - will return false.
*
* @param string $shortcode The name of the shortcode to check
@sheabunge
sheabunge / flashget.sh
Created September 29, 2016 12:55
Shell script for retrieving flash videos from Linux cache. Tested on Ubuntu.
#!/usr/bin/env bash
pids=$(ps ax | grep -iE 'chrome|firefox|vivaldi' | grep -i flash | awk '{ print $1 }')
for pid in $pids
do
file -L /proc/$pid/fd/* | grep -iE 'video|media|mp4|flash' | cut -f 1 -d ':'
done
@sheabunge
sheabunge / oembed-in-comments.php
Created July 17, 2013 08:18
Allows the use of oEmbed in WordPress comments
<?php
/**
* Plugin Name: oEmbed in Comments
* Description: Allow oEmbeds in comment text. A fork of http://wordpress.org/plugins/oembed-in-comments/
* Version: 1.2
* Author: Evan Solomon, modified by Shea Bunge
*/
class oEmbed_Comments {
@sheabunge
sheabunge / flashget
Last active March 19, 2016 06:44
Bash script for retrieving flash videos from Firefox/Chrome cache
#!/usr/bin/env bash
for process in chrome firefox
do
pid=$(ps ax | grep -i $process | grep -i flash | cut -f 1 -d ' ')
file -L /proc/$pid/fd/* | grep -iE 'video|media|mp4|flash' | cut -f 1 -d ':'
done
@sheabunge
sheabunge / Getting Started with Drupal and Drush.md
Last active January 25, 2016 12:21
Getting Started with Drupal and Drush

Getting Started with Drupal and Drush

As part of participating in Google Code-In this year, I am introducing myself to Drupal, as an excersise to see how it works and what it offers as an alternative to WordPress for building content managed websites. As part of this process, I am learning how to install Drupal on an Ubuntu-powered web server running nginx and PHP 7.

To make installing and managing Drupal much easier, we will be shell interface for Drupal known as Drush. Drush is an incredibly useful tool, allowing you to perform a number of various tasks from the command line as a faster and more efficient alternative to using the graphical web based administration.

Setting up the server

First step is to install a web server for Drupal to run on. The first component of this is nginx, a fast and effecient server which can integrate with PHP. It is avaliable in the default Ubuntu repostories and can be installed like so:

sudo apt install nginx