Skip to content

Instantly share code, notes, and snippets.

View micjamking's full-sized avatar
🏝️
Working remote

Mike King micjamking

🏝️
Working remote
View GitHub Profile
@micjamking
micjamking / send_email.php
Created May 3, 2016 04:09
PHP - Basic Form
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "you@yourdomain.com";
$email_subject = "Your email subject line";
function died($error) {
@micjamking
micjamking / wp-permissions.sh
Created December 28, 2015 22:04
Set WordPress permissions for localhost installations
#!/bin/bash
# Set WordPress permissions for localhost installations
# @param {string} $1 - directory to apply permission settings
# @example - $ wp_permissions wordpress/
function wp_permissions() {
sudo chown -R :_www "$1" && sudo chmod -R g+w "$1"
}
@micjamking
micjamking / foundation-menu.php
Created November 30, 2015 23:18
WordPress Navigation Menu Customizations for Foundation Top Bar
<?php
/**
* Add a parent class for menu item
*/
function add_menu_parent_class( $items ) {
$parents = array();
foreach ( $items as $item ) {
if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
@micjamking
micjamking / functions.php
Last active September 12, 2015 00:46
Custom directory location for custom post type templates
<?php
// Selects Custom Post Type Templates for single and archive pages
// ----------------------------------------------------------------------
add_filter('template_include', 'custom_template_include');
function custom_template_include($template) {
$custom_template_location = get_stylesheet_directory() . '/my-inc/my-templates/';
if ( get_post_type () ) {
if ( is_archive() ) :
if( file_exists( $custom_template_location . 'archive-' . get_post_type() . '.php' ))
return $custom_template_location . 'archive-' . get_post_type() . '.php';
/**
* Copyright (c) 2015 Matthew Zipay <mattz@ninthtest.net>. All rights reserved.
* Licensed under the MIT License <http://opensource.org/licenses/MIT>.
*
* The problem:
* You need to make a cross-domain request for JSON data, but the remote
* server doesn't send the necessary CORS headers, and it only supports
* simple JSON-over-HTTP GET requests (no JSONP support).
*
* One possible solution:
@micjamking
micjamking / README.md
Last active August 29, 2015 14:16
2015 Computer Setup for Front end Development (OSX)
@micjamking
micjamking / README.md
Last active August 29, 2015 14:15
[JavaScript] AngularJS README Template

Project Name

Requirements

Install

$ git clone git@github.com:user/project.git
$ cd project
@micjamking
micjamking / .bash_profile
Last active August 29, 2015 14:13
[Command Line] Configuration files
source ~/.profile
@micjamking
micjamking / .htaccess
Last active August 29, 2015 14:06
[Apache] 301 Redirects
# Redirect individual files
Redirect 301 /oldfile.html /newfile.html