Skip to content

Instantly share code, notes, and snippets.

View PaulHughes01's full-sized avatar

Paul Hughes PaulHughes01

View GitHub Profile
@PaulHughes01
PaulHughes01 / muut-second-forum-page.php
Last active August 29, 2015 14:20
Adding a second forum page to a website
<?php
/**
* muut-second-forum-page.php
*
* Template Name: Muut Second Forum Template
*
* @package Muut
* @copyright 2014 Muut Inc
*/
@PaulHughes01
PaulHughes01 / pr.md
Last active August 29, 2015 14:07 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@PaulHughes01
PaulHughes01 / class-moot.php
Last active August 29, 2015 13:57
Allow Moot to be used for commenting pages not just posts in WordPress.
<?php
// In the WordPress Moot Plugin version 2.0.11
// In the file class-moot.php, replace line 61, which looks like:
if (!is_home() && $forumname != null && get_option('moot_generate') == "true" && get_post_type() == "post") {
// Replace it with THIS:
if (!is_home() && $forumname != null && get_option('moot_generate') == "true" && in_array( get_post_type(), array( 'post', 'page' ) ) ) {
@PaulHughes01
PaulHughes01 / functions.php
Last active December 17, 2015 10:09
To have archive pages exist for venues and organizers in Modern Tribe's The Events Calendar plugin.
<?php
// Insert this into your functions.php file:
add_filter( 'tribe_events_register_venue_type_args', 'my_modification_of_post_type_args', 10, 1 );
add_filter( 'tribe_events_register_organizer_type_args', 'my_modification_of_post_type_args', 10, 1 );
function my_modification_of_post_type_args( $args ) {
$args['has_archive'] = true;
// You could also assign a string to has_archive, which would be the archive slug:
// $args['has_archive'] = 'venues';
@PaulHughes01
PaulHughes01 / functions.php
Last active December 14, 2015 12:08
Venue query ordered by number of events per venue.
<?php
// Add this to your functions.php file to create a venue query that queries venues in order of number of events.
// You may need to add a limit statement if you want more events to be returned than the default for the query.
add_filter( 'pre_get_posts', 'my_function_to_get_venues_by_event_numbers', 10, 1 );
function my_function_to_get_venues_by_event_numbers( $query ) {
$post_type = (array) $query->query_vars['post_type'];
if ( !is_single() && $post_type == array( TribeEvents::VENUE_POST_TYPE) ) {
add_filter( 'posts_fields', 'my_posts_fields_for_venues_function', 20, 1 );
add_filter( 'posts_join', 'my_posts_join_for_venues_function', 20, 1 );
add_filter( 'posts_where', 'my_posts_where_for_venues_function', 20, 1 );
@PaulHughes01
PaulHughes01 / gist:4999758
Last active December 14, 2015 00:38
This is the code you can use to display the proper error messages for Modern Tribe's The Events Calendar add-ons. Instructions included in the comments below.
<?php
/**
* In the root plugin file, where you initialize your class on 'plugins_loaded', run a check
* to see if class TribeEvents exists, if it doesn't, show the error message. This takes
* care of if TEC is not installed. The below code is an example from
* The Events Calendar: Community Events.
*/
///////////////////
// File: the-events-calendar-community-events/tribe-community-events.php
///////////////////
@PaulHughes01
PaulHughes01 / functions.php
Last active December 11, 2015 23:39
Workaround to pass a given currency to Eventbrite when using Modern Tribe's The Events Calendar: Eventbrite Tickets plugin.
<?php
/* PLACE THE FOLLOWING IN YOUR THEME'S FUNCTIONS.PHP FILE. */
add_action( 'tribe_eb_after_event_creation', 'my_change_tribe_eventbrite_currency', 10, 4 );
function my_change_tribe_eventbrite_currency( $eventbrite_id, $venue_id, $organizer_id, $post_id ) {
// See http://www.currencysystem.com/codes/ for a list of three-letter
// currency acronyms. Change the below variable to your preference.
$currency_acro = 'EUR';
@PaulHughes01
PaulHughes01 / gist:3688451
Created September 10, 2012 02:12
New Views/Templating Design Example
<?php
/**
* The abstracted view of a single event.
* This view contains the hooks and filters required to create an effective single event view.
*
* You can recreate and ENTIRELY new single view (that does not utilize these hooks and filters)
* by doing a template override, and placing a single-event.php file in a /tribe-events/ directory within your theme directory, which will override the /views/single-event.php.
*/
?>
@PaulHughes01
PaulHughes01 / gist:3326097
Created August 11, 2012 18:13
TinyMCE for TribeEventsBeforeHTML/After
<?php
// Add the following to your functions.php file.
function tribe_filter_before_html_field( $field ) {
echo '<fieldset id="tribe-field-tribeEventsBeforeHTML" class="tribe-field tribe-field-textarea tribe-size-large">';
echo '<legend class="tribe-field-label">Add HTML before calendar</legend><div class="tribe-field-wrap">';
wp_editor( tribe_get_option('tribeEventsBeforeHTML', ''), 'tribeEventsBeforeHTML', array( 'teeny' => true ) );
echo '</fieldset>';
}
<?php
function tribe_get_month_all_events() {
$events = tribe_get_events( array( 'eventDisplay'=>'month' ) );
foreach ( $events as $event ) {
echo $event->EventStartDate . '<br />';
}
}
add_action( 'wp_head', 'tribe_get_month_events' );