Skip to content

Instantly share code, notes, and snippets.

:shipit:

Claudio Sanches claudiosanches

:shipit:
Block or report user

Report or block claudiosanches

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View woocommerce-pay-button-sample.php
<?php
/**
* Plugin Name: Test "pay button" support
*/
add_action( 'plugins_loaded', function() {
class My_Custom_Gateway extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'custom_gateway';
$this->has_fields = false;
@claudiosanches
claudiosanches / functions.php
Created Sep 21, 2019
WooCommerce - Change "Sale!" text
View functions.php
add_filter( 'woocommerce_sale_flash', function( $string ) {
echo '<span class="onsale">Promoção!</span>'
}, 10 );
@claudiosanches
claudiosanches / run.php
Created Jan 18, 2019
Small script to migrate Bitbucket repositories to GitHub.
View run.php
<?php
/**
* Migrate repositorioes from Bitbucket to GitHub.
*
* Usage: php run.php
*
* @package CS\Bitbucket_to_Github
* @license MIT License
*/
class CS_Bitbucket_to_Github
@claudiosanches
claudiosanches / wc-products-disable-gutenberg.php
Last active Dec 3, 2018
Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x or older
View wc-products-disable-gutenberg.php
<?php
/**
* Plugin Name: No Gutenberg for old versins of WooCommerce
* Plugin URI: https://gist.github.com/claudiosanches/d0231798eb6041e4911b4bca409ec1ac
* Description: Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x.
* Author: Claudio Sanches
* Author URI: https://claudiosanches.com
* Version: 1.0.0
* License: GPLv3
*
@claudiosanches
claudiosanches / changing-php-version.md
Last active Jan 14, 2019
Changing PHP version on Ubuntu
View changing-php-version.md

Apache

sudo a2dismod php7.2
sudo a2enmod php7.3
sudo service apache2 restart

Command line

@claudiosanches
claudiosanches / plugin.php
Created May 2, 2017
WooCommerce - Send "New User Registration" email to admins when new customer is created.
View plugin.php
<?php
/**
* Send "New User Registration" email to admins when new customer is created on WooCommerce.
*
* @param int $id New customer ID.
*/
function my_wc_customer_created_notification( $id ) {
wp_new_user_notification( $id, null, 'admin' );
}
@claudiosanches
claudiosanches / functions.php
Created Apr 5, 2017
WooCommerce - Restore "Free!" for free simple products on WooCommerce 3.0.
View functions.php
<?php
/**
* Restore single product "Free!" on WooCommerce 3.0.
*
* @param string $price Price HTML.
* @param WC_Product $product Product instance.
* @return string.
*/
function my_wc_custom_get_price_html( $price, $product ) {
if ( $product->get_price() == 0 ) {
@claudiosanches
claudiosanches / functions.php
Last active Mar 28, 2018
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 / .htaccess
Created Mar 8, 2017
Redirect all pages to a new domain
View .htaccess
RewriteEngine On
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
@claudiosanches
claudiosanches / functions.php
Last active Mar 26, 2018
WooCommerce Correios - Free PAC for Shipping Zone
View functions.php
<?php
function custom_woocommerce_correios_shipping_methods( $rate, $instance_id ) {
// Verifica se esta utilizando a instancia correta, se não estiver para o código.
if ( 99 !== $instance_id ) {
return $rate;
}
$rate['cost'] = 0;
return $rate;
You can’t perform that action at this time.