Skip to content

Instantly share code, notes, and snippets.

Working from home

Tiago Bega tsbega

Working from home
View GitHub Profile
View Character limitation for Address Fields.php
add_filter( 'wfacp_forms_field', function($field,$key){
if($key=='billing_number' || $key=='shipping_number'){
if($key=='billing_address_2' || $key=='shipping_address_2'){
tsbega /
Created Mar 25, 2021 — forked from denji/
NGINX tuning for best performance

Moved to git repository:

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

tsbega / delete-all-woocommerce-products.php
Created Mar 17, 2021 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
View delete-all-woocommerce-products.php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
tsbega / nginx device redirect
Created Nov 11, 2020 — forked from mariusom/nginx device redirect
Nginx detecting desktop, tablet or mobile by looking tat the http user agent.
View nginx device redirect
# Source:
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|t
View Register Custom Taxonomy Woocommerce Products
// Register Custom Taxonomy
function ess_custom_taxonomy_Item() {
$labels = array(
'name' => 'Brands',
'singular_name' => 'Brand',
'menu_name' => 'Brands',
'all_items' => 'All Brands',
'parent_item' => 'Parent Brand',
'parent_item_colon' => 'Parent Brand:',
tsbega / elementor-canvas-scripts.php
Created Aug 24, 2020 — forked from norewp/elementor-canvas-scripts.php
Custom scripts only on the Elementor Canvas template
View elementor-canvas-scripts.php
<?php // You probably don't need to add this opening PHP tag!
function my_custom_canvas_scripts() {
$classes = get_body_class();
if ( in_array( 'page-template-elementor_canvas', $classes ) ) { ?>
<script type="text/javascript">
<!--[Custom Script]><!-->
//(function($) { //Uncomment this for no conflict jQuery
// Add your script here
tsbega / add-taxonomy-to-woocommerce-export.php
Created Jul 27, 2020 — forked from helgatheviking/add-taxonomy-to-woocommerce-export.php
Add a custom taxonomy to WooCommerce import/export
View add-taxonomy-to-woocommerce-export.php
* Plugin Name: WooCommerce Add Taxonomy to Export
* Plugin URI:
* Description: Add a custom taxonomy to WooCommerce import/export.
* Version: 1.0.1
* Author: Kathy Darling
* Author URI:
* Woo: 18716:fbca839929aaddc78797a5b511c14da9
View wp_functions.php
// Meta Tags Generator
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'woo_version');
// Retirando a barra do admin no wordpress
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
function my_function_admin_bar(){
return false;
tsbega / image-shortcode.php
Created Mar 27, 2020 — forked from kovshenin/image-shortcode.php
Image shortcode for WordPress
View image-shortcode.php
* Image shortcode callback
* Enables the [kovshenin_image] shortcode, pseudo-TimThumb but creates resized and cropped image files
* from existing media library entries. Usage:
* [kovshenin_image src="" width="100" height="100"]
* @uses image_make_intermediate_size
tsbega /
Created Mar 20, 2020 — forked from lewg/
UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
# UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
# Based on
# Cambodia (KH)
ufw deny from to any port 22
# Chinese (CN) IP addresses follow:
ufw deny from to any port 22
ufw deny from to any port 22