Skip to content

Instantly share code, notes, and snippets.

View EvanHerman's full-sized avatar
🐈
Cats, Code, WordPress

Evan Herman EvanHerman

🐈
Cats, Code, WordPress
View GitHub Profile
@EvanHerman
EvanHerman / timeline-express-image-icons.php
Last active February 25, 2018 14:28 — forked from petenelson/timeline-express-filter-test.php
Timeline Express - Add an additional image field to use in place of the icon on the timeline.
/*
* Timeline Express - Image Icons
*
* Note: Requires Timeline Express v1.2 or later.
* The following code should be placed in the bottom of your active themes functions.php file.
*/
add_filter( 'timeline-express-custom-icon-html', 'pn_timeline_express_custom_icon_html_test', 10, 3 );
function pn_timeline_express_custom_icon_html_test( $html, $post_id, $timeline_express_options ) {
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
@EvanHerman
EvanHerman / gist:ba29e4941be52042ef57
Last active May 17, 2016 21:51
Use the announcement image as the icon - Props Pete Nelson
/*
* Timeline Express Custom Icon Filter Test
* Note: Requires Timeline Express v1.2 or later.
* The following code should be placed in the bottom of your active themes functions.php file.
*/
add_filter( 'timeline-express-custom-icon-html', 'pn_timeline_express_custom_icon_html_test', 10, 3 );
function pn_timeline_express_custom_icon_html_test( $html, $post_id, $timeline_express_options ) {
$custom_png_icon = get_post_meta( $post_id, '_custom_png_icon', true );
@EvanHerman
EvanHerman / check-if-element-in-viewport-on-scroll.js
Last active May 31, 2023 13:23
Check when an element comes into view (jQuery)
function isOnScreen(elem) {
// if the element doesn't exist, abort
if( elem.length == 0 ) {
return;
}
var $window = jQuery(window)
var viewport_top = $window.scrollTop()
var viewport_height = $window.height()
var viewport_bottom = viewport_top + viewport_height
var $elem = jQuery(elem)
@EvanHerman
EvanHerman / woocommerce_products_free_shipping.php
Last active October 3, 2015 14:59
Exclude shipping costs from certain products (by product ID )
<?php
function yikes_woocommerce_free_shipping( $is_available ) {
global $woocommerce;
// set the product ids that are eligible
$eligible = array( '360' );
// get cart contents
$cart_items = $woocommerce->cart->get_cart();
@EvanHerman
EvanHerman / yikes-mailchimp-redirect-url-example.php
Last active October 7, 2015 16:13
Easy Forms for MailChimp - Alter URL user is redirected too using the yikes-mailchimp-redirect-url filter
<?php
/*
* Alter the URL the user is redirected to after a successfull submission of form #3
* - Add a custom URL, or add query args to the page URL selected on the edit forms page
* @parameters
* $url - the original URL set on the edit forms page
* $form_id - the ID of the form that was submitted
* $page_data - the global $post data - contains all sorts of info about the current page (including ID, title etc.)
*/
function yikes_mailchimp_alter_redirect_url( $url, $form_id, $page_data ) {
@EvanHerman
EvanHerman / yikes-easy-forms-for-mailchimp-custom-default-value-tag.php
Last active October 12, 2015 13:40
Add custom tags to the 'pre defined tags' section
<?php
/*
* Add a new custom tag to the 'pre defined tags' section
* @ Change 'tag', 'description' and 'title' to suit your needs.
* @ $available_tags - the default pre-defined tags available out of the box
*/
add_filter( 'yikes-mailchimp-custom-default-value-tags', 'add_new_pre_defined_tags' );
function add_new_pre_defined_tags( $available_tags ) {
// define a new array, with our default tag data (note: to create more than one, simply copy and paste what is below and alter the values)
$available_tags[] = array(
@EvanHerman
EvanHerman / acf-file-field-download-after-submission.php
Last active October 8, 2015 17:49
After a form is successfully submitted, redirect the user to a download attached to the current page and assigned to an ACF (http://www.advancedcustomfields.com/) 'file' field.
<?php
/*
* Grab the contents of an ACF 'file' field, called attached_file, on the page the form was submitted on (ie: page with ID 15)
* and re-direct the user to that URL (to download the file) after a successful submission.
* @since 0.1
*/
function yikes_mailchimp_alter_redirect_url( $url, $form_id, $page_data ) {
// grab the ACF field -- returns an array
// (Example: Array ( [id] => 43 [alt] => [title] => 2002 [caption] => [description] => [mime_type] => file/zip [url] => http://www.example.com/file.zip ) )
@EvanHerman
EvanHerman / wp-svg-icon-repair-snippet.php
Created October 9, 2015 12:12
Fix WP SVG Icons being overridden in the dashboard
<?php
/*
* This snippet gets placed at the bottom of your active themes functions.php file
* - This is necessary as some themes load their own set of icons and use !important; which conflicts with our plugin
*/
/*
* Fix theme's overriding the default icon set in the dashboard
*/
@EvanHerman
EvanHerman / populate-field-with-url-param-plugin.php
Last active October 12, 2015 13:52
Easy Forms for MailChimp by YIKES - Pre-populate form field with URL Param shortcode.
<?php
/*
* Add a new custom tag to the 'pre defined tags' section
* @ Change 'tag', 'description' and 'title' to suit your needs.
* @ $available_tags - the default pre-defined tags available out of the box
*/
add_filter( 'yikes-mailchimp-custom-default-value-tags', 'add_new_pre_defined_tags' );
function add_new_pre_defined_tags( $available_tags ) {
// define a new array, with our default tag data (note: to create more than one, simply copy and paste what is below and alter the values)