Skip to content

Instantly share code, notes, and snippets.

View mrfoxtalbot's full-sized avatar

Alvaro Gómez Velasco mrfoxtalbot

View GitHub Profile
@mrfoxtalbot
mrfoxtalbot / gist:755c7a3733443de04e45
Last active August 29, 2015 14:26 — forked from mikejolley/gist:11171530
Hide all/some shipping options when free shipping is available
/**
* woocommerce_package_rates is a 2.1+ hook
*/
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
/**
* Hide shipping rates when free shipping is available
*
* @param array $rates Array of rates found for the package
* @param array $package The package array/object being shipped
@mrfoxtalbot
mrfoxtalbot / gist:bf4f274c312ccfe80ac7
Last active October 12, 2017 08:53
jQuery que funciona (javascript, via @grindcode)
jQuery( document ).ready(function($) {
$( ".foo" ).addClass( "superfoo" )
;});
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
unmeta_id – leave this blank (it will be auto-generated)
user_id – this will be the id of the user you created in the previous step. Remember we picked 4.
meta_key – this should be wp_capabilities
@mrfoxtalbot
mrfoxtalbot / gist:390ab0fae260436549a8
Created October 27, 2015 21:05 — forked from corsonr/gist:9152652
WooCommerce : add custom fields to product variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 3 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'save_variable_fields', 10, 1 );
/**
@mrfoxtalbot
mrfoxtalbot / How to use html entities in a css pseudo element
Last active January 4, 2016 12:58
Unicode hex values for CSS pseudo element
You can't use html entities in a css pseudo element, because it inserts the ampersand and everything :
a:before { content: '&#xe139;'; }
In order to get it to work, you have to use the unicode hex values, which are stupid hard to figure out:
a:before { content: '\E139'; }
I had to use this unicode code converter to get the proper codepoints, but it would be super awesome if you provided them to begin with along with the html entities.
@mrfoxtalbot
mrfoxtalbot / gist:159046d75d4b9619365b
Created November 17, 2015 17:08
Ejemplo de Shortcode concatenando strings y usando funciones
function privateshare() {
$titulo = get_the_title();
$enlace = get_the_permalink();
$loquequiero = '<a href="mailto:?subject=Quiero compartir contigo este artículo&body=' .$titulo. ': ' .$enlace. '"><img src="email-icon.png"></a>';
return $loquequiero;
}
add_shortcode("privateshare", "privateshare");
@mrfoxtalbot
mrfoxtalbot / site-new.php
Created November 19, 2015 13:54 — forked from igmoweb/site-new.php
Custom query shortcode
<?php
add_shortcode( 'areas', 'custom_query_shortcode' );
function custom_query_shortcode( $atts ) {
// EXAMPLE USAGE:
// [areas show_posts="100" post_type="page" post_parent="246"]
// Defaults
$defaults = array(
"show_posts" => 100,
"post_type" => 'page',
If your table prefix is “wp_” or “wp1_” or even “wordpress_”, then changing it will bring your WordPress site security to a higher level.
By default Fantastico installation sets “wp_” as a prefix for each WordPress table name. Since this is a known vulnerability, malicious users can exploit your data easily.
They specifically look for the wp_options table, because it will alter your WordPress site look. Through wp_options they can set the url to redirect to their sites, leaving you the impression that your site was defaced.
If you already have a WordPress site, take a look at either your config.php file or go to phpMyAdmin in cPanel to check your tables names.
// Entry in config.php showing wordpress table prefix used in the installation
$table_prefix = ‘wp_'; // Only numbers, letters, and underscores please!
Attackers can easily send malicious code using JavaScript injecting SQL targeting your wp_ based tables. To make your wordpress site really secure, change the prefix to something that is difficult to
// Callback - Manejador de Eventos
function manejadorEventos(elEvento) {
// Compatibilizar el evento
var evento = elEvento || window.event;
// Imprimir detalles
console.log("-----------------------------")
console.log("Type: "+evento.type); // Tipo
console.log("Bubbles: "+evento.bubbles);
console.log("Cancelable: "+evento.cancelable);
console.log("CurrentTarget: ", evento.currentTarget);
add_filter( 'wpcf7_validate_email*', 'custom_email_confirmation_validation_filter', 20, 2 );
function custom_email_confirmation_validation_filter( $result, $tag ) {
$tag = new WPCF7_Shortcode( $tag );
if ( 'your-email-confirm' == $tag->name ) {
$your_email = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : '';
$your_email_confirm = isset( $_POST['your-email-confirm'] ) ? trim( $_POST['your-email-confirm'] ) : '';
if ( $your_email != $your_email_confirm ) {