Skip to content

Instantly share code, notes, and snippets.

View claudiosanches's full-sized avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / Mailhog_installation.md
Last active May 31, 2023 14:16 — forked from dipenparmar12/Mailhog_installation.md
Mailhog installation guide (Linux)

Mailhog

1. Install GoLang

Install

Mailhog Requires Go 1.4+ to run so we will install GO language in system.

sudo apt install golang-go -y

Cross verify Go language is successfully installed.

@claudiosanches
claudiosanches / svn-checkout.sh
Last active July 4, 2022 18:32
SVN - Checkout project and don't fetch content for all tags
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 / woocommerce-pay-button-sample.php
Created November 7, 2019 20:40
WooCommerce - Pay Button sample
<?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 September 21, 2019 18:29
WooCommerce - Change "Sale!" text
add_filter( 'woocommerce_sale_flash', function( $string ) {
echo '<span class="onsale">Promoção!</span>'
}, 10 );
@claudiosanches
claudiosanches / run.php
Created January 18, 2019 18:19
Small script to migrate Bitbucket repositories to GitHub.
<?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 November 6, 2023 20:09
Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x or older
<?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 January 23, 2023 02:19
Changing PHP version on Ubuntu

Apache

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

Command line

@claudiosanches
claudiosanches / plugin.php
Created May 2, 2017 22:33
WooCommerce - Send "New User Registration" email to admins when new customer is created.
<?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 April 5, 2017 18:30
WooCommerce - Restore "Free!" for free simple products on WooCommerce 3.0.
<?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 January 8, 2024 19:36
WooCommerce - Adds a custom message about how long will take to delivery.
<?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>';
}