Skip to content

Instantly share code, notes, and snippets.

@jessepearson
jessepearson / acf-update-via-json.php
Created March 24, 2015 12:58
Automatically update Advanced Custom Fields field groups via JSON
<?php
/**
* Function that will automatically update ACF field groups via JSON file update.
*
* @link http://www.advancedcustomfields.com/resources/synchronized-json/
*/
function jp_sync_acf_fields() {
// vars
stdClass Object
(
[id] =>
[packed] => Array
(
[0] => WC_Boxpack_Item Object
(
[weight] => 7.00
[height] => 2.50
[width] => 12.00
stdClass Object
(
[id] =>
[packed] => Array
(
[0] => WC_Boxpack_Item Object
(
[weight] => 7.00
[height] => 2.50
[width] => 12.00
@jessepearson
jessepearson / jp_address_field_filter.php
Created November 4, 2015 19:07
Function to modify/change the label and placeholder for address fields in WooCommerce
<?php
/**
* Removes "Town" from label/placeholder in checkout forms
*/
function jp_address_field_filter( $fields ) {
// fields we want to look for
$search = array(
'billing_city',
'shipping_city',
[06-Nov-2015 15:03:43 UTC] $possible_packages:
[06-Nov-2015 15:03:43 UTC] Array
(
[0] => stdClass Object
(
[id] =>
[packed] => Array
(
[0] => WC_Boxpack_Item Object
(
<?php
// go through possible packages
foreach ( $possible_packages as $package ) {
// add the best to a new array
if ( $package->percent == $best_percent ) {
$best_packages[] = $package;
}
}
@jessepearson
jessepearson / gist:dc77c1b57a40f9bb6648
Created November 19, 2015 17:16
Remove redundant, additional image sizes in wordpress via command line.
Taken from: http://www.deluxeblogtips.com/2012/05/remove-image-sizes.html
If you want to remove files of specific size (for ex. 180x180), run this command:
find . -name *-180x180.* | xargs rm -f
This will remove all files with name *-180x180.* (such as screenshot-180x180.jpg), which are generated by WordPress.
Note: You can only do this if you have privilege of running Linux command on your host/server. If you don’t (in case of using shared host), you should ask your host support to do this for you.
If you want to remove all generated files, run this command:
@jessepearson
jessepearson / woocommerce-email-new-address.php
Last active June 17, 2016 19:58 — forked from BFTrick/woocommerce-email-new-address.php
Email the site admin when a customer changes their address
<?php
/**
* Plugin Name: WooCommerce Email Customer Address
* Plugin URI: https://gist.github.com/BFTrick/7891074
* Description: Email the site admin when a customer changes their address
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@jessepearson
jessepearson / reorder-wc-memberships-posts-listing.php
Last active September 29, 2017 14:53
Reordering membership content on My Membership Content page in WooCommerce Memberships
<?php // only copy this line if needed
/**
* This function allows for the editing of the query args for the query that displays the posts/content on the My Membership Content page
*
* Works with Memberships v1.6.3
*
* @param array $query_args The query arguements
* @param string $type The type of restriction being queried, unused in this case.
* @param int $paged The page, if paged, also unused.
* @see https://codex.wordpress.org/Class_Reference/WP_Query
@jessepearson
jessepearson / give_zip_back_to_wc.php
Last active June 29, 2016 23:48
This function will add zip files back to the allowed mime types WooCommerce can use
<?php // Only copy this line if needed
/**
* This function will add zip files back to the allowed mime types WooCommerce can use
*
* @param array $mimes The allowed mime types
* @return array The filtered allowed mime types
*/
function give_zip_back_to_wc( $mimes ) {