Skip to content

Instantly share code, notes, and snippets.

View kadai's full-sized avatar

Kadai Crosshansen kadai

View GitHub Profile
@kadai
kadai / htaccess
Last active November 8, 2017 07:23
php_value memory_limit 256M
<?php
function mostrar_busqueda( $items, $args ){
/* SI NO ES EL MENU PRINCIPAL, REGRESAMOS EL MENU SIN TOCAR */
if ( "primary" != $args->theme_location ){
return $items;
}
$formulario = get_search_form(FALSE);
/wp-content/languages/themes/
<?php
function dtorrer_agregar_seguimiento_envio() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'https://dtorrer.com/url-destino';
}, false );
</script>
<?php
<?php
function dtorrer_agregar_seguimiento_envio() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
ga( 'send', 'event', 'Contact Form', 'submit' );
location = 'https://dtorrer.com/url-destino';
}, false );
</script>
CREATE TABLE $tableprefix_et_social_stats (
id mediumint(9) NOT NULL AUTO_INCREMENT,
sharing_date datetime DEFAULT '1000-01-01 00:00:00' NOT NULL,
network varchar(20) NOT NULL,
action varchar(10) NOT NULL,
post_id bigint(20) NOT NULL,
ip_address varchar(45) NOT NULL,
media_url varchar(2083) NOT NULL,
location varchar(20) NOT NULL,
UNIQUE KEY id (id)) DEFAULT CHARACTER SET utf8
@kadai
kadai / functions.php
Created May 8, 2018 03:32
Función para conocer el desempeño de WordPress
<?php
add_filter('wp_footer', dtorrer_diagnostico);
function dtorrer_diagnostico(){
$datos = array();
$datos[] = 'Fecha: ' . date('Y-m-d H:i:s');
$datos[] = 'Tiempo: ' . timer_stop(0, 2) . ' segundos.';
if (function_exists('memory_get_usage')) {
$unidades = array('b','kb','mb','gb','tb','pb');
<?php
/* SI TENEMOS UN REDIRECTING LOOP CON CLOUDFLARE Y HTTPS */
/* LE OBLIGAMOS AL SERVIDOR A "ACTIVAR" EL MODO HTTPS */
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
/* SI USAMOS CLOUDFLARE, USAMOS ESTO PARA RESTAURAR EL IP DEL VISITANTE */
if ( !empty( $_SERVER['REMOTE_ADDR'] ) && !empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) )
<?php
add_action( 'wp_enqueue_scripts', 'dtorrer_agregar_estilos_al_tema' );
function dtorrer_agregar_estilos_al_tema() {
wp_enqueue_style( 'estilos-temapadre', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'estilos-temahijo', get_stylesheet_directory_uri() . '/style.css',array( 'estilos-temapadre' ) );
}
?>
@kadai
kadai / 001-filterbyhttpcode.php
Created October 29, 2018 20:05
Some solutions to some common problems found in the plugin Swift Performance.
<?php
/*
* We verify the HTTP code that WordPress will send and then we decide if the current page
* should be allowed to be cached.
*/
add_filter('swift_performance_is_cacheable', 'dtorrer_swift_iscacheable', 20, 1);
function dtorrer_swift_iscacheable( $cacheable = FALSE ){
if( FALSE === $cacheable ){ return $cacheable; }