Skip to content

Instantly share code, notes, and snippets.

View tankbar's full-sized avatar

Tankbar tankbar

View GitHub Profile
@tankbar
tankbar / functions.php
Created September 21, 2017 13:31
Search custom fields on WooCommerce Orders
add_filter( 'woocommerce_shop_order_search_fields', 'woocommerce_shop_order_search_order_total' );
function woocommerce_shop_order_search_order_total( $search_fields ) {
$search_fields[] = '_order_total';
return $search_fields;
}
@tankbar
tankbar / functions.php
Created September 20, 2017 09:07
Increase variations per page in WooCommerce admin tab
add_filter( 'woocommerce_admin_meta_boxes_variations_per_page', 'override_increase_variations_per_page' );
function override_increase_variations_per_page() { 
return 50; 
}
@tankbar
tankbar / functions.php
Created August 31, 2017 09:27
Easily Remove Query String From CSS & Javascript In WordPress
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
@tankbar
tankbar / functions.php
Created August 25, 2017 12:04
ENQUEUE SCRIPTS AND STYLES WITH AUTOMATIC VERSIONING
//Instead of WP default
//<link rel='stylesheet' id='child-theme-css' href='http://mysite.com/wp-content/themes/child/css/styles.min.css?ver=4.3.1' type='text/css' media='all' />
//You get this every time the minified CSS is saved and compressed:
//<link rel='stylesheet' id='child-theme-css' href='http://mysite.com/wp-content/themes/child/css/styles.min.css?ver=1447781986' type='text/css' media='all' />
<?php
$themecsspath = get_stylesheet_directory() . '/css/styles.min.css';
wp_enqueue_style(
'child-theme',
@tankbar
tankbar / _webkit-reset.scss
Last active April 3, 2017 06:38
-webkit CSS reset
-webkit-tap-highlight-color: rgba(0,0,0,0); // remove default hightlight color on links
-webkit-user-select: none; //prevent user from selecting
-webkit-text-size-adjust: none; //don't allow zooming of text (probaly not wise to use)
-webkit-font-smoothing: antialiased; // (Nice display of custom fonts on webkit, also don't use font-weight: bold; use the weight of the font eg: font-weight: 400;
-webkit-appearance: none; //remove native styling added by ios to form elements
-webkit-backface-visibility: hidden; //fix flickering in ios when animated element is larger than the screen width
/* Fix html5 datepicker arrow when using twitter bootstrap and chrome */
input[type=date]::-webkit-calendar-picker-indicator {
display: inline-block;
@tankbar
tankbar / _reset-webkit-ios.scss
Last active April 3, 2017 06:27
Mobile Safari Reset Inputs
/* MOBILE SAFARI RESET INPUTS */
input[type="text"],
input[type="password"],
input[type="email"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
@tankbar
tankbar / functions.php
Created March 30, 2017 12:58
Add PDF to WooCommerce Order Email
<?php
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
$your_pdf_path = get_template_directory() . '/terms.pdf';
$attachments[] = $your_pdf_path;
return $attachments;
}
@tankbar
tankbar / custom-documents.php
Last active February 16, 2017 15:00
WooCommerce ACF Field for Products documents and Font Awesome Icons
<?php
global $post, $product, $woocommerce;
if(get_field('documents', $post->ID)) {
echo '<table class="shop_table shop_table_responsive shop_documents"><thead><th>Filnamn</th><th>Filtyp</th><th>Storlek</th></thead>';
while(has_sub_field('documents'))
{
$attachment_id = get_sub_field('document_file');
$url = wp_get_attachment_url( $attachment_id );
$title = get_the_title( $attachment_id );
@tankbar
tankbar / stop-long-comments.php
Created February 16, 2017 08:58
WordPress Stop long comments
/*
Plugin Name: Stop long comments
Description: A security precaution to stop comments that are too long.
Version: 0.0.4
Author: WPEngine
Author URI: wpengine.com
License: GPLv2
*/
add_filter( 'pre_comment_content', 'wpengine_die_on_long_comment', 9999 );
@tankbar
tankbar / functions.php
Created January 24, 2017 08:00 — forked from gregrickaby/functions.php
Show me dev info in WordPress
add_action( 'wp_footer', 'wds_debug' );
/*
* Show me some dev info during development! DELETE ME BEFORE GOING LIVE!!!
*
*/
function wds_debug() {
global $template; ?><br />
<?php echo $template; ?><br />
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds<br />
Server load: <?php $load = sys_getloadavg(); echo $load[0]; ?>%<br />