Skip to content

Instantly share code, notes, and snippets.

View deryckoe's full-sized avatar

Deryck Oñate Espinel deryckoe

View GitHub Profile
@deryckoe
deryckoe / wp-shortcode-cleanup.php
Last active August 29, 2015 14:07
Shortcode Garbage Markup Cleanup
public function cleanup_shortcode_fix($content) {
$array = array('<p>[' => '[', ']</p>' => ']', ']<br />' => ']', ']<br>' => ']');
$content = strtr($content, $array);
return $content;
}
add_filter('the_content', 'cleanup_shortcode_fix');
@deryckoe
deryckoe / wp-uc-redirect.php
Created September 28, 2014 16:16
Redirect if no admin - WordPress
function under_construcction() {
if ( ! is_page('login') ) {
if ( ! is_user_logged_in() ) {
wp_redirect( '/en-construccion/', 301 ); // o puedes redireccionar a una página dentro de WordPress, utilizando get_permalink();
exit;
}
}
}
<?php /**
* Template Name: Pre Home
*/?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PATAGONIA BLUE</title>
</head>
@deryckoe
deryckoe / add_action.php
Last active February 15, 2017 23:02
WP Expertos/60/add_action
<?php add_action( 'hook', 'funcion', $prioridad, $argumentos ); ?>
@deryckoe
deryckoe / enqueue_styles.php
Last active February 17, 2017 19:20
WPExpertos/Child Themes
<?php
function wpxp_load_styles() {
// Carga los estilos de este tema hijo
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
// Carga la tipografia Exo de Google
wp_enqueue_style( 'google-exo', 'https://fonts.googleapis.com/css?family=Exo' );
}
@deryckoe
deryckoe / class-tgm-plugin-activation.php
Created February 19, 2017 13:36
WP Expertos/Habilitar TGM en tu theme
<?php
/**
* Plugin installation and activation for WordPress themes.
*
* @package TGM-Plugin-Activation
* @version 2.4.0
* @author Thomas Griffin <thomasgriffinmedia.com>
* @author Gary Jones <gamajo.com>
* @copyright Copyright (c) 2012, Thomas Griffin
* @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
@deryckoe
deryckoe / author-box.php
Last active November 6, 2018 05:58
WP Expertos/Author Profile Plugin
<div class="author__wrapper">
<div class="author__avatar">
<?php echo get_avatar( $user->ID ); ?>
</div>
<h1 class="author__name"><?php echo esc_html( $user->display_name ); ?></h1>
<div class="author__description">
<?php echo apply_filters( 'the_content', $user->description ); ?>
</div>
</div>
@deryckoe
deryckoe / .htaccess
Last active April 13, 2018 18:39
Remote Upload
#Put this file in wp-content/uploads and modify remote domain.
#Copia este arhivo en wp-content/uploads and modifica el dominio remoto.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://remotedomain.tld/wp-content/uploads/$1 [L,P]
</IfModule>
@deryckoe
deryckoe / admin_footer_text.php
Last active July 29, 2017 15:14
Filtra el texto mostrado en el pie de página del administrador.
@deryckoe
deryckoe / rss_widget.php
Last active July 29, 2017 15:40
Agrega un RSS de noticias al Dashboard de WordPress
<?php
/**
* Agrega un RSS de noticias al Dashboard de WordPress
*/
function wpe_add_dashboard_widgets() {
wp_add_dashboard_widget( 'dashboard_custom_feed', 'Noticias de WP Expertos', 'wpe_rss_widget' );
}