Skip to content

Instantly share code, notes, and snippets.

@ellisar
ellisar / remove_wc_data.sql
Created February 3, 2022 01:52 — 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 ORDER DATA FROM POSTMETA TABLE
delete from wp_postmeta where post_id in (select ID from wp_posts where post_type = 'shop_order');
# DELETE ORDER DATA FROM POSTS TABLE
delete from wp_posts where post_type = 'shop_order';
@ellisar
ellisar / woocommerce-optimize-scripts.php
Created March 20, 2019 07:26 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@ellisar
ellisar / role.js
Created November 2, 2018 14:27 — forked from tranchau1991/role.js
all role in wp
object(WP_Roles)[1286]
public 'roles' =>
array (size=9)
'administrator' =>
array (size=2)
'name' => string 'Administrator' (length=13)
'capabilities' =>
array (size=139)
'switch_themes' => boolean true
'edit_themes' => boolean true
@ellisar
ellisar / gist:a5e34721f6f967021a8ee795ebf48a6d
Created October 30, 2018 18:00 — forked from dkwiebe/gist:477d5f8af91022357ef13324a06a130e
Retrieve Subscription products from WooCommerce
SELECT subscription_line_items.subscription_id,
subscriptions.post_status,
product.id AS product_id,
product.post_title AS product_name,
product.post_status,
mo.product_type,
subscription_line_items.qty,
subscription_line_items.product_total,
subscription_meta.currency,
subscription_meta.billing_period,
/* Woocommerce Styles */
/*
A couple things to note...
1. This code was written very specifically for my base child theme so it might not work out of the box with every theme.
I have it here mostly to share with anyone who might be looking to do the same thing I was.
2. I generally add my WooCommerce CSS overrides to a custom-woo.css file then use wp_enqueue_style() to call it
so that it enqueues after the default WooCommerce Stylesheets
@ellisar
ellisar / gist:2b045dd1cafd16e5ec17eb26431fa8ac
Created October 7, 2018 15:38 — forked from corsonr/gist:8583524
WooCommerce / Checkout field editor: define range dates for datepicker field type
add_filter( 'wp_footer' , 'woo_add_checkout_field_date_range_limit' );
/**
* woo_add_checkout_field_date_range_limit
*
* @access public
* @since 1.0
* @return void
*/
function woo_add_checkout_field_date_range_limit() {
@ellisar
ellisar / GitHub Gist WP Shortcodes Plugin
Created October 7, 2018 15:33 — forked from corsonr/GitHub Gist WP Shortcodes Plugin
How to use GitHub Gist within Wordpress Shortcodes
<?php
/*
Plugin Name: Easy GitHub Gist Shortcodes
Plugin URI: http://www.remicorson.com/easy-github-gist-shortcodes
Description: Insert easily GitHub Gist within shortcodes this way [gist id="xxxxxx"]
Version: 1.0
Author: Remi Corson
Author URI: http://www.remicorson.com/
*/
@ellisar
ellisar / Easy Default Parameters
Created October 7, 2018 15:30 — forked from corsonr/Easy Default Parameters
Set your default parameters on fresh installs
<?php
/*
Plugin Name: Easy Default Parameters
Plugin URI: http://remicorson.com
Description: Set your own default parameters on a fresh WordPress install
Version: 0.1
Author: Rémi Corson
Author URI: http://remicorson.com
Contributors: Rémi Corson, corsonr
*/