Skip to content

Instantly share code, notes, and snippets.

View chriswagoner's full-sized avatar

Chris Wagoner chriswagoner

  • Chicago
View GitHub Profile
@chriswagoner
chriswagoner / mem-bump.php
Created May 25, 2018 14:49
Let's bump that WordPress memory up!
/* This goes in that config file */
define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
@chriswagoner
chriswagoner / bb-anchor-offset.js
Created September 26, 2018 19:34
Offsetting the Beaver Builder page scroll for anchor links
jQuery(function ($) {
var win = $(window);
function bbScroll() {
if ('undefined' != typeof FLBuilderLayoutConfig) {
var offset = 0;
if ('undefined' === typeof FLBuilderLayout) {
return;
}
@chriswagoner
chriswagoner / toolset-add-active-filter-class
Created May 14, 2019 19:39
Add a class to the active checkbox in Toolset after the AJAX filter runs.
jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function active_label(){
jQuery('input[checked=checked]').parent().addClass('active');
});
@chriswagoner
chriswagoner / Toolset_View_as_Tabs.note
Created June 20, 2019 20:39
Separating data into Tabs in Toolset Views
// This is how you can separate your view pulls into tab for better layouts.
// Note, you will need to have something to query against for the data seperation.
// Use Case: WooCommerce Products in Tabs
// You will need 3 Views to accomplish this. We open the tabs the first view and close the tabs in the second view. We add the second view into the first on the outside of the loop (since it contains it's own loop). Then nest a view in there for final data. See the example below.
// 1. Add the jQuery UI Tabs to WordPress
// Add this to specific pages using a Beaver Builder Themer part
<script type="text/javascript">
jQuery(function( $ ) {
@chriswagoner
chriswagoner / tax_in_url.php
Last active August 11, 2019 03:40
Add Taxonomy to URL
// Custom Taxonomy Permalinks -- This will use the Taxonomy Variable as part of the URL dynamically
// You will need to add the %variable% from line 10 in your post type like this
// 'rewrite' => array('slug' => '/%variable%', 'with_front' => false)
// or if you're using Toolset then turn on permalink rewrite and add /%variable% as the custom rewrite
add_filter('post_link', 'location_permalink', 10, 3); // Call it what you want
add_filter('post_type_link', 'location_permalink', 10, 3); // Call it what you want
function location_permalink($permalink, $post_id, $leavename) { // Make sure your name matches the filter name above
if (strpos($permalink, '%state%') === FALSE) return $permalink; // The variable you add to your rewrite URL, here we are using %state%
@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;
})
@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 / 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 / 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 / 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]