Skip to content

Instantly share code, notes, and snippets.

Avatar

Drew Poland bmoredrew

View GitHub Profile
@bmoredrew
bmoredrew / jquery-boilerplate.js
Created Aug 30, 2017 — 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`.
View jquery-boilerplate.js
/**
* 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 Jun 9, 2017
Randomly display 3 ACF repeater rows
View rand-acf-repeater.php
<?php
$blocks = get_field('menu_blocks');
if( $blocks ) $count = 0;
{
shuffle( $blocks );
foreach( $blocks as $block )
{
View acf_get_directions.php
<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>
View gist:b9538c1e10b80cb8982f
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 Sep 22, 2015
transient api to cache xml data ?
View trans-xml.php
$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 Aug 29, 2015
CulinaryLocal Events Feed Widget
View culinarylocal-events-feed-widget.html
<!-- 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
View functions.php
<?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 Apr 27, 2015
Front-end Attendee List WooCommerce WooTickets Events Calendar Plugin
View gist:dcc7d04b23e785f6c0bb
<?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();
@bmoredrew
bmoredrew / gist:c32ef178f138c8335ca2
Created Mar 3, 2015
Add service fee to woo cart per item
View gist:c32ef178f138c8335ca2
add_action( 'woocommerce_cart_calculate_fees', 'df_add_handling_fee' );
function df_add_handling_fee( $cart_object ) {
global $woocommerce;
// $specialfeecat = 3711; // category id for the special fee
$spfee = 0.00; // initialize special fee
$spfeeperprod = 2.50; //special fee per product
//Getting Cart Contents.
$cart = $woocommerce->cart->get_cart();
@bmoredrew
bmoredrew / gist:5bfd80f87ccf24b8358d
Created Feb 2, 2015
GoDaddy WordPress htaccess 404 Permalinks Fix
View gist:5bfd80f87ccf24b8358d
# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>