Skip to content

Instantly share code, notes, and snippets.

View niemenmaa's full-sized avatar

Anttoni Niemenmaa niemenmaa

View GitHub Profile
@niemenmaa
niemenmaa / functions.php
Created August 30, 2017 07:11
Enable srcset when wp-stateless and Google Bucket is used
add_filter( 'max_srcset_image_width', __NAMESPACE__ . '\\remove_max_srcset_image_width', 99 );
/**
* Reset max srcset image width.
*
* @param int $max_width The maximum image width to be included in the 'srcset'. Default '1600'.
*
* @return bool You can return sensible value also this resets to default 1600.
*/
function remove_max_srcset_image_width( $max_width ) {
return false;
@niemenmaa
niemenmaa / wp-cli-cheats.md
Last active June 8, 2017 10:44
I will update this cheat sheet with handy one liners for wp-cli

WP-CLI cheatsheet

Remove all users with ROLE:

wp user delete $(wp user list --role=ROLE --format=ids)

Run commands as specific user identified by ID

wp eval 'echo get_current_user_id();' --user=ID

Keybase proof

I hereby claim:

  • I am pikkulahti on github.
  • I am pikkulahti (https://keybase.io/pikkulahti) on keybase.
  • I have a public key whose fingerprint is 3360 1ADE 8678 8117 7EFD 22D1 9150 EEA0 E781 4B11

To claim this, I am signing this object:

@niemenmaa
niemenmaa / draft_complete_orders.php
Created February 23, 2017 20:30
This snippet moves ordered items in draft state when order is marked complete. Same with category filter: https://gist.github.com/Pikkulahti/2504f6539b67efe417bd9b1382f72658
<?php
/**
* Moves ordered items in draft state.
*/
function custom_draft_complete_orders( $order_id ) {
// Fetch order infromation
$order = new WC_Order( $order_id );
// Get products on order
$items = $order->get_items();
@niemenmaa
niemenmaa / draft_complete_orders_in_category.php
Last active March 21, 2017 08:55
This snippet moves ordered items in draft state if they are in specific category when order is marked complete. Same without category filter: https://gist.github.com/Pikkulahti/545e5f738027c6e36637f49c6ccd2743
<?php
/**
* Moves ordered items in draft state.
*/
function custom_draft_complete_orders( $order_id ) {
// Fetch order infromation
$order = new WC_Order( $order_id );
// Get products on order
$items = $order->get_items();
foreach( $items as $product ) {