Skip to content

Instantly share code, notes, and snippets.

View hslaszlo's full-sized avatar

Laszlo Sebestyen Horvath hslaszlo

View GitHub Profile
/*
* From css-tricks.com
* http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@hslaszlo
hslaszlo / functions.php
Last active September 8, 2015 14:57 — forked from kloon/functions.php
WooCommerce add "Save x%" next to sale prices
<?php
// Add save percent next to sale item prices.
add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 );
function woocommerce_custom_sales_price( $price, $product ) {
$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
return $price . sprintf( __(' Save %s', 'woocommerce' ), $percentage . '%' );
}
?>
@hslaszlo
hslaszlo / functions.php
Created October 24, 2015 11:15 — forked from kloon/functions.php
WooCommerce Change Description Tab title and heading to product title
<?php
// Change the description tab title to product name
add_filter( 'woocommerce_product_tabs', 'wc_change_product_description_tab_title', 10, 1 );
function wc_change_product_description_tab_title( $tabs ) {
global $post;
if ( isset( $tabs['description']['title'] ) )
$tabs['description']['title'] = $post->post_title;
return $tabs;
}
@hslaszlo
hslaszlo / functions.php
Created October 24, 2015 11:19 — forked from kloon/functions.php
WooCommerce Was, Now, Save % price
<?php
// Add Now: R12, Was: R15, Save 20% price for items on sale
add_action( 'woocommerce_sale_price_html', 'wc_custom_sale_price', 10, 2 );
function wc_custom_sale_price( $price, $product ) {
$percentage = round( ( ( $product->regular_price - $product->get_price() ) / $product->regular_price ) * 100 );
return sprintf( __( 'Now: %s, Was: %s, Save %s', 'woocommerce' ), woocommerce_price( $product->get_price() ), woocommerce_price( $product->regular_price ), $percentage . '%' );
}
?>
/**
* Add "Ingredients" and "Benefits" tabs to WooCommerce products
*
* @link http://blackhillswebworks.com/?p=5453
* @link http://www.sean-barton.co.uk/2013/03/remove-woocommerce-20-reviews-tab
* @link http://www.php.net/manual/en/function.htmlspecialchars-decode.php
*/
add_filter( 'woocommerce_product_tabs', 'bhww_woo_extra_tabs' );
<?php
/**
* Plugin Name: WooCommerce plus Contact Form 7
* Plugin URI: http://reigelgallarde.me/plugins/how-to-add-inquiry-tab-to-your-product-in-woocommerce-using-contact-form-7
* Description: Additional Tab Product Inquiry.
* Author: Reigel Gallarde
* Author URI: http://reigelgallarde.me
* Version: 0.1
* Tested up to: 4.1
*
@hslaszlo
hslaszlo / gist:51611b507dda1d2ad06725843ac5a449
Created July 17, 2016 08:19 — forked from corsonr/gist:5947181
Show WooCommerce product ID in a custom column on products list page
<?php
/**
* Plugin Name: WooCommerce - Show products IDs
* Plugin URI: http://www.remicorson.com/easily-find-woocommerce-products-id/
* Description: Adds a new columns to products list page to display product IDs
* Version: 1.0
* Author: Remi Corson
* Author URI: http://remicorson.com
* Requires at least: 3.5
* Tested up to: 3.5
@hslaszlo
hslaszlo / gist:012f280c8c2a63e0d4dd035bf6108166
Created July 17, 2016 08:20 — forked from corsonr/gist:6138666
WooCommerce - List products by attribute (multiple values), ex: [woo_products_by_attributes attribute="colour" values="red,black" per_page="5"]
<?php
/**
* Plugin Name: WooCommerce - List Products by Attributes
* Plugin URI: http://www.remicorson.com/list-woocommerce-products-by-attributes/
* Description: List WooCommerce products by attributes using a shortcode, ex: [woo_products_by_attributes attribute="colour" values="red,black" per_page="5"]
* Version: 1.0
* Author: Remi Corson
* Author URI: http://remicorson.com
* Requires at least: 3.5
* Tested up to: 3.5
@hslaszlo
hslaszlo / functions.php
Created December 21, 2017 07:35 — forked from dleone81/functions.php
Woocommerce get product type
/**
* is_type can be simple, variable, grouped, external
* woocommerce_single_product_summary is hook!
* Put this into your functions.php (child-theme)
**/
add_action( 'woocommerce_single_product_summary', 'get_product_type', 5 );
function get_product_type() {
global $post;
if( function_exists('get_product') ){
$product = get_product( $post->ID );