Skip to content

Instantly share code, notes, and snippets.

View gist:1684757
add_role('school_admin', 'School Administrator', array(
'read' => true,
'edit_school' => true,
'edit_pages' => true,
'edit_posts' => true)
);
@MZAWeb
MZAWeb / gist:2131168
Created Mar 20, 2012
XML-RPC Wrapper
View gist:2131168
<?php
if (!class_exists("MZAXMLRPC")){
abstract class MZAXMLRPC {
protected $calls = Array();
protected $namespace = "myxmlrpc";
function __construct($namespace){
@MZAWeb
MZAWeb / gist:3194851
Created Jul 28, 2012
Exclusive search for p2p
View gist:3194851
<?php
add_action( 'pre_get_posts', 'query_for_recipe_search' );
function query_for_recipe_search( $query ) {
if ( is_recipe_search() && is_main_query() ) {
$ingredients = isset( $_GET["search_ingredients"] ) ? $_GET["search_ingredients"] : NULL;
if ( is_array( $ingredients ) ) {
global $wpdb;
@MZAWeb
MZAWeb / gist:3229799
Created Aug 1, 2012
The Events Calendar: maybeAddEventTitle
View gist:3229799
<?php
public function maybeAddEventTitle( $title, $sep = NULL ) {
if ( get_query_var( 'eventDisplay' ) == 'upcoming' ) {
$new_title = apply_filters( 'tribe_upcoming_events_title', __( "Upcoming Events", 'tribe-events-calendar' ) . ' ' . $sep . ' ' . $title, $sep );
} elseif ( get_query_var( 'eventDisplay' ) == 'past' ) {
$new_title = apply_filters( 'tribe_past_events_title', __( "Past Events", 'tribe-events-calendar' ) . ' ' . $sep . ' ' . $title, $sep );
} elseif ( get_query_var( 'eventDisplay' ) == 'month' ) {
if ( get_query_var( 'eventDate' ) ) {
$title_date = date_i18n( "F, Y", strtotime( get_query_var( 'eventDate' ) ) );
@MZAWeb
MZAWeb / gist:3229874
Created Aug 1, 2012
The Events Calendar: Change calendar HTML title
View gist:3229874
<?php
/*
* Parameters:
* $title: the original title (ie: Events for July, 2012)
* $separator: I believe it will be always null for this filter
* $date: The selected month in string format (ie: July, 2012)
*/
function richard_modify_calendar_title( $title, $separator, $date ) {
$new_title = 'Here goes your custom title for the date: ' . $date;
@MZAWeb
MZAWeb / gist:3232646
Created Aug 2, 2012
my_tribe_meta_event_cats (list without link)
View gist:3232646
<?php
function my_tribe_meta_event_cats() {
$tribe_ecp = TribeEvents::instance();
$terms = get_the_terms( get_the_ID(), $tribe_ecp->get_event_taxonomy() );
if ( $terms ) {
$term_names = wp_list_pluck( $terms, 'name' );
$label = "Category";
if ( count( $term_names ) > 1 ) {
@MZAWeb
MZAWeb / gist:3415684
Created Aug 21, 2012
Hide events cat from the front end
View gist:3415684
<?php
add_filter( 'parse_tribe_event_query', 'hide_my_private_category', 999 );
function hide_my_private_category( $query ) {
/*
* First we create the tax_query for excluding
* all the events that have the term 'hidden'.
* Change that 'hidden' for the slug of the term
* you want to hide from the Front End.
@MZAWeb
MZAWeb / gist:3476084
Created Aug 26, 2012
INCLUDE ALL THE STRINGS!
View gist:3476084
#if HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
@MZAWeb
MZAWeb / gist:3483555
Created Aug 26, 2012
array_intersect_assoc
View gist:3483555
<?php
function my_array_compare( $val1, $val2 ) {
return ( $val1["parent_entry_id"] == $val2["parent_entry_id"] );
}
$first = array( array( "parent_entry_id" => 123 ), array( "parent_entry_id" => 987 ), );
$second = array( array( "parent_entry_id" => 123 ),
View gist:3483773
<?php
$expert_parents = array( array( "parent_entry_id" => "1758" ), array( "parent_entry_id" => "151" ), );
$topic_parents = array( array( "parent_entry_id" => "151" ),
array( "parent_entry_id" => "1815" ),
array( "parent_entry_id" => "2548" ),
array( "parent_entry_id" => "2550" ), );
function find_matches( $val1, $val2 ) {
return ( intval( $val1["parent_entry_id"] ) - intval( $val2["parent_entry_id"] ) );