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 / bootstrap-alert.css
Created March 17, 2018 13:09
Bootstrap Alert CSS
.alert {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
}
.alert h4 {
margin-top: 0;
color: inherit;
@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 / functions.php
Created January 24, 2016 16:56
Localize the jquery datepicker in WordPress using the WP_Locale object
<?php
add_action( 'admin_enqueue_scripts', 'admin_print_js' );
public function admin_print_js() {
global $wp_locale;
//add the jQuery UI elements shipped with WP
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-datepicker' );
@EvanHerman
EvanHerman / config.yml
Last active December 3, 2021 02:56
WordPress Plugin CircleCI 2.0 Config - PHPCS, PHPUnit and rsync Deployment
workflows:
version: 2
main:
jobs:
- php56-build
- php70-build
- php71-build
- php72-build
- deploy:
requires:
@EvanHerman
EvanHerman / redirect-user-back-to-product.php
Created November 13, 2015 16:30
WooCommerce - After login, redirect the user back to the last viewed product
<?php
/*
* Add a hidden field to our WooCommerce login form - passing in the refering page URL
* Note: the input (hidden) field doesn't actually get created unless the user was directed
* to this page from a single product page
*/
function redirect_user_back_to_product() {
// check for a referer
$referer = wp_get_referer();
// if there was a referer..
@EvanHerman
EvanHerman / wp-admin-table-markup.html
Last active August 8, 2020 07:32
WordPress Dashboard Admin Table Markup
<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
<th id="cb" class="manage-column column-cb check-column" scope="col"></th> <!-- this column contains checkboxes -->
<th id="columnname" class="manage-column column-columnname" scope="col"></th>
<th id="columnname" class="manage-column column-columnname num" scope="col"></th> <!-- "num" added because the column contains numbers -->
</tr>
</thead>
@EvanHerman
EvanHerman / easy-forms-for-mailchimp-email-notifications.php
Last active May 20, 2020 09:10
Easy Forms for MailChimp - Email notifications when a user signs up
<?php
/*
* This snippet should go at the bottom of your functions.php file.
* Send a notification email to the user after a form is successfully submitted
* @sample snippet
*/
function yikes_easy_forms_for_mailchimp_email_notifications( $email, $submitted_data, $form, $notifications ) {
if( ! empty( $submitted_data ) ) {
// add additional items you don't want included in the email notification
$exclude_from_email = array(
@EvanHerman
EvanHerman / custom-read-more-text.php
Last active September 20, 2019 02:30
Timeline Express Custom Read More Text
<?php // Do not include this line - this is here for syntax highlighting only
/**
* Alter the read more text on the timeline
*
* @param string $text The read more link text.
* @param integer $post_id The post ID.
*
* @return string The final read more link text.
*/
@EvanHerman
EvanHerman / rw-elephant-inventory-gallery-filters.php
Last active October 15, 2018 00:09
RW Elephant Inventory Gallery - Product Data Filters
@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 ) {