Skip to content

Instantly share code, notes, and snippets.

View claudiosanches's full-sized avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / functions.php
Created November 8, 2016 14:13
WooCommerce - Validating new "My account" registration fields
<?php
/**
* Validate the extra register fields.
*
* @param WP_Error $validation_errors Errors.
* @param string $username Current username.
* @param string $email Current email.
*
* @return WP_Error
*/
@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 / install.sh
Last active September 3, 2021 15:48
Ubuntu - Install Strem.io
#!/usr/bin/env bash
sudo su
curl -SO# http://178.62.254.47/Stremio3.5.1.linux.tar.gz
mkdir -p /opt/stremio
tar -xvzf Stremio3.5.1.linux.tar.gz -C /opt/stremio
curl -SO# http://www.strem.io/3.0/stremio-white-small.png
mv stremio-white-small.png /opt/stremio/
curl -SO# https://gist.githubusercontent.com/claudiosmweb/797b502bc095dabee606/raw/52ad06b73d90a4ef389a384fbc815066c89798eb/stremio.desktop
mv stremio.desktop /usr/share/applications/
@claudiosanches
claudiosanches / functions.php
Last active January 4, 2021 07:10
WooCommerce Custom CSS
<?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 January 12, 2013 02:33
WooCommerce - Botão ver detalhes no lugar do botão de adicionar ao carrinho.
<?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 September 15, 2012 16:46
Custom posts per page for Taxonomy
<?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 September 12, 2014 13:49
WooCommerce 2.2 - Register new order statuses.
<?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,
@claudiosanches
claudiosanches / php-mail.md
Last active October 31, 2019 22:55
Ubuntu - PHP email with Gmail.

Install

sudo apt-get install ssmtp

Configuration

Open /etc/ssmtp/ssmtp.conf.

@claudiosanches
claudiosanches / functions.php
Created May 24, 2014 17:38
WooCommerce Extra Checkout Fields for Brazil - Neighborhood required
<?php
function custom_wcbcf_billing_fields( $fields ) {
$fields['billing_neighborhood']['required'] = true;
return $fields;
}
add_filter( 'wcbcf_billing_fields', 'custom_wcbcf_billing_fields' );
function custom_wcbcf_shipping_fields( $fields ) {
@claudiosanches
claudiosanches / functions.php
Created September 30, 2013 14:07
WooCommerce - Hide price and add-to-cart button for non-logged in users.
<?php
function woocommerce_template_loop_price() {
if ( is_user_logged_in() )
woocommerce_get_template( 'loop/price.php' );
}
function woocommerce_template_loop_add_to_cart() {
if ( is_user_logged_in() )
woocommerce_get_template( 'loop/add-to-cart.php' );