Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / version.php
Created August 28, 2015 16:02
You can use this to verify PHP version info for your server.
<?php
if ( version_compare( PHP_VERSION, '5.0.0', '>=' ) ) {
echo 'I am using PHP 5, my PHP_VERSION: ' . PHP_VERSION;
}
echo '<br>My phpversion(): ' . phpversion();
if ( defined ( 'PHP_VERSION_ID' ) ) {
echo '<br>My PHP_VERSION_ID: ' . PHP_VERSION_ID;
@joshfeck
joshfeck / custom_functions.php
Created February 4, 2014 21:36
Adds an "Add to cart" link onto the single event registration page. Requires Event Espresso and its Multi Event Registration add-on.
<?php
add_action('action_hook_espresso_social_display_buttons', 'single_custom_cart_link');
function single_custom_cart_link($event_id) {
global $wpdb;
$event_name = $wpdb->get_var("SELECT event_name FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'");
?><div class="custom-cart-link" style="display:block;">
@joshfeck
joshfeck / main.php
Last active August 29, 2015 13:56
update the price option correctly
<?php
if (!function_exists('espresso_ticket_information')) {
function espresso_ticket_information($atts) {
global $wpdb;
extract($atts);
$price_option = "{$price_option}";
$type = "{$type}";
@joshfeck
joshfeck / custom_functions.php
Last active August 29, 2015 13:56
use WP the_content() filter to translate a payment type.
<?php
function my_change_check( $content ) {
$content = str_replace( '<td>Check</td>', '<td>Cheque</td>', $content);
return $content;
}
<?php
function espresso_ticket_information($atts) {
global $wpdb;
extract($atts);
$price_option = "{$price_option}";
$type = "{$type}";
switch ($type) {
case 'ticket':
@joshfeck
joshfeck / po_payment_vars.php
Created February 20, 2014 16:37
This gist updates the po_payment_vars.php file found in the Event Espresso 3 PO gateway and adds some simple jQuery validation.
<?php
function espresso_display_purchase_order($payment_data) {
global $org_options;
extract($payment_data);
$default_gateway_version = empty($default_gateway_version) ? '' : $default_gateway_version;
echo '<!-- Event Espresso Purchase Order Gateway Version ' . $default_gateway_version . '-->';
$po_payment_settings = get_option('event_espresso_purchase_order_payment_settings');
<?php
//* Do NOT include the opening php tag
//* Load Lato and Merriweather Google fonts
add_action( 'wp_enqueue_scripts', 'bg_load_google_fonts' );
function bg_load_google_fonts() {
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,700|Merriweather:300,700', array(), CHILD_THEME_VERSION );
}
@joshfeck
joshfeck / custom_functions.php
Created April 1, 2014 17:02
Compatibility fix for servers running PHP5.2. Fixes an issue with exporting an Event Espresso attendee list if using ticketing on a server running PHP 5.2. Upload this file to /wp-content/uploads/espresso/
<?php
class EEDateTime extends DateTime
{
public static function createFromFormat($format, $time, $timezone = null)
{
if(!$timezone) $timezone = new DateTimeZone(date_default_timezone_get());
$version = explode('.', phpversion());
if(((int)$version[0] >= 5 && (int)$version[1] >= 2 && (int)$version[2] > 17)){
return parent::createFromFormat($format, $time, $timezone);
@joshfeck
joshfeck / page-minimal.php
Created April 10, 2014 00:33
This is a simple, minimally-styled, single page template to be used for an Event Espresso payments page template when using an offsite gateway like Authorize.net SIM where adding SSL isn't a viable option. It will not match your WordPress theme, with the exception of Ice Cap, which this template was based on: http://wordpress.org/themes/ice-cap
<?php
/*
Template Name: minimal
*/
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
@joshfeck
joshfeck / ee_add_taxonomy_post_class.php
Last active August 29, 2015 14:00
Adds a class name to the Event Espresso event post's post class so events that belong to a specific category can be uniquely styled with CSS. Requires Event Espresso 4.2.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// Add a class name to the event post's post class that's based on the category it's assigned to
add_filter( 'post_class', 'ee_add_taxonomy_post_class', 10, 3 );
function ee_add_taxonomy_post_class( $classes, $class, $ID ) {
$taxonomy = 'espresso_event_categories';
$terms = get_the_terms( (int) $ID, $taxonomy );