Skip to content

Instantly share code, notes, and snippets.

View afragen's full-sized avatar

Andy Fragen afragen

View GitHub Profile
@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 / 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 / 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 / iCal-Invite-Fix.applescript
Last active August 15, 2020 12:12
Script for automatically extracting calendar items from meeting requests in Mail.app and adding them into iCal. It will always extract into the first local calendar.
(*
Script for automatically extracting calendar items from meeting requests
and adding them into iCal. It will always extract into the first local calendar.
written by Andy Fragen <andy@thefragens.com>
modified to run from AppleScript menu
http://www.macosxhints.com/article.php?story=20060821073102694
http://bbs.macscripter.net/viewtopic.php?id=17655
@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 / new-user-approve-delete-deny.php
Last active January 11, 2016 05:19
Uses the hook new_user_approve_user_denied in the New User Approve WP plugin to delete denied users.
<?php
/*
Plugin Name: New User Approve - Delete Deny
GitHub Plugin URI: https://gist.github.com/afragen/5624319
Description: This plugin hooks into 'new_user_approve_user_denied' to delete the denied new user.
Requires at least: 3.1
Tested up to: 3.6.1
Version: 1.0.1
Author: Andy Fragen
@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
@afragen
afragen / current_ip.sh
Created June 17, 2013 18:17
I run this script using an ssh key to create a file with the current IP of my machine. Change user@host.com to a user with ssh key pair on your machine. I then access this file from my server.
#!/usr/bin/env bash
# This script should only generate an email when the WAN IP has changed.
# run in launchd
#test for any parameter, true if debugging
test -n "$1" && dbg=$1 || dbg=false #;dbg=true
echo "Running $0"
my_ip=`curl -s http://checkip.dyndns.org | awk '{print $6}' | awk ' BEGIN { FS = "<" } { print $1 } '`
@afragen
afragen / mount.sh
Created June 17, 2013 18:26
Call in launchd plist to run at user login to automatically mount a disk. Example usage iTunes Library stored on NAS.
#!/usr/bin/env bash
# call with `mount.sh true` for debug messages
version="1.0"
dbg=false
home_vols=( "/Volumes/iTunes" "/Volumes/Drobo" ) # order is important
webdav_vols=( "/Volumes/user1" "/Volumes/user2" "/Volumes/user3" )
home_router_mac="mac-address-here"
# how to grab drobo_ip based upon drobo mac address using `netstat -rnf inet`
drobo_mac="mac-address-here"