Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / functions.php
Created February 23, 2018 20:00 — forked from claudiosanches/functions.php
WooCommerce - Variable product with custom price labels
function custom_variable_price_html( $price, $product ) {
$price = '';
if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
$price .= '<span class="from">' . __( 'A partir de' ) . ' </span>';
}
$price .= woocommerce_price( $product->get_price() );
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
@monecchi
monecchi / function-localize.php
Created June 19, 2017 15:17 — forked from neilgee/function-localize.php
wp_localize_script using Booleans & Integers
<?php
//wp_localize_script by default passes everything in as strings so for booleans and integers when being referenced in your javascript you need to do some trickery
//Example 1 - passing in booleans as strings
$options = get_option('ng_slicknavmenu');
// Add PHP plugin variables to the $params[] array to pass to jQuery
$data = array (
'ng_slicknav_menu' => $options['ng_slicknav_menu'],
'ng_slicknav_position' => $options['ng_slicknav_position'],
@monecchi
monecchi / get-svg.php
Created March 16, 2017 11:54 — forked from spigotdesign/get-svg.php
WordPress get SVG file contents
<?php echo file_get_contents( get_stylesheet_directory_uri() . '/img/icons/your-logo-file.svg' ); ?>
@monecchi
monecchi / high-dpi-media.css
Created March 12, 2017 18:22 — forked from marcedwards/high-dpi-media.css
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@monecchi
monecchi / fa-icon-walker.php
Created March 9, 2017 12:56 — forked from Freekbron/fa-icon-walker.php
Font Awesome - WordPress - Custom nav walker
<?php
/**
* Custom nav walker
*
* Custom nav walker to assign icons to menu items.
*/
class FA_Icon_Walker extends Walker_Nav_Menu
{
/**
@monecchi
monecchi / functions.php
Created February 23, 2017 17:12 — forked from growdev/functions.php
WooCommerce - Remove Shipping Method if Shipping Zone Selected
<?php
add_filter( 'woocommerce_available_payment_gateways', 'filter_gateways', 1);
function filter_gateways( $gateways ) {
$method = WC()->session->get( 'chosen_shipping_methods' );
// get the value of the radio button on the checkout page
if ( 'flat_rate:1' != $method[0] ) {
unset( $gateways['paypal'] );
}
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2017.21.01
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
@monecchi
monecchi / tab-active-url-hash.php
Last active January 19, 2017 03:38 — forked from corsonr/gist:0e0a4dfaacf59fdca314
WooCommerce: activate product tabs from URL
<?php
/**
* wc_direct_link_to_product_tabs
*
* Allows you to create custom URLs to activate product tabs by default, directly from the URL
* ex: http://mysite.com/my-product-name#reviews
*/
function wc_direct_link_to_product_tabs() {
if( is_product() ) {
?>
@monecchi
monecchi / get-users-first-last-name-wordpress.php
Created December 1, 2016 23:28 — forked from kellenmace/get-users-first-last-name-wordpress.php
Get User's First and Last Name in WordPress
<?php
/**
* Get user's first and last name, else just their first name, else their
* display name. Defalts to the current user if $user_id is not provided.
*
* @param mixed $user_id The user ID or object. Default is current user.
* @return string The user's name.
*/
function km_get_users_name( $user_id = null ) {
@monecchi
monecchi / bin-cc.md
Created August 31, 2016 18:33 — forked from erikhenrique/bin-cc.md
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3