Skip to content

Instantly share code, notes, and snippets.

View Shonari's full-sized avatar

Shonari Shonari

  • Cayman Islands
View GitHub Profile
@Shonari
Shonari / Add content to woocommerce order email
Created May 30, 2017 13:09
Add content to woocommerce order email via theme functions.php file
// add text to the thank you page
add_action( 'woocommerce_email_before_order_table', 'add_content', 20 );
function add_content() {
echo '<h2 id="h2lorem">Lorem Ipsum</h2><p id="pthanks">Illo fugiat mollitia itaque voluptates delectus platea, eius. Odio aperiam, voluptatibus, enim, risus asperiores?</p>';
}
@Shonari
Shonari / Recalculate Google Spreadsheet
Created May 4, 2017 13:44
A button that refreshes a google spreadsheet
function myRecalculate() {
// The code below opens a spreadsheet using its ID
// Note that the spreadsheet is NOT physically opened on the client side.
// It is opened on the server only (for modification by the script).
var ss = SpreadsheetApp.openById("Put_Your_Spreadsheet_ID_Here");
var sheet = ss.getSheetByName("Support");
var cell = sheet.getRange('B1')
cell.setValue(1)
add_filter( 'gform_field_validation_26_79', 'product_quantity_validation', 10, 4 );
add_filter( 'gform_field_validation_26_4', 'product_quantity_validation', 10, 4 );
add_filter( 'gform_field_validation_26_13', 'product_quantity_validation', 10, 4 );
add_filter( 'gform_field_validation_26_14', 'product_quantity_validation', 10, 4 );
add_filter( 'gform_field_validation_26_17', 'product_quantity_validation', 10, 4 );
function product_quantity_validation( $result, $value, $form, $field ) {
$quantity = intval( rgar( $value, $field->id . '.3' ) );
if ( $result['is_valid'] && !empty( $quantity ) && $quantity < 5 ) {
@Shonari
Shonari / Row Color Google Sheets
Created October 27, 2014 15:20
Alternating Row Color in Google Sheets
// Go to Format > Conditional Formatting. Select "Custom formula is" then add the following formula followed by cell color you wish.
=MOD(ROW(A2),2) < 1
@Shonari
Shonari / WordpressEmail.php
Created July 4, 2014 16:25
Replace default Wordpress email address and from name with website specific information. Just paste in your themes function.php file.
function res_fromemail($email) {
$wpfrom = get_option('admin_email');
return $wpfrom;
}
function res_fromname($email){
$wpfrom = get_option('blogname');
return $wpfrom;
}
@Shonari
Shonari / 0_reuse_code.js
Created July 4, 2014 15:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Shonari
Shonari / ImageDimension
Created July 4, 2014 15:41
Add an image dimension column to the Media Library in Wordpress. Just copy code and paste in your themes function.php file
add_filter('manage_upload_columns', 'size_column_register');
function size_column_register($columns) {
$columns['dimensions'] = 'Dimensions';
return $columns;
}
add_action('manage_media_custom_column', 'size_column_display', 10, 2);
function size_column_display($column_name, $post_id) {
if( 'dimensions' != $column_name || !wp_attachment_is_image($post_id))
return;
list($url, $width, $height) = wp_get_attachment_image_src($post_id, 'full');