Skip to content

Instantly share code, notes, and snippets.

View DarrylErentzen's full-sized avatar

Darryl Erentzen DarrylErentzen

View GitHub Profile
@DarrylErentzen
DarrylErentzen / wc_order_status_changes.php
Created October 28, 2021 17:01 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@DarrylErentzen
DarrylErentzen / config.json
Created November 29, 2016 01:45 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@DarrylErentzen
DarrylErentzen / currency-formatted.js
Created November 24, 2016 11:44
JavaScript function to format number as currency
function CurrencyFormatted(amount)
{
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
@DarrylErentzen
DarrylErentzen / cleanup.js
Created November 23, 2016 12:12 — forked from joeldrapper/cleanup.js
Cleanup WordPress
function cleanup () {
var textContent = jQuery('.wp-editor-area').val();
textContent = textContent
.replace(/(\<center\>)(["a-z,.!?':;@£$%=\[\]{}^&*()_”“–—‘’\-\+0-9 \n]*)(\<\/center\>)/ig, "<blockquote>$2</blockquote>")
.replace(/(\<img.+\/\>)/g, "\n\n")
.replace(/(\<i\>)(.*)(\<\/i\>)/g, "<em>$2</em>")
.replace(/(\<b\>)(.*)(\<\/b\>)/g, "<strong>$2</strong>");
jQuery('.wp-editor-area').val(textContent);
};
@DarrylErentzen
DarrylErentzen / string_to_slug.js
Created November 23, 2016 12:09
javascript version of WordPress sanitize_title()
function string_to_slug(str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++)
{
@DarrylErentzen
DarrylErentzen / string-to-slug.js
Created November 21, 2016 03:08 — forked from spyesx/string-to-slug.js
String to slug in JS (wordpress sanitize_title)
var string_to_slug = function (str)
{
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++)
@DarrylErentzen
DarrylErentzen / gist:11058641
Last active June 4, 2021 15:12
make a formidable form show tabs for each section
<!-- place styles and jQuery somewhere in the page containing the form, or in the form's "Customize HTML" after the submit button -->
<style>
/***
* styles for tabs
***/
.tab_heading {
background-color: #ddd;
color: #aaa;
font-size: 13px;
display: inline-block;
@DarrylErentzen
DarrylErentzen / gist:9849343
Created March 29, 2014 05:57
Disable wpautop for specific post type (works even if post type is embedded in another post or page)
function disable_wpautop() {
if (get_post_type() == 'frm_display') // replace with slug of your desired post type
remove_filter('the_content', 'wpautop');
}
add_action('wp_head', 'disable_wpautop');
@DarrylErentzen
DarrylErentzen / theCSS.css
Created March 27, 2014 20:46
styling select input with css3
body, html {background:#444; text-align:center; padding:50px 0;}
/* The CSS */
select {
padding:3px;
margin: 0;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
-webkit-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
@DarrylErentzen
DarrylErentzen / gist:9818026
Created March 27, 2014 20:35
disable submit button on click
jQuery('input:submit').click(function(){
jQuery('input:submit').val("Form submiting.....");
jQuery('input:submit').attr("disabled", true);
});