Skip to content

Instantly share code, notes, and snippets.

Jordan Smith hirejordansmith

Block or report user

Report or block hirejordansmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hirejordansmith
hirejordansmith / functions.php
Created Sep 26, 2019
Add support for ACF custom fields to WooCommerce Attributes
View functions.php
<?php
// Adds a custom rule type.
add_filter( 'acf/location/rule_types', function( $choices ){
$choices[ __("Other",'acf') ]['wc_prod_attr'] = 'WC Product Attribute';
return $choices;
} );
// Adds custom rule values.
add_filter( 'acf/location/rule_values/wc_prod_attr', function( $choices ){
@hirejordansmith
hirejordansmith / functions.php
Last active Aug 28, 2019
Move ACF Field Groups back to High (after title) position
View functions.php
<?php
add_action( 'admin_init', 'prefix_reset_metabox_positions' );
function prefix_reset_metabox_positions(){
// for posts
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_post' );
// for pages
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_page' );
// for custom post type Sermon Series
@hirejordansmith
hirejordansmith / functions.php
Created Jun 28, 2019
How to add a WooCommerce Quick Buy Link without a plugin
View functions.php
<?php
// Outputs the button below the default Add to cart button on Single Product page
add_action('woocommerce_after_add_to_cart_button','hjs_add_quick_buy_link_single', 5);
function hjs_add_quick_buy_link_single() { ?>
<style>
.woocommerce div.product form.cart .button.quick-buy {
background: #f04e3d !important;
border-color: #f04e3d !important;
margin-left: 10px;
}
@hirejordansmith
hirejordansmith / hjs-gform-pre-submission-css-class.php
Created Apr 4, 2019
Gravity Forms // gform_pre_submission filter based on field CSS class
View hjs-gform-pre-submission-css-class.php
<?php
add_action( 'gform_pre_submission', 'pre_submission_handler_one' );
function pre_submission_handler_one( $form ) {
foreach ( $form['fields'] as $field ) {
$cssClass = $field->cssClass;
if ( strpos($cssClass, 'test') !== false) {
$field_id = $field->id;
$date = new DateTime( 'now' );
$_POST["input_$field_id"] = $date->format('U');
}
@hirejordansmith
hirejordansmith / gf-2-3-database-updates.txt
Last active Dec 12, 2018
Gravity Forms 2.3 Database Updates
View gf-2-3-database-updates.txt
rg_lead_meta -> gf_entry_meta
rg_lead_detail -> gf_entry_meta
rg_lead -> gf_entry
All lead_id columns -> entry_id
rg_form_meta -> gf_form_meta
rg_form_view -> gf_form_view
rg_form -> gf_form
View facet-wp-infinite-scroll.js
/* globals FWP */
/**
* JavaScript for FacetWP Infinite Scroll
*/
( function( $ ) {
'use-strict';
var throttleTimer = null;
var throttleDelay = 100;
@hirejordansmith
hirejordansmith / functions.php
Created Feb 20, 2018
Add New Tab to the WooCommerce My Account Page
View functions.php
/**
* @snippet Add New Tab to WooCommerce My Account Page
* @author Hire Jordan Smith // https://hirejordansmith.com
*/
// Register new endpoint to use for My Account page
add_action( 'init', 'hjs_add_account_update_endpoint' );
function hjs_add_account_update_endpoint() {
add_rewrite_endpoint( 'account-update', EP_ROOT | EP_PAGES );
}
@hirejordansmith
hirejordansmith / functions.php
Created Feb 19, 2018
HJS // Force WordPress Images to link to Media File instead of Attachment Page Globally
View functions.php
<?php
add_shortcode( 'gallery', 'my_gallery_shortcode' );
function my_gallery_shortcode( $atts ) {
$atts['link'] = 'file';
return gallery_shortcode( $atts );
}
@hirejordansmith
hirejordansmith / base-code.js
Last active Feb 6, 2017
How to automatically reload a Gravity Form in a modal
View base-code.js
// This would be added to a callback or event function
// Replace "82" with the ID of your form
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
@hirejordansmith
hirejordansmith / pre-populate-gf-dropdown-with-affiliates.php
Last active Feb 6, 2017
Pre-populate a Gravity Forms Dropdown field with AffiliateWP Affiliates
View pre-populate-gf-dropdown-with-affiliates.php
<?php
// Add filters for Form ID 8
add_filter( 'gform_pre_render_8', 'populate_posts' );
add_filter( 'gform_pre_validation_8', 'populate_posts' );
add_filter( 'gform_pre_submission_filter_8', 'populate_posts' );
add_filter( 'gform_admin_pre_render_8', 'populate_posts' );
function populate_posts( $form ) {
// Loop through each field searching for any "select" field with the class "populate-affs"
You can’t perform that action at this time.