Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / index.html
Last active Jun 8, 2021
HTML5 - Validar número de celular em São Paulo
View index.html
<div class="form-group">
<label for="phone">Telefone <span class="required">*</span></label>
<input type="text" class="form-control" id="phone" name="phone" placeholder="(99) 9999-9999" pattern="(\([0-9]{2}\))\s([9]{1})?([0-9]{4})-([0-9]{4})" title="Número de telefone precisa ser no formato (99) 9999-9999" required="required" />
</div>
@claudiosanches
claudiosanches / functions.php
Last active May 9, 2021
WooCommerce - Change ajax variation threshold
View functions.php
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 10;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
@claudiosanches
claudiosanches / functions.php
Last active Apr 28, 2021
WooCommerce - Hide the "In stock" message on product page.
View functions.php
<?php
/**
* Hide the "In stock" message on product page.
*
* @param string $html
* @param string $text
* @param WC_Product $product
* @return string
*/
function my_wc_hide_in_stock_message( $html, $text, $product ) {
@claudiosanches
claudiosanches / functions.php
Created Jul 6, 2016
WooCommerce - Custom tag cloud shortcode
View functions.php
<?php
/**
* Custom WooCommerce tag cloud shortcode.
*
* Use the follow shortcode in your pages: [my_wc_tag_cloud]
*/
function my_custom_wc_tag_cloud_shortcode() {
return wp_tag_cloud( array( 'taxonomy' => 'product_tag', 'echo' => false ) );
}
@claudiosanches
claudiosanches / svn-checkout.sh
Last active Jan 21, 2021
SVN - Checkout project and don't fetch content for all tags
View svn-checkout.sh
svn co --depth=files https://plugins.svn.wordpress.org/woocommerce/ # Checkout project without fetching content
cd woocommerce
svn up assets branches trunk # Fetch content for everything except for the tags
svn up --set-depth=immediates tags # Create tags directory tree, but don't fetch any content
svn up --set-depth=infinity tags/<tag_number> # Fetch content for a tag
@claudiosanches
claudiosanches / changing-php-version.md
Last active Jan 18, 2021
Changing PHP version on Ubuntu
View changing-php-version.md

Apache

sudo a2dismod php8.0
sudo a2enmod php7.4
sudo service apache2 restart

Command line

@claudiosanches
claudiosanches / functions.php
Last active Jan 4, 2021
WooCommerce Custom CSS
View functions.php
<?php
function my_theme_woocommerce_enqueue_styles( $styles ) {
$base_url = str_replace( array( 'http:', 'https:' ), '', get_stylesheet_directory_uri() ) . '/inc/woocommerce/css/';
$styles['woocommerce-layout']['src'] = $base_url . 'woocommerce-layout.css';
$styles['woocommerce-smallscreen']['src'] = $base_url . 'woocommerce-smallscreen.css';
$styles['woocommerce-general']['src'] = $base_url . 'woocommerce.css';
return $styles;
@claudiosanches
claudiosanches / add-to-cart.php
Created Jan 12, 2013
WooCommerce - Botão ver detalhes no lugar do botão de adicionar ao carrinho.
View add-to-cart.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product;
printf( '<a href="%s" class="button">%s</a>', get_permalink( $product->id ), __( 'Ver detalhes' ) );
@claudiosanches
claudiosanches / functions.php
Created Sep 15, 2012
Custom posts per page for Taxonomy
View functions.php
<?php
/**
* Custom posts per page for Taxonomy
*/
function cs_custom_posts_per_page( $query ) {
if ( is_tax( 'Categorias' ) ) {
$query->query_vars['posts_per_page'] = 1;
return;
@claudiosanches
claudiosanches / functions.php
Created Sep 12, 2014
WooCommerce 2.2 - Register new order statuses.
View functions.php
<?php
// My new order statuses.
function register_my_new_order_statuses() {
register_post_status( 'wc-status-name', array(
'label' => _x( 'Status Name', 'Order status', 'textdomain' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,