Skip to content

Instantly share code, notes, and snippets.

View fredbradley's full-sized avatar

Fred Bradley fredbradley

View GitHub Profile
if ($_POST['email']) {
$email = $_POST['email'];
$message = "Hello this is a test! It worked!";
mail($email, 'My Subject', $message);
echo 'Mail Should Now Be Sent!';
}
@fredbradley
fredbradley / nextPlayFunction.php
Created April 11, 2013 17:31
Can anyone spot any errors with the code below? I need it to display an output that matches with this document from the client (see screenshot here: https://twitter.com/fredbradley/status/322399388146216961/photo/1 )
<?php
/*
* FOR THE PHP GEEKS!
------------------
Can anyone spot any errors with the code below?
I need it to display an output that matches with this document from the client (see screenshot here: https://twitter.com/fredbradley/status/322399388146216961/photo/1 )
@fredbradley
fredbradley / Need some help with Wordpress Custom Tax Query and Group Taxomonies
Created October 6, 2013 14:09
I need to create a page that shows all the posts that are tagged with "video". It's not working like I expect. It's only showing the normal blog posts - not the other custom post types that are also tagged with 'video'. Below is the code that I've got. For reference the function get_bonn_post_types is an array of all the post types on my install…
<?php
/*
Hello!
This has been bugging me for the best part of a day now, so I'm appealing to help in order to calm my nerves.
I run a site that has many custom post types. Every post type shares the use of the post_tag taxonomy.
I need to create a page that shows all the posts that are tagged with "video". It's not working like I expect. It's only showing the normal blog posts - not the other custom post types that are also tagged with 'video'.
@fredbradley
fredbradley / SRAMail
Created November 22, 2013 21:27
Proposed New SRA Mailing Design
<div class="no-format" id="header">
<div class="text-center">
<p>BLAH BLAH BLAH</p>
</div>
</div>
<div class="container" id="emailWrapper">
<div class="row" id="header">
<div class="col-md-5">
SRA LOGO
</div>
<html>
<head>
<style>
/**
* Update: July 2020
* I have converted this into it's own separate project now: https://github.com/fredbradley/tfl-colours
*/
</head>
<body>
<!-- Here is an example of how the above styles can be implmented!
@fredbradley
fredbradley / Display Latest Tweet
Last active August 29, 2015 13:56
Copy this script and put it right at the bottom of your index.html file. Ensure that somewhere in your template there is a div that looks like this: <div id="emapTweet"></div>
p.interact a {
background:url("twitter-sprite.png"); /* Obviously make sure that twitter-sprite.png is included in your template! */
display: inline-block;
height: 20px;
width: 20px;
text-indent: -9999px;
}
p.interact a.twitter_reply_icon,
p.interact a.twitter_retweet_icon,
p.interact a.twitter_fav_icon {
<?
/**
* Some custom code written by Fred that will pull in all the photos in given photosets
*/
// First we Add some custom styles! Not ideal, and not compliant but quick and easy! ?>
<style>
ul.flickr-photos,
ul.flickr-photos li {
list-style:none;
<?php
/**
* Update Custom Terms
*
* @author Fred Bradley <@fredbradley>
* @version 1.0
* @since Since Release 1.0.0
*/
function update_station_tag_list($post_id) {
@fredbradley
fredbradley / youtube_id_from_url
Created February 17, 2015 17:18
A useful PHP function that uses regex to get the YouTube video ID from however your user decided to copy the YouTube Link!
<?php
/**
* get youtube video ID from URL
*
* @param string $url
* @return string Youtube video id or FALSE if none found.
*/
function youtube_id_from_url($url) {
$pattern =
'%^# Match any youtube URL
@fredbradley
fredbradley / fb_format_twitter_handle
Last active August 29, 2015 14:18
Useful Wordpress filter snippet for automatically finding Twitter handles in your content and formatting them as a link with Twitter Web Intents and Fontawesome icons
<?php
/**
* How this works: While writing content in the Wordpress editor. Simply add a twitter handle without a link but with the @ symbol.
* EG: "Here is some content written by @FredBradley" would turn into "Here is some content written by <i class="fa fa-fw fa-twitter"></i><a href="https://twitter.com/intent/user/?screen_name=@FredBradley">@FredBradley</a>"
*
* Notes: For this snippet to work 100% as intended it requires two things.
* 1. You need to have Font Awesome working on your site. (http://fontawesome.io/)
* 2. You need to have called the Twitter Widgets.js javascript for Web Intents to work. More details here: https://dev.twitter.com/web/intents#user-intent
*
* How to implement: Simply add this snippet into your theme's functions.php file!