Skip to content

Instantly share code, notes, and snippets.

@trevorgreenleaf
trevorgreenleaf / gist:6355369
Created August 27, 2013 15:51
Create Random bg color in php
// Create Random bg color in php
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$color = '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
echo '<style> body { background-color:'.$color.'}</style>';
@trevorgreenleaf
trevorgreenleaf / gist:6378510
Created August 29, 2013 14:05
Do shortcodes like this
echo do_shortcode( '[foo]' ); // Boo
echo foo_shortcode_callback(); // Yey!
@trevorgreenleaf
trevorgreenleaf / WP: Custom page for a given Url
Last active December 22, 2015 02:58
Allows you to use a custom page for a given Url. With out having to setup a page and template in wp
function page_custom() {
if($_SERVER['REQUEST_URI'] == '/register'){
// path to the file
include(get_template_directory().'/users/register.php');
}
}
add_action('template_redirect', 'page_custom');
@trevorgreenleaf
trevorgreenleaf / gist:7711464
Created November 29, 2013 20:26
Switching PHP from mac to MAMP's PHP
Go to Terminal
Enter " which php "
If it says /usr/bin/php, then proceed to 3.
Enter sudo nano ~/.bash_profile (or sudo vim ~/.bash_profile if you know how to use it)
then paste this export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"
ctrl - O then enter to save, then ctrl - X to exit.
restart terminal.
Enter which php
http://stackoverflow.com/questions/16830405/laravel-requires-the-mcrypt-php-extension
@trevorgreenleaf
trevorgreenleaf / gist:8513341
Created January 20, 2014 01:14
Installing Laravel on Media Temple GS
Go into domain folder
transfer or run a new install of laravel
git clone https://github.com/laravel/laravel example.com && cd example.com
// get composer
curl -sS https://getcomposer.org/installer | php -d allow_url_fopen=On
// install composer
php -d allow_url_fopen=On composer.phar install
<snippet>
<content><![CDATA[
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${1:New Project Title}</title>
@trevorgreenleaf
trevorgreenleaf / Products Page
Created October 2, 2014 02:31
Products Page
<?php get_header();
/*
Template Name: Product Page
*/
?>
<div class="col-xs-12">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
if( current_user_can('administrator')){
// show something to admins only
}
?>
@trevorgreenleaf
trevorgreenleaf / gist:3b0a00990e8866683e65
Created November 4, 2014 04:40
Using categories with the wp loop the manual way
<?php get_header();
/*
Template Name: Cats Grid Page
*/
?>
<p>Show the cats grid</p>
<div class="well"><ul>
<?php
@trevorgreenleaf
trevorgreenleaf / Basic CSS Btn Hover
Created November 25, 2014 03:37
Basic CSS Btn Hover
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Btn Hovers</title>
<style>
a.btn {
width:200px;
height: 200px;