Skip to content

Instantly share code, notes, and snippets.

View mattyza's full-sized avatar
Focused

Matty Cohen mattyza

Focused
View GitHub Profile
@mattyza
mattyza / blueprint.json
Last active May 19, 2024 08:20
A blueprint for importing a set of content in WXR format from another gist into WordPress Playground
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/kb/",
"steps": [
{
"step": "importWxr",
"file": {
"resource": "url",
"url": "https://gist.githubusercontent.com/mattyza/47b23aca53a7de81743d3dd9f01464c7/raw/2442ca3400b8cf2666f6015c48744d3397f04b08/kb-pages-to-import.xml"
}
@mattyza
mattyza / phpcs.xml
Created September 10, 2020 10:11 — forked from gedex/phpcs.xml
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>WooCommerce extension PHP_CodeSniffer ruleset.</description>
<!-- Exclude paths -->
<exclude-pattern>tests/</exclude-pattern>
<exclude-pattern>woo-includes/woo-functions.php</exclude-pattern>
<exclude-pattern>woo-includes/class-wc-dependencies.php</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

Simple iDoneThis Alternative

This simple script is for logging all of the awesome things you do every day, using Terminal, and syncing them all to Dropbox. Nifty, right?

Installation

  • Grab the idid.sh file to a directory on your computer (tested with OS X).
  • Using Terminal, in the directory where you placed idid.sh, run the following commands:
  • mv idid.sh /usr/local/bin/idid.sh
@mattyza
mattyza / customer-centric-from-details.php
Created March 10, 2016 12:31
Use the customer's details as the "From" information for "New Order" emails in WooCommerce.
function custom_use_customer_from_address ( $from_email, $obj ) {
if ( is_a( $obj, 'WC_Email_New_Order' ) ) {
$address_details = $obj->object->get_address( 'billing' );
if ( isset( $address_details['email'] ) && '' != $address_details['email'] ) {
$from_email = $address_details['email'];
}
}
return $from_email;
}
add_filter( 'woocommerce_email_from_address', 'custom_use_customer_from_address', null, 2 );
@mattyza
mattyza / matty-double-post-type-rewrite-rule-example.php
Last active October 16, 2023 06:49
A WordPress custom rewrite rule example, combining two post types.
<?php
/**
* Plugin Name: Double Post Type Rewrite Rule Example
* Plugin URI: https://gist.github.com/mattyza/7dfd156992f23835f68e
* Description: Adds a custom rewrite rule to mimic http://domain.com/post-type-01/post-type-02/.
* Author: Matty Cohen
* Author URI: http://matty.co.za/
* Version: 1.0.0
* Stable tag: 1.0.0
* License: GPL v3 - http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
@mattyza
mattyza / matty-profile-rewrite.php
Created August 22, 2012 09:59
Modify the "/author" rewrite rule in WordPress to read "/profile" (permalinks refresh required).
<?php
/**
* Plugin Name: Add "/profile" URL rewrite rule.
* Version: 1.0.0
* Author: Matty
* Description: Add a rewrite rule to redirect "/profile" URLs to the appropriate author archive screen.
*/
new Matty_Profile_Rewrite();