Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Tiago Bega tsbega

🏠
Working from home
View GitHub Profile
@tsbega
tsbega / functions.php
Created Jul 20, 2017 — forked from ofernandolopes/functions.php
Limit Authors to their Own Posts in WordPress Admin
View functions.php
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'manage_options' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
@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;
/**
*
View estados-cidades.json
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@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 {
@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 / 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
View show-template.php
<?php
function show_template() {
global $template;
print_r($template);
}
add_action('wp_footer', 'show_template');
?>
@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"
@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')
);