Skip to content

Instantly share code, notes, and snippets.

View jo-snips's full-sized avatar

Jonah West jo-snips

View GitHub Profile
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
<?php
//Add to your theme's functions.php
add_filter( 'tribe_ical_feed_item', 'tribe_ical_modify_event', 10, 2 );
function tribe_ical_modify_event( $item, $eventPost ) {
$searchValue = "DESCRIPTION";
$fl_array = preg_grep('/^' . "$searchValue" . '.*/', $item);
$key = array_values($fl_array);
$keynum = key($fl_array);
<?php
// use this method to replace the orininal in v1.0.5 (line 273 in the-events-calendar-facebook-importer.php)
function get_facebook_photo( $object_id ) {
$api_url = $this->build_url_with_access_token( $object_id . '/', array( 'fields' => 'cover', 'return_ssl_resources' => 1 ) );
$api_request = $this->json_retrieve( $api_url );
$new_path = $api_request->cover->source;
$get_photo = wp_remote_get( $api_request->cover->source );
// setup return object
$photo['url'] = $new_path;
<?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 );
</php
/**
* Facebook Page Feed Parser
*
* @using cURL
*/
function fb_parse_feed( $page_id, $no = 5 ) {
// URL to the Facebook page's RSS feed.
<?php
/**
* Loop Add to Cart
*/
global $product;
if( $product->get_price() === '' && $product->product_type != 'external' ) return;
?>
<?php
/*
Template Name: Stock Report :)
*/
if (!is_user_logged_in() || !current_user_can('manage_options')) wp_die('This page is private.');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
// use this method to replace the orininal in v1.0.5 (line 273 in the-events-calendar-facebook-importer.php)
function get_facebook_photo( $object_id ) {
$api_url = $this->build_url_with_access_token( $object_id . '/', array( 'fields' => 'cover', 'return_ssl_resources' => 1 ) );
$api_request = $this->json_retrieve( $api_url );
$new_path = $api_request->cover->source;
$get_photo = wp_remote_get( $api_request->cover->source );
// setup return object
$photo['url'] = $new_path;
<?php
add_action( 'init', 'tribe_events_wootheme_compatibility' );
function tribe_events_wootheme_compatibility() {
if ( ! is_home() ) {
remove_filter( 'pre_get_posts', 'woo_exclude_categories_homepage', 10 );
}
}