Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / test.php
Last active Jan 26, 2023
Regex for test credit card brand
View test.php
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@claudiosanches
claudiosanches / index.html
Last active Jan 25, 2023
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 / changing-php-version.md
Last active Jan 23, 2023
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 / exemplo-media-queries-condicoes.html
Created May 19, 2012
Layout Responsivo #01: Introdução
View exemplo-media-queries-condicoes.html
<!DOCTYPE html>
<html>
<head>
<title>Exemplo de Media Types</title>
<!-- todos os dispositivos -->
<link href="estilos.css" rel="stylesheet" type="text/css" media="all" />
<!-- monitores e com largura máxima de 600px (por exemplo tablets) -->
<link href="estilo1.css" rel="stylesheet" type="text/css" media="screen and (max-width: 800px)" />
<!-- apenas para monitores coloridos -->
<link href="estilo2.css" rel="stylesheet" type="text/css" media="only screen and (color)" />
@claudiosanches
claudiosanches / functions.php
Last active Jan 12, 2023
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 Nov 17, 2022
WooCommerce - Adds a custom message about how long will take to delivery.
View functions.php
<?php
/**
* Adds a custom message about how long will take to delivery.
*/
function my_wc_custom_cart_shipping_notice() {
echo '<tr class="shipping-notice"><td colspan="2"><small>';
_e( '<strong>Atenção:</strong> O prazo de entrega começa a contar a partir da aprovação do pagamento.', 'my-text-domain' );
echo '</small></td></tr>';
}
@claudiosanches
claudiosanches / functions.php
Created Dec 1, 2012
WooCommerce - Custom Simple Product price format.
View functions.php
<?php
/**
* Custom simple product price format.
*
* Adds credit cart parcels in price html.
*
* @param string $price Old price format.
*
* @return string Price format with credit card parcels.
*/
@claudiosanches
claudiosanches / functions.php
Last active Oct 31, 2022
WooCommerce Correios - PAC Free
View functions.php
<?php
function custom_woocommerce_correios_shipping_methods( $rate ) {
$rate['cost'] = 0;
return $rate;
}
add_filter( 'woocommerce_correios_correios-pac_rate', 'custom_woocommerce_correios_shipping_methods' );
@claudiosanches
claudiosanches / recebe.php
Created Sep 30, 2012
Exemplo de como adicionar ou atualizar dados com WPDB
View recebe.php
<?php
// Update table
function cs_add_data($competition, $date, $numbers) {
global $wpdb;
$table_name = $wpdb->prefix . 'nome da sua tabela';
$numbers = str_replace('/', '-', $numbers);
// Test variables
if (!is_numeric($competition))
wp_die('O número do concurso é inválido');
@claudiosanches
claudiosanches / woocommerce-installments-example.php
Last active Oct 12, 2022
WooCommerce - Displays the price in 3 installments without interest.
View woocommerce-installments-example.php
<?php
/**
* Plugin Name: WooCommerce Installments Example
* Plugin URI: http://claudiosmweb.com/
* Description: Added the price with 3 installments without interest.
* Author: claudiosanches
* Author URI: http://www.claudiosmweb.com/
* Version: 1.0
* License: GPLv2 or later
*/