Skip to content

Instantly share code, notes, and snippets.

View chriswagoner's full-sized avatar

Chris Wagoner chriswagoner

  • Chicago
View GitHub Profile
@chriswagoner
chriswagoner / acf_date_format.php
Created May 13, 2021 13:17
Advanced Custom Fields ACF shortcode for date format output
function acf_event_date( $atts )
{
// extract attributes
extract( shortcode_atts( array(
'field' => '',
'post_id' => false,
'format_value' => true,
'date_format' => ''
), $atts ) );
@chriswagoner
chriswagoner / get_this_post.php
Created April 12, 2021 19:12
Get the ID of this post
add_shortcode( 'return_post_id', 'gimme_post_id' );
function gimme_post_id() {
return get_the_ID();
}
@chriswagoner
chriswagoner / remove_woocommerce_lightbox.php
Created January 26, 2021 19:43
Remove the WooCommerce Lightbox Effect
/**
* Remove WooCommerce Lightbox
*/
add_action( 'init', 'my_remove_lightbox' );
function my_remove_lightbox() {
remove_theme_support( 'wc-product-gallery-lightbox' );
}
// ================================================================================================
// FLIPPING THE GET SHORTCODE TO GET CATS IN A RESTRICTED FASHION ^CW
// ================================================================================================
/**
* Eg : [getcats type="slug"]
* Shortcode for getting a list of categories from a current product category & restricted by product brand
*
* Shortcode attributes :
* type (optional): type of resultset values returned (slug or id) Default: slug
@chriswagoner
chriswagoner / get_tabs.php
Created March 12, 2020 19:24
A shortcode that will get Tabs from woocommerce products so you can output in a tabular fashion. This is part 1 of 2. You must have an attribute called tabs for this to work.
/**
* Eg : [gettabs category="hydraulic" type="slug"]
* Shortcode for getting a list of tabs from a product category
*
* Shortcode attributes :
* type (optional): type of resultset values returned (slug or id) Default: slug
* category (required): slug of product category
*
* returns comma-separated string of tab slugs or tab ids
*/
@chriswagoner
chriswagoner / beaver-themer-wc-notices.php
Last active February 29, 2020 05:18 — forked from carlosonweb/beaver-themer-wc-notices.php
Move the WooCommerce Notices on the Beaver Themer Singular Product Layout to Anywhere on the layout via a Custom Shortcode
/**
* First, remove WooCommerce Notices box from its default location on the page (somewhere at the top).
*/
remove_filter( 'fl_theme_builder_before_render_content', 'FLThemeBuilderWooCommerceSingular::before_render_content' );
/* You can now insert the store messages using the default WooCommerce shortcode -> [shop_messages] */
/**
* OPTIONAL NEW SHORTCODE
* Create this shortcode : [fl_woocommerce_notices]
@chriswagoner
chriswagoner / scrub_woo.txt
Created September 12, 2019 19:56
Scrub Woocommerce from Database
// Dropping Woocommerce part because it's way faster!
// Here are two sources below with credit -- I'll add more as I find them
1.) Remove all products, categories, meta and relations
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
@chriswagoner
chriswagoner / BB_add_UA_Platform.js
Last active May 12, 2020 13:40
Beaver Builder: Add User Agent & Platform to HTML
// In Beaver Builder, we want to inject the browser and platform into the HTML tag so we can target specific browsers and/or platform in a simple manner.
// Open Beaver Builder > Open Global Settings > Javascript Tab > Paste Below Snippet
// Credit: https://codepen.io/samiah/pen/NgQKMb
jQuery(function() {
var b = document.documentElement;
b.setAttribute('data-useragent', navigator.userAgent);
b.setAttribute('data-platform', navigator.platform );
b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
});
@chriswagoner
chriswagoner / toolset-select-location.js
Created August 21, 2019 18:36
Toolset - Dynamically populate the dropdown to select the user's current location
// Add this to the Search and Pagination JS field.
// This will populate the dropdown (view filter) to set the state that the user is currently in. You can target any filter you have on the page.
// You will need to install the plugin CF Geo Plugin. They have shortcode and you can utilize JS for location attributes.
// Here we're changing a State dropdown for locations. Change to fit your project.
jQuery(document).ready(function () {
if(jQuery("body:not(.home) #wpv_control_select_wpcf-org-state option[selected='selected']").val() === "") {
var state = window.cfgeo.region;
var stateHandle = '#wpv_control_select_wpcf-org-state option[value="' + state + '"]';
jQuery(stateHandle).attr('selected', true).trigger('change');
@chriswagoner
chriswagoner / toolset_sort_by_distance.js
Last active August 21, 2019 18:28
Toolset - Sort results by distance
// This will go into the Search and Pagination JS box in toolset. It will exectue when the search results are updated.
// Change the .main-wrapper & and list-item to your classes.
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
var $wrapper = $('.main-wrapper');
$wrapper.find('.list-item').sort(function (a, b) {
return +a.dataset.sort - +b.dataset.sort;
})