Skip to content

Instantly share code, notes, and snippets.

View kurtschlatzer's full-sized avatar

Kurt Schlatzer kurtschlatzer

View GitHub Profile

Keybase proof

I hereby claim:

  • I am kurtschlatzer on github.
  • I am kurtschlatzer (https://keybase.io/kurtschlatzer) on keybase.
  • I have a public key whose fingerprint is 6126 1316 C9FE 560A 650B 8771 45D5 0AC9 D2CD 4E16

To claim this, I am signing this object:

@kurtschlatzer
kurtschlatzer / bootstrap-4-menu-wordpress-filters.md
Created August 8, 2019 14:06 — forked from jakebellacera/bootstrap-4-menu-wordpress-filters.md
Bootstrap 4 menus in WordPress via filters. No walker needed!

Bootstrap 4 menus in WordPress with filters

No walker needed!

This snippet allows you to create Bootstrap 4 menus without the use of a Walker. Instead, we're using filters to leverage WordPress core functionality as much as possible. Basically, all you need to do is this and you're done:

<nav class="navbar navbar-expand-lg fixed-top">
  <div class="container">
    <a class="navbar-brand" href="<?php echo home_url(); ?>">
@kurtschlatzer
kurtschlatzer / gist:6f58cb9c7099c93ffad6893d73af1fed
Created May 11, 2019 02:32 — forked from bryceadams/gist:050d886159265d6f5e6dbce649552704
Disable WooCommerce total spent / order count meta calculations
<?php
add_filter( 'get_user_metadata', 'mtkdocs_filter_user_metadata', 10, 4 );
function mtkdocs_filter_user_metadata( $value, $object_id, $meta_key, $single ) {
// Check if it's one of the keys we want to filter
if ( in_array( $meta_key, array( '_money_spent', '_order_count' ) ) ) {
// Return 0 so WC doesn't try calculate it
return 0;
}
// Default
<?php
/**
* WordPress menu cache.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@kurtschlatzer
kurtschlatzer / remove_wc_data.sql
Created January 3, 2019 20:20 — forked from growdev/remove_wc_data.sql
Remove WooCommerce orders, subscriptions, non admin users
# GET number of orders
select count(*)from wp_posts where post_type = 'shop_order';
# DELETE ORDERS
delete from wp_postmeta where post_id in (
select ID from wp_posts where post_type = 'shop_order');
delete from wp_posts where post_type = 'shop_order';
# DELETE order refunds
## Delete duplicate WooCommerce products
## (Retains the lowest ID)
## Pro tip: Change to SELECT to test
DELETE bad_rows.*
from wp_posts as bad_rows
inner join (
select post_title, MIN(id) as min_id
from wp_posts
where post_type = 'product'
@kurtschlatzer
kurtschlatzer / WP-missing-featured.sql
Created January 3, 2019 19:18 — forked from tomfordweb/WP-missing-featured.sql
Select All posts that are missing featured image
/**
* USE AT YOUR OWN RISK!
*
* In no way do I guarantee the accuracy of these queries to do exactly what you want on your own server.
* I have written them down for my own personal record, and you are free to use at your own discretion,
* and provide corrections.
*/
/**
* 1. Delete order and coupon meta data.
@kurtschlatzer
kurtschlatzer / redirect-from-json.php
Created July 18, 2018 17:49 — forked from SteveRyan-ASU/redirect-from-json.php
Pantheon: Redirect via JSON feed in private file section
// PHP snippet included in wp-config.php (or settings.php).
// Including from that location in a separate file is OK as well.
<?php
// Remove any leading "www." from the host name.
$redirect_host = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$redirect_path = strtolower(rtrim($_SERVER['REQUEST_URI']));
if (strlen($redirect_path) > 2) {
$redirect_path = rtrim($redirect_path, '/');
}
@kurtschlatzer
kurtschlatzer / cart.php
Created April 19, 2018 15:21 — forked from WebEndevSnippets/cart.php
Plugin: Clear Cart for WooCommerce
<input type="submit" class="button" name="clear-cart" value="<?php _e('Empty Cart', 'woocommerce'); ?>" />