Skip to content

Instantly share code, notes, and snippets.

@wisecrab
wisecrab / wordpress-send-email.php
Last active August 29, 2015 14:28
A simple function and variable set group to send an email from WordPress.
$to = 'email@example.com';
$subject = 'This is the email subject';
$message = 'Here is my email message.';
$headers = 'From: My Name <myname@example.com>' . "\r\n";
$headers .= "Reply-To: myname@example.com \r\n";
$attachments = '';
wp_mail( $to, $subject, $message, $headers, $attachments );
/*
*** Order Status Options ***
>> woocommerce_order_status_pending
>> woocommerce_order_status_failed
>> woocommerce_order_status_on-hold
>> woocommerce_order_status_processing
>> woocommerce_order_status_completed
>> woocommerce_order_status_refunded
>> woocommerce_order_status_cancelled
// Override default theme option for the number
// of products in a row on archive pages.
function products_per_row() {
return 3; // 3 products per row
}
add_filter('loop_shop_columns', 'products_per_row', 999);
//Update the excerpt length
function new_excerpt_length($length) {
return 100; // 100 Words
}
add_filter('excerpt_length', 'new_excerpt_length');
//Register custom sidebar
function theme_slug_widgets_init() {
register_sidebar( array (
'name' => __( 'Custom Sidebar', 'theme_slug' ),
'id' => 'custom_sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s" role="complementary">',
'after_widget' => "</aside>",
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
));
<!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 -->
<!DOCTYPE html>
<html>
<head>
<title>Kitchen Sink</title>
</head>
<body>
<section id="main">
//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;
@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;