Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Tiago Bega tsbega

🏠
Working from home
View GitHub Profile
@tsbega
tsbega / example-ajax-enqueue.php
Created Mar 18, 2020 — forked from devinsays/example-ajax-enqueue.php
Simple WordPress Ajax Example
View example-ajax-enqueue.php
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array('jquery')
);
@tsbega
tsbega / .htaccess
Last active Feb 20, 2020 — forked from boogah/.htaccess
Expire headers .htaccess code.
View .htaccess
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
View show-template.php
<?php
function show_template() {
global $template;
print_r($template);
}
add_action('wp_footer', 'show_template');
?>
@tsbega
tsbega / optimize-images.sh
Last active Oct 7, 2020 — forked from rkbhochalya/optimize-images.sh
Recursively optimize PNG and JPEG images using convert command
View optimize-images.sh
# Recursively optimize PNG and JPEG images using convert command
#
# `convert` is part of ImageMagick (http://www.imagemagick.org/). You will need to install it first.
#
# Author: Rajendra Kumar Bhochalya (http://rkb.io)
#
# @see https://developers.google.com/speed/docs/insights/OptimizeImages
# Optimize all JPEG images in current directory and subdirectories
find . -name "*.jpg" -exec convert "{}" -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB "{}" \; -exec echo "{}" \;
@tsbega
tsbega / custom-login-styles.css
Created Jan 30, 2019 — forked from gugaalves/custom-login-styles.css
WordPress - Customizing Login, Register and Lost Password pages
View custom-login-styles.css
/*
*
* This CSS template will customize WordPress.org login page:
*
* Login page: /wp-login.php
* Register page: /wp-login.php?action=register
* Lost Password page: /wp-login.php?action=lostpassword
*
* @site https://tudoparawp.com.br
* @author Guga Alves
@tsbega
tsbega / woocommerce-optimize-scripts.php
Created Jan 19, 2019 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
View woocommerce-optimize-scripts.php
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@tsbega
tsbega / magento-nginx.conf
Created Aug 23, 2018 — forked from gwillem/magento-nginx.conf
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
View magento-nginx.conf
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
View estados-cidades.json
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@tsbega
tsbega / Main.java
Created Jun 19, 2018 — forked from JFRode/Main.java
SQL para registro de todos os estados e cidades do Brasil
View Main.java
package jfrode.jsontosql.main;
import java.io.BufferedReader;
import java.io.FileReader;
import org.json.JSONArray;
import org.json.JSONObject;
/**
*
@tsbega
tsbega / Main.java
Created Jun 19, 2018 — forked from JFRode/Main.java
SQL para registro de todos os estados e cidades do Brasil
View Main.java
package jfrode.jsontosql.main;
import java.io.BufferedReader;
import java.io.FileReader;
import org.json.JSONArray;
import org.json.JSONObject;
/**
*