Skip to content

Instantly share code, notes, and snippets.

@bmoredrew
bmoredrew / sort-by-acf-repeater-field.php
Last active May 7, 2022 08:15
Sort Posts by ACF Repeater Field Using Multidimensional Array
<?php
// Create an empty array for storage
$post_data = array();
// Set arguments for your query
$args = array(
'post_type' => 'trips',
'posts_per_page' => 999
);
@bmoredrew
bmoredrew / Arr.php
Created September 6, 2017 21:12
PHP: Array support class and functions
<?php
/**
* Support class for working with arrays.
*/
class Arr
{
/**
* Extend an associative array.
*
@bmoredrew
bmoredrew / jquery-boilerplate.js
Created August 30, 2017 13:38 — forked from tommcfarlin/jquery-boilerplate.js
[WordPress] Properly loading jQuery within WordPress without having to use the `noConflict` method, or creating your own reference such as `$wp = jQuery`.
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
@bmoredrew
bmoredrew / rand-acf-repeater.php
Created June 9, 2017 05:26
Randomly display 3 ACF repeater rows
<?php
$blocks = get_field('menu_blocks');
if( $blocks ) $count = 0;
{
shuffle( $blocks );
foreach( $blocks as $block )
{
@bmoredrew
bmoredrew / acf_get_directions.php
Created August 9, 2016 05:43 — forked from mattradford/acf_get_directions.php
ACF Get Directions map link
<a class="directions" href="https://www.google.com/maps?saddr=My+Location&daddr=<?php $location = get_field('map_location'); echo $location['lat'] . ',' . $location['lng']; ?>"><?php _e('Get Directions','roots'); ?></a>
Drew is a front-end developer, <a href="http://www.baltimoredrew.com/">WordPress developer and entrepreneur from Baltimore, MD</a>. With more than five years of freelance experience and over 15 years of development experience, Drew consults clients around the world about their ecommerce needs. To give back to the community Drew regularly attends and speaks at WordCamp events and helps organize the Baltimore WordPress meetup and WordCamp Baltimore.
@bmoredrew
bmoredrew / trans-xml.php
Created September 22, 2015 20:54
transient api to cache xml data ?
$feed = simplexml_load_file( 'URL' );
foreach ( $feed->channel->item as $item )
{
if( $counter <= $limit )
{
echo '<p>' . esc_html( $item->title ) . '</p>';
echo '<a href="' . esc_attr( $item->link ) . '">Read more &gt;</a>';
$counter++;
}
@bmoredrew
bmoredrew / culinarylocal-events-feed-widget.html
Last active August 29, 2015 14:22
CulinaryLocal Events Feed Widget
<!-- start CulinaryLocal widget code -->
<a href="http://culinarylocal.com"><img src="http://www.culinarylocal.com/public-assets/logo.png" border="-1" alt="Culinary Local Marketplace" /></a><br/>
<script type="text/javascript">document.write('\x3Cscript type="text/javascript" src="' + ('https:' == document.location.protocol ? 'https://' : 'http://') + 'feed.mikle.com/js/rssmikle.js">\x3C/script>');</script><script type="text/javascript">(function() {var params = {rssmikle_url: "http://www.culinarylocal.com/events/feed/",rssmikle_frame_width: "200",rssmikle_frame_height: "350",frame_height_by_article: "0",rssmikle_target: "_blank",rssmikle_font: "Arial, Helvetica, sans-serif",rssmikle_font_size: "12",rssmikle_border: "off",responsive: "off",rssmikle_css_url: "",text_align: "left",text_align2: "left",corner: "on",scrollbar: "on",autoscroll: "on",scrolldirection: "down",scrollstep: "3",mcspeed: "20",sort: "Off",rssmikle_title: "on",rssmikle_title_sentence: "Upcoming Events",rssmikle_title_link: "",rssmikle_tit
<?php
/**
* Custom PayPal Adaptive Payments args.
*
* @param array $args
* @param WC_Order $order
* @return array
*/
function custom_woocommerce_paypal_ap_payment_args( $args, $order ) {
$args['receiverList'] = array(
@bmoredrew
bmoredrew / gist:dcc7d04b23e785f6c0bb
Created April 27, 2015 15:56
Front-end Attendee List WooCommerce WooTickets Events Calendar Plugin
<?php
global $current_user;
get_currentuserinfo();
if (is_user_logged_in() && $current_user->ID == $post->post_author) {
// Build a list of attendees
$attendeeList = TribeEventsTickets::get_event_attendees($event_id);
$customerList = array();