Skip to content

Instantly share code, notes, and snippets.

View Tmeister's full-sized avatar
🇲🇽
Working from home

Enrique Chavez Tmeister

🇲🇽
Working from home
View GitHub Profile
@Tmeister
Tmeister / functions.php
Last active January 21, 2017 23:57
Remove version number from query string
<?php
/**
* Remove the ver query argument from the source path
* @param $src Script loader source path.
*
* @return string
*/
function tm_remove_query_string_version( $src ){
return remove_query_arg( 'ver', $src );
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
normal-wp-search-query.sql - takes < 1 second
tablepress-query-hook.sql - takes around 4 seconds
tablepress-thrive-hooks.sql - takes between 20 and 30 seconds and froze the server
The site is hosted in his own server.
Server spects
4 CPUS
8G Ram
80 GB SSD HD
@Tmeister
Tmeister / thrive-visual-editor.php
Created November 17, 2016 17:41
Include the TCB saved meta into query search fields - BAD IDEA!!
<?php
/**
* include the TCB saved meta into query search fields
*
* wordpress actually allows inserting post META fields in the search query,
* but it will always build the clauses with AND (between post content and post meta) e.g.:
* WHERE (posts.title LIKE '%xx%' OR posts.post_content) AND (postsmeta.meta_key = 'tve_save_post' AND postsmeta.meta_value LIKE '%xx%')
*
* - we cannot use this, so we hook into the final pieces of the built SQL query - we need a solution like this:
/*
# Time: 2016-11-17T01:05:06.879587Z
# User@Host: -----[-----] @ localhost [127.0.0.1] Id: 1150
# Query_time: 60.799160 Lock_time: 0.000680 Rows_sent: 14 Rows_examined: 209299
*/
SELECT SQL_CALC_FOUND_ROWS wp_s3bgzgx9jq_posts.ID FROM wp_s3bgzgx9jq_posts LEFT JOIN wp_s3bgzgx9jq_postmeta
AS tve_pm ON (wp_s3bgzgx9jq_posts.ID = tve_pm.post_id) WHERE 1=1
AND ( ((tve_pm.meta_key = 'tve_save_post') AND (tve_pm.meta_value LIKE '%Box%'))
OR ((tve_pm.meta_key = 'tve_save_post') AND (tve_pm.meta_value LIKE '%mods%'))
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
/*
Theme Name: Twenty Sixteen Child
Theme URI: http://tusitio.com/twentysixteen-child/
Description: My tema hijo basado en Twenty Sixteen
Author: Enrique Chavez
Author URI: https://enriquechavez.co
Template: twentysixteen
Version: 1.0.0
Tags: black, green, white, light, dark, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready, responsive-layout, infinite-scroll, post-slider, design, food, journal, magazine, news, photography, portfolio, clean, contemporary, dark, elegant, modern, professional, sophisticated
Text Domain: twenty-sixteen-child
<?php
$content = get_the_content(); // O de donde obtengas tu contenido https://codex.wordpress.org/Function_Reference/get_the_content.
$tagless = wp_strip_all_tags( $content ); // Remueve las etiquetas HTML https://codex.wordpress.org/Function_Reference/wp_strip_all_tags
$short = substr( $tagless, 0, 100); // "Corta" el texto del 0 al 100 http://php.net/manual/en/function.substr.php
echo $short;
@Tmeister
Tmeister / nginx.conf
Last active November 11, 2019 16:13
Laravel Server Setup
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel/public;
index index.php index.html index.htm;
server_name localhost;
location ~ \.php$ {
mysql> select * from currencies;
+----+-----------------------------+-------------+---------------+
| id | name | google_code | official_code |
+----+-----------------------------+-------------+---------------+
| 1 | Argentine Peso | ARS | ARS |
| 2 | Australian Dollar | A$ | AUD |
| 3 | Bolivian Boliviano | BOB | BOB |
| 4 | Brazilian Real | R$ | BRL |
| 5 | British Pound | £ | GBP |
| 6 | Brunei Dollar | BND | BND |