Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / svn-checkout.sh
Created May 27, 2020
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
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
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 Apr 7, 2020
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 Apr 7, 2020
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 Jun 9, 2020
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]
You can’t perform that action at this time.