Skip to content

Instantly share code, notes, and snippets.

<?php
/***********************************************************************************
These are examples and references for the WooCommerce Order Item meta data hooks
that is displayed in the admin side of WordPress when viewing a customer's order.
***********************************************************************************/
//Do Something before the order item's meta data
do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $_product );
//Do Something after the order item's meta data
@wisecrab
wisecrab / string-split-by-word-after-x-characters.php
Last active September 2, 2015 20:55
Split a string by word after $x amount of characters
<?php
function splitStringByWords($x, $string) {
//Convert the string
$converted_string = explode( "\n", wordwrap( $string, $x));
//Return the array of split strings
return $converted_string;
}
//Number of characters the split will occur after
@wisecrab
wisecrab / custom-fields-and-taxonomies.php
Last active August 27, 2015 15:41
Easy to use functions for getting access to custom meta data for posts and custom posts.
/*****************************************************
*** Get all taxonomy terms for a post ***
*****************************************************/
get_the_term_list( $post->ID, 'taxonomy_name' ); //Returns links
get_the_term_list( $post->ID, 'taxonomy_name', '', ', ', '' ); //Returns links separated by commas
strip_tags(get_the_term_list( $post->ID, 'taxonomy_name' )); //Returns text
/*****************************************************
*** Get custom fields for a post ***
<?php
function seoFriendly($string, $separator) {
//Only accept dashes or underscores
if( $separator == "-" || $separator == "_" ) {
$separator = $separator;
} else {
$separator = "-";
}
@wisecrab
wisecrab / mixins.scss
Last active November 21, 2024 16:28
A collection of useful SCSS mixins.
/***********************************************
Gradients
***********************************************/
@mixin gradient($from, $to) {
background: -webkit-gradient(linear, left top, left bottom, from($from), to($to));
background: -moz-linear-gradient(top, $from, $to);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
}
//Usage
@wisecrab
wisecrab / grid.css
Last active October 7, 2015 20:59
A simple CSS grid built around device types. Easily configure for a project by setting the 3 different screen size variables and adjusting the padding for the rows, that's it!
/**************************************************
>> Grid <<
**************************************************/
.row {
display: block;
box-sizing: border-box;
}
.row:after {
content: "";
display: block;
//Rename the coupon field on the cart page
function woocommerce_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) {
// bail if not modifying frontend woocommerce text
if ( is_admin() || 'woocommerce' !== $text_domain ) {
return $translated_text;
}
if ( 'Apply Coupon' === $text ) {
$translated_text = 'MY_NEW_TEXT_HERE';
}
return $translated_text;
<!DOCTYPE html>
<html>
<head>
<title>Kitchen Sink</title>
</head>
<body>
<section id="main">
<!DOCTYPE html>
<html>
<head>
<!-- Document Settings -->
<meta charset="utf-8" >
<!-- Responsive Settings -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes, minimum-scale=1.0, maximum-scale=2.0">
<!-- SEO Settings -->