Skip to content

Instantly share code, notes, and snippets.

View afragen's full-sized avatar

Andy Fragen afragen

View GitHub Profile
@afragen
afragen / iOS.css
Created September 21, 2012 16:41
The Events Calendar: iOS CSS media queries
/* iPad [portrait + landscape] and iPhone [portrait + landscape] */
@media only screen and (min-device-width: 320px) and (max-device-width: 1024px) {
/* code here */
}
/* iPad [portrait + landscape] */
@media only screen and (device-width: 768px) {
/* code here */
}
@afragen
afragen / iPhone.css
Created September 21, 2012 17:46
The Events Calendar: iPhone CSS
/* iPhone [portrait + landscape] */
@media only screen and (max-device-width: 480px) {
body { min-width: 550px; }
.tribe-events-thismonth, .tribe-events-othermonth { min-width: 50px; max-width:60px; }
#tribe-events-calendar-header { padding-top: 3em; }
.tribe-events-calendar-buttons { top:0; left:0; }
.tribe-events-calendar-widget td a.tribe-events-mini-has-event { cursor: pointer; }
}
@afragen
afragen / user_meta.php
Last active October 13, 2015 04:08
get custom user meta for email users plugin
<?php
add_action( admin_head, 'return_meta' );
function return_meta() {
get_user_meta_field_data ( 'drmc-department' );
get_user_meta_field_data ( 'drmc-department', 'er' );
}
function get_users_by_meta_data( $meta_key, $meta_value ) {
// Query for users based on the meta data
@afragen
afragen / http-api-debug.php
Created November 21, 2015 01:06
Debug HTTP API calls in WordPress
<?php
add_action( 'http_api_debug', 'viper_http_api_debug', 15, 5 );
function viper_http_api_debug( $response, $type, $class, $args, $url ) {
// You can change this from error_log() to var_dump() but it can break AJAX requests
var_dump( "\n<br />" . 'Request URL: ' . var_export( $url, true ) );
var_dump( "\n<br />" . 'Request Args: ' . var_export( $args, true ) );
var_dump( "\n<br />" . 'Request Response : ' . var_export( $response, true ) );
}
@afragen
afragen / remove_tribe_cat_once.php
Created December 18, 2012 01:09
The Events Calendar Category Colors: place this code in your theme's functions.php file if you see the calendar taking on the styling of the first event of the month. If it causes problems. Don't use it.
// Try to stop the first event category from being added to the article classes
// (when the default page template is used) - Thanks Barry
add_filter('post_class', 'remove_tribe_cat_once', 1);
function remove_tribe_cat_once(array $classes) {
if ( class_exists('TribeEvents') ) {
// The Main Calendar Page or Calendar Category Page
if (( tribe_is_month() && !is_tax() ) || ( tribe_is_month() && is_tax() )) {
static $count = 0;
if ($count++ === 0) {
@afragen
afragen / get_template_name.php
Created December 18, 2012 03:36
Add this to your theme's functions.php file. It will display the name of your Events Calendar template file.
add_action( 'wp_head', 'template_name' );
function template_name() {
if ( class_exists( 'TribeEvents' ) ) {
if ( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
$template = TribeEvents::getOption('tribeEventsTemplate');
print_r( $template );
}
}
}
@afragen
afragen / tooltip.php
Created December 10, 2015 00:06
An override template for ECP 4.0 week view tooltip display. It will strip HTML from the tooltip.
<?php
// Place in {your-theme}/tribe-events/pro/week/tooltip.php
/**
*
* Please see single-event.php in this directory for detailed instructions on how to use and modify these templates.
*
*/
@afragen
afragen / tribe-subscribe-gcal-ical.php
Last active December 11, 2015 11:08
Subscribe in Google Calendar/iCal. Place this code in your ecp-page-template.php file or whatever your template is.
<?php
if ( function_exists( 'tribe_get_ical_link' ) ) {
$calurl = tribe_get_ical_link();
$icalurl = preg_replace('(https?://)', 'webcal://', $calurl );
$gcalurl = 'https://www.google.com/calendar/render?cid=' . $calurl ;
}
?>
<a href="<?php echo $icalurl; ?>" title="Subscribe to this calendar using your favorite calendar program (iCal, Outlook, etc.)" class="ical">iCal Subscribe</a>
<a href="<?php echo $gcalurl; ?>" title="Subscribe to this calendar in your Google Calendar" class="gcal-add" target="_blank">Subscribe in Google Calendar</a>
@afragen
afragen / iOS-aspect-ratio.css
Created May 21, 2013 23:45
iOS media queries - device aspect ratio
/*Another useful media feature is device-aspect-ratio.*/
/*Note that the iPhone 5 does not have a 16:9 aspect ratio. It is in fact 40:71.*/
/*iPhone < 5:*/
@media screen and (device-aspect-ratio: 2/3) {}
/*iPhone 5:*/
@media screen and (device-aspect-ratio: 40/71) {}
@afragen
afragen / my-custom-titles.php
Created May 24, 2013 03:20
Change the title 'Calendar of Events' to your custom title.
<?php
add_filter('tribe_get_events_title','my_custom_titles');
function my_custom_titles($title) {
if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
return 'JazzSchool Events';
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
return 'JazzSchool Events' . ' &raquo; ' . single_term_title('', false);
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List