Skip to content

Instantly share code, notes, and snippets.

View richardbuff's full-sized avatar

Richard Buff richardbuff

View GitHub Profile
@richardbuff
richardbuff / wc-set-all-ancestor-categories-for-product.php
Last active June 6, 2018 19:41
WP-CLI - Set all parent / ancestor categories for a WooCommerce product - WP-CLI custom command
<?php
// If a child category for WooCommerce Product is set, but the parent/grandparent/etc category is not set,
// running this will also set all the ancestor categories (parent, grandparent, etc...)
if ( defined('WP_CLI') && WP_CLI ) { //Check to make sure WP_CLI is running. This way our code isn't loaded on normal site visits.
/**
* Class EA_Set_All_Ancestor_Cats_For_A_Product
*/
class EA_Set_All_Ancestor_Cats_For_A_Product extends WP_CLI_Command {
@richardbuff
richardbuff / gist:ca05441197668ae28b68
Last active August 29, 2015 14:22
Sublime Snippets For PHP echo of HTML opening and closing tags
// Save as: php-echo-open-html.sublime-snippet
<snippet>
<content><![CDATA[
echo '<${1:div} ${2:class}="${3:value}">';
]]></content>
<description>PHP echo statement with opening html tag with class</description>
<tabTrigger>phpechohtmlopen</tabTrigger>
<scope>source.php.embedded.block.html</scope>
</snippet>